(self, prompt, speech_module)
| 44 | return f"{prompt}\n\n{info}" |
| 45 | |
| 46 | async def process(self, prompt, speech_module) -> str: |
| 47 | answer = "" |
| 48 | attempt = 0 |
| 49 | max_attempts = 5 |
| 50 | prompt = self.add_sys_info_prompt(prompt) |
| 51 | self.memory.push('user', prompt) |
| 52 | clarify_trigger = "REQUEST_CLARIFICATION" |
| 53 | |
| 54 | while attempt < max_attempts and not self.stop: |
| 55 | print("Stopped?", self.stop) |
| 56 | animate_thinking("Thinking...", color="status") |
| 57 | await self.wait_message(speech_module) |
| 58 | answer, reasoning = await self.llm_request() |
| 59 | self.last_reasoning = reasoning |
| 60 | if clarify_trigger in answer: |
| 61 | self.last_answer = answer |
| 62 | await asyncio.sleep(0) |
| 63 | return answer, reasoning |
| 64 | if not "```" in answer: |
| 65 | self.last_answer = answer |
| 66 | await asyncio.sleep(0) |
| 67 | break |
| 68 | self.show_answer() |
| 69 | animate_thinking("Executing code...", color="status") |
| 70 | self.status_message = "Executing code..." |
| 71 | self.logger.info(f"Attempt {attempt + 1}:\n{answer}") |
| 72 | exec_success, feedback = self.execute_modules(answer) |
| 73 | self.logger.info(f"Execution result: {exec_success}") |
| 74 | answer = self.remove_blocks(answer) |
| 75 | self.last_answer = answer |
| 76 | await asyncio.sleep(0) |
| 77 | if exec_success and self.get_last_tool_type() != "bash": |
| 78 | break |
| 79 | pretty_print(f"Execution failure:\n{feedback}", color="failure") |
| 80 | pretty_print("Correcting code...", color="status") |
| 81 | self.status_message = "Correcting code..." |
| 82 | attempt += 1 |
| 83 | self.status_message = "Ready" |
| 84 | if attempt == max_attempts: |
| 85 | return "I'm sorry, I couldn't find a solution to your problem. How would you like me to proceed ?", reasoning |
| 86 | self.last_answer = answer |
| 87 | return answer, reasoning |
| 88 | |
| 89 | if __name__ == "__main__": |
| 90 | pass |
nothing calls this directly
no test coverage detected