Request AI agents to process the user input.
(self)
| 274 | self.last_query = query |
| 275 | |
| 276 | async def think(self) -> bool: |
| 277 | """Request AI agents to process the user input.""" |
| 278 | push_last_agent_memory = False |
| 279 | if self.last_query is None or len(self.last_query) == 0: |
| 280 | return False |
| 281 | agent = self.router.select_agent(self.last_query) |
| 282 | if agent is None: |
| 283 | return False |
| 284 | if self.current_agent != agent and self.last_answer is not None: |
| 285 | push_last_agent_memory = True |
| 286 | tmp = self.last_answer |
| 287 | self.current_agent = agent |
| 288 | self.is_generating = True |
| 289 | self.last_answer, self.last_reasoning = await agent.process(self.last_query, self.speech) |
| 290 | self.is_generating = False |
| 291 | if push_last_agent_memory: |
| 292 | self.current_agent.memory.push('user', self.last_query) |
| 293 | self.current_agent.memory.push('assistant', self.last_answer) |
| 294 | if self.last_answer == tmp: |
| 295 | self.last_answer = None |
| 296 | return True |
| 297 | |
| 298 | def get_updated_process_answer(self) -> str: |
| 299 | """Get the answer from the last agent.""" |
no test coverage detected