Skip to content

Commit

Permalink
fix: Fix debugging log + remove final_code (try 2) (#185)
Browse files Browse the repository at this point in the history
  • Loading branch information
MingruiZhang authored Jul 30, 2024
1 parent 5399f4f commit afcafea
Showing 1 changed file with 15 additions and 19 deletions.
34 changes: 15 additions & 19 deletions vision_agent/agent/vision_agent_coder.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ def write_and_test_code(
"code": DefaultImports.prepend_imports(code),
"payload": {
"test": test,
"result": result.to_json(),
# "result": result.to_json(),
},
}
)
Expand Down Expand Up @@ -426,7 +426,8 @@ def debug_code(
) -> tuple[str, str, Execution]:
log_progress(
{
"type": "code",
"type": "log",
"log_content": ("Debugging code"),
"status": "started",
}
)
Expand Down Expand Up @@ -469,10 +470,11 @@ def debug_code(
)
log_progress(
{
"type": "code",
"type": "log",
"log_content": ("Running code"),
"status": "running",
"code": DefaultImports.prepend_imports(code),
"payload": {
"code": DefaultImports.prepend_imports(code),
"test": test,
},
}
Expand All @@ -483,12 +485,15 @@ def debug_code(
)
log_progress(
{
"type": "code",
"type": "log",
"log_content": (
"Code execution succeed" if result.success else "Code execution failed"
),
"status": "completed" if result.success else "failed",
"code": DefaultImports.prepend_imports(code),
"payload": {
"code": DefaultImports.prepend_imports(code),
"test": test,
"result": result.to_json(),
# "result": result.to_json(),
},
}
)
Expand Down Expand Up @@ -525,7 +530,8 @@ def retrieve_tools(
) -> Dict[str, str]:
log_progress(
{
"type": "tools",
"type": "log",
"log_content": ("Retrieving tools for each plan"),
"status": "started",
}
)
Expand Down Expand Up @@ -802,17 +808,6 @@ def chat_with_workflow(
plan.append({"code": code, "test": test, "plan": plan_i})

execution_result = cast(Execution, results["test_result"])
self.log_progress(
{
"type": "final_code",
"status": "completed" if success else "failed",
"payload": {
"code": DefaultImports.prepend_imports(code),
"test": test,
"result": execution_result.to_json(),
},
}
)

if display_visualization:
for res in execution_result.results:
Expand All @@ -822,6 +817,7 @@ def chat_with_workflow(
play_video(res.mp4)

return {
"status": "completed" if success else "failed",
"code": DefaultImports.prepend_imports(code),
"test": test,
"test_result": execution_result,
Expand Down

0 comments on commit afcafea

Please sign in to comment.