Create a fallback plan using heuristic logic (no LLM required)
(prompt: &str)
| 147 | |
| 148 | /// Create a fallback plan using heuristic logic (no LLM required) |
| 149 | pub fn fallback_plan(prompt: &str) -> ExecutionPlan { |
| 150 | let complexity = if prompt.len() < 50 { |
| 151 | Complexity::Simple |
| 152 | } else if prompt.len() < 150 { |
| 153 | Complexity::Medium |
| 154 | } else if prompt.len() < 300 { |
| 155 | Complexity::Complex |
| 156 | } else { |
| 157 | Complexity::VeryComplex |
| 158 | }; |
| 159 | |
| 160 | let mut plan = ExecutionPlan::new(prompt, complexity); |
| 161 | |
| 162 | let step_count = match complexity { |
| 163 | Complexity::Simple => 2, |
| 164 | Complexity::Medium => 4, |
| 165 | Complexity::Complex => 7, |
| 166 | Complexity::VeryComplex => 10, |
| 167 | }; |
| 168 | |
| 169 | for i in 0..step_count { |
| 170 | let step = Task::new( |
| 171 | format!("step-{}", i + 1), |
| 172 | crate::prompts::render( |
| 173 | crate::prompts::PLAN_FALLBACK_STEP, |
| 174 | &[("step_num", &(i + 1).to_string())], |
| 175 | ), |
| 176 | ); |
| 177 | plan.add_step(step); |
| 178 | } |
| 179 | |
| 180 | plan |
| 181 | } |
| 182 | |
| 183 | /// Create a fallback goal using heuristic logic (no LLM required) |
| 184 | pub fn fallback_goal(prompt: &str) -> AgentGoal { |