Skip to content

Commit

Permalink
fix: streaming back assistant response before parse code action
Browse files Browse the repository at this point in the history
  • Loading branch information
wuyiqunLu committed Oct 16, 2024
1 parent aba25ed commit 65b8ef6
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions vision_agent/agent/vision_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,19 +492,10 @@ def chat_with_artifacts(
}
)

code_action = response.get("execute_python", None)
# sometimes it gets stuck in a loop, so we force it to exit
if last_response == response:
response["let_user_respond"] = True

finished = response.get("let_user_respond", False)

code_action = response.get("execute_python", None)
if code_action is not None:
code_action = use_extra_vision_agent_args(
code_action, test_multi_plan, custom_tool_names
)

if last_response == response:
self.streaming_message(
{
"role": "assistant",
Expand All @@ -514,7 +505,7 @@ def chat_with_artifacts(
"value": "Agent is stuck in conversation loop, exited",
"traceback_raw": [],
},
"finished": finished and code_action is None,
"finished": code_action is None,
}
)
else:
Expand All @@ -524,10 +515,18 @@ def chat_with_artifacts(
"content": new_format_to_old_format(
add_step_descriptions(response)
),
"finished": finished and code_action is None,
"finished": response.get("let_user_respond", False)
and code_action is None,
}
)

finished = response.get("let_user_respond", False)

if code_action is not None:
code_action = use_extra_vision_agent_args(
code_action, test_multi_plan, custom_tool_names
)

if code_action is not None:
result, obs = execute_code_action(
artifacts,
Expand Down

0 comments on commit 65b8ef6

Please sign in to comment.