mirror of
https://github.com/khoj-ai/khoj.git
synced 2024-11-23 23:48:56 +01:00
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:
parent
eb492f3025
commit
306f7a2132
1 changed files with 17 additions and 8 deletions
|
@ -87,15 +87,24 @@ async def apick_next_tool(
|
||||||
max_iterations=max_iterations,
|
max_iterations=max_iterations,
|
||||||
)
|
)
|
||||||
|
|
||||||
with timer("Chat actor: Infer information sources to refer", logger):
|
try:
|
||||||
response = await send_message_to_model_wrapper(
|
with timer("Chat actor: Infer information sources to refer", logger):
|
||||||
query=query,
|
response = await send_message_to_model_wrapper(
|
||||||
context=function_planning_prompt,
|
query=query,
|
||||||
response_type="json_object",
|
context=function_planning_prompt,
|
||||||
user=user,
|
response_type="json_object",
|
||||||
query_images=query_images,
|
user=user,
|
||||||
tracer=tracer,
|
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:
|
try:
|
||||||
response = clean_json(response)
|
response = clean_json(response)
|
||||||
|
|
Loading…
Reference in a new issue