Show error in picking next tool to researcher llm in next iteration

Previously the whole research mode response would fail if the pick
next tool call to chat model failed. Now instead of it completely
failing, the researcher actor is told to try again in next iteration.

This allows for a more graceful degradation in answering a research
question even if a (few?) calls to the chat model fail.
This commit is contained in:
Debanjum 2024-11-10 13:14:46 -08:00
parent eb492f3025
commit 306f7a2132

View file

@ -87,15 +87,24 @@ async def apick_next_tool(
max_iterations=max_iterations,
)
with timer("Chat actor: Infer information sources to refer", logger):
response = await send_message_to_model_wrapper(
query=query,
context=function_planning_prompt,
response_type="json_object",
user=user,
query_images=query_images,
tracer=tracer,
try:
with timer("Chat actor: Infer information sources to refer", logger):
response = await send_message_to_model_wrapper(
query=query,
context=function_planning_prompt,
response_type="json_object",
user=user,
query_images=query_images,
tracer=tracer,
)
except Exception as e:
logger.error(f"Failed to infer information sources to refer: {e}", exc_info=True)
yield InformationCollectionIteration(
tool=None,
query=None,
warning="Failed to infer information sources to refer. Skipping iteration. Try again.",
)
return
try:
response = clean_json(response)