(interaction, query)
| 205 | return JSONResponse(status_code=404, content={"error": "No answer available"}) |
| 206 | |
| 207 | async def think_wrapper(interaction, query): |
| 208 | try: |
| 209 | interaction.last_query = query |
| 210 | logger.info("Agents request is being processed") |
| 211 | success = await interaction.think() |
| 212 | if not success: |
| 213 | interaction.last_answer = "Error: No answer from agent" |
| 214 | interaction.last_reasoning = "Error: No reasoning from agent" |
| 215 | interaction.last_success = False |
| 216 | else: |
| 217 | interaction.last_success = True |
| 218 | pretty_print(interaction.last_answer) |
| 219 | interaction.speak_answer() |
| 220 | return success |
| 221 | except Exception as e: |
| 222 | logger.error(f"Error in think_wrapper: {str(e)}") |
| 223 | pretty_print(f"An error occurred: {str(e)}", color="error") |
| 224 | interaction.last_answer = f"" |
| 225 | interaction.last_reasoning = f"Error: {str(e)}" |
| 226 | interaction.last_success = False |
| 227 | raise e |
| 228 | |
| 229 | @api.post("/query", response_model=QueryResponse) |
| 230 | async def process_query(request: QueryRequest): |
no test coverage detected