Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add log for debug code and test #95

Merged
merged 7 commits into from
May 30, 2024
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 32 additions & 29 deletions vision_agent/agent/vision_agent_v3.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,29 +140,23 @@ def write_and_test_code(
_LOGGER.info("Initial code and tests:")
log_progress(
{
"log": "Code:",
"code": code,
}
)
log_progress(
{
"log": "Test:",
"code": test,
"type": "initial_attempt",
"payload": {
"code": code,
"test": test,
"result": result,
"success": success,
},
}
)
_CONSOLE.print(
Syntax(f"{code}\n{test}", "python", theme="gruvbox-dark", line_numbers=True)
)
log_progress(
{
"log": "Result:",
"result": result,
}
)
_LOGGER.info(f"Initial result: {result}")

count = 0
new_working_memory = []

while not success and count < max_retries:
fixed_code_and_test = extract_json(
debugger(
Expand All @@ -183,8 +177,15 @@ def write_and_test_code(
if verbosity == 2:
log_progress(
{
"log": f"Debug attempt {count + 1}, reflection:",
"result": fixed_code_and_test["reflections"],
"type": "debug_attempt",
"payload": {
"count": count + 1,
"code": code,
"test": test,
"result": result,
"success": success,
"reflection": fixed_code_and_test["reflections"],
},
}
)
_LOGGER.info(
Expand All @@ -195,12 +196,6 @@ def write_and_test_code(
f"{code}\n{test}", "python", theme="gruvbox-dark", line_numbers=True
)
)
log_progress(
{
"log": "Debug result:",
"result": result,
}
)
_LOGGER.info(f"Debug result: {result}")
count += 1

Expand All @@ -209,6 +204,15 @@ def write_and_test_code(
_CONSOLE.print(
Syntax(f"{code}\n{test}", "python", theme="gruvbox-dark", line_numbers=True)
)
log_progress(
{
"type": "final_result",
"payload": {
"success": success,
"reach_max_retries": count == max_retries,
},
}
)
_LOGGER.info(f"Final Result: {result}")

return {
Expand All @@ -235,8 +239,8 @@ def retrieve_tools(
if verbosity == 2:
log_progress(
{
"log": "Retrieved tools:",
"tools": tool_desc,
"type": "tools",
"payload": tool_desc,
}
)
_LOGGER.info(f"Tools: {tool_desc}")
Expand Down Expand Up @@ -316,8 +320,8 @@ def chat_with_workflow(
if self.verbosity >= 1:
self.log_progress(
{
"log": "Going to run the following plan(s) in sequence:\n",
"plan": plan_i,
"type": "plans",
"payload": plan_i,
}
)

Expand Down Expand Up @@ -362,7 +366,7 @@ def chat_with_workflow(
if self.verbosity > 0:
self.log_progress(
{
"log": "Reflection:",
"type": "final_reflection",
"reflection": reflection,
}
)
Expand All @@ -375,8 +379,7 @@ def chat_with_workflow(

self.log_progress(
{
"log": f"The Vision Agent V3 has concluded this chat.\nSuccess: {success}",
"finished": True,
"type": "agent_conclusion",
}
)

Expand Down
Loading