Skip to content

Commit

Permalink
feat: error handling for conversation agent
Browse files Browse the repository at this point in the history
  • Loading branch information
wuyiqunLu committed Sep 24, 2024
1 parent d59c893 commit 4034797
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
21 changes: 19 additions & 2 deletions vision_agent/agent/vision_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,15 +314,32 @@ def chat_with_code(

# sometimes it gets stuck in a loop, so we force it to exit
if last_response == response:
response["let_user_respond"] = True
self.streaming_message(
{"role": "assistant", "error": "Stuck in loop"}
{
"role": "assistant",
"finished": True,
"content": "{}",
"error": {
"name": "Error when running conversation agent",
"value": "Agent is stuck in conversation loop, exited",
"traceback_raw": [],
},
}
)
break
elif response["let_user_respond"]:
self.streaming_message(
{"role": "assistant", "content": response, "finished": True}
)
break
else:
self.streaming_message({"role": "assistant", "content": response})

<<<<<<< Updated upstream
finished = response["let_user_respond"]

=======
>>>>>>> Stashed changes
code_action = parse_execution(
response["response"], test_multi_plan, customized_tool_names
)
Expand Down
1 change: 1 addition & 0 deletions vision_agent/tools/meta_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,7 @@ def detect_dogs(image_path: str):

agent = va.agent.VisionAgentCoder()
if name not in artifacts:
print(f"[Artifact {name} does not exist]")
return f"[Artifact {name} does not exist]"

code = artifacts[name]
Expand Down

0 comments on commit 4034797

Please sign in to comment.