MCPcopy
hub / github.com/Fosowl/agenticSeek / think_wrapper

Function think_wrapper

api.py:207–227  ·  view source on GitHub ↗
(interaction, query)

Source from the content-addressed store, hash-verified

205 return JSONResponse(status_code=404, content={"error": "No answer available"})
206
207async 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)
230async def process_query(request: QueryRequest):

Callers 1

process_queryFunction · 0.85

Calls 5

pretty_printFunction · 0.90
infoMethod · 0.80
thinkMethod · 0.80
speak_answerMethod · 0.80
errorMethod · 0.80

Tested by

no test coverage detected