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,6 +87,7 @@ async def apick_next_tool(
max_iterations=max_iterations, max_iterations=max_iterations,
) )
try:
with timer("Chat actor: Infer information sources to refer", logger): with timer("Chat actor: Infer information sources to refer", logger):
response = await send_message_to_model_wrapper( response = await send_message_to_model_wrapper(
query=query, query=query,
@ -96,6 +97,14 @@ async def apick_next_tool(
query_images=query_images, query_images=query_images,
tracer=tracer, 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: try:
response = clean_json(response) response = clean_json(response)