Skip to content

Commit

Permalink
fix format
Browse files Browse the repository at this point in the history
  • Loading branch information
wuyiqunLu committed May 23, 2024
1 parent fd72e6e commit ee62b54
Showing 1 changed file with 38 additions and 27 deletions.
65 changes: 38 additions & 27 deletions vision_agent/agent/vision_agent_v3.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ def format_memory(memory: List[Dict[str, str]]) -> str:
return FEEDBACK.format(
feedback="\n".join(
[
f"### Feedback {i}:\nCode: ```python\n{
m['code']}\n```\nFeedback: {m['feedback']}\n"
f"### Feedback {i}:\nCode: ```python\n{m['code']}\n```\nFeedback: {m['feedback']}\n"
for i, m in enumerate(memory)
]
)
Expand Down Expand Up @@ -142,10 +141,12 @@ def write_and_test_code(
_CONSOLE.print(
Syntax(f"{code}\n{test}", "python", theme="gruvbox-dark", line_numbers=True)
)
log_progress({
"log": "First result:",
"result": result,
})
log_progress(
{
"log": "First result:",
"result": result,
}
)
_LOGGER.info(f"First result: {result}")

count = 0
Expand All @@ -168,10 +169,12 @@ def write_and_test_code(

success, result = _EXECUTE.run_isolation(f"{code}\n{test}")
if verbosity == 2:
log_progress({
"log": f"Debug attempt {count + 1}, reflection:",
"reflection": fixed_code_and_test['reflections'],
})
log_progress(
{
"log": f"Debug attempt {count + 1}, reflection:",
"reflection": fixed_code_and_test['reflections'],
}
)
_LOGGER.info(
f"Debug attempt {
count + 1}, reflection: {fixed_code_and_test['reflections']}"
Expand All @@ -181,10 +184,12 @@ def write_and_test_code(
f"{code}\n{test}", "python", theme="gruvbox-dark", line_numbers=True
)
)
log_progress({
"log": "Debug result:",
"result": result,
})
log_progress(
{
"log": "Debug result:",
"result": result,
}
)
_LOGGER.info(f"Debug result: {result}")
count += 1

Expand All @@ -206,7 +211,7 @@ def retrieve_tools(
plan: List[Dict[str, str]],
tool_recommender: Sim,
log_progress: Callable[[Dict[str, str]], None],
verbosity: int = 0
verbosity: int = 0,
) -> str:
tool_info = []
tool_desc = []
Expand All @@ -215,10 +220,12 @@ def retrieve_tools(
tool_info.extend([e["doc"] for e in tools])
tool_desc.extend([e["desc"] for e in tools])
if verbosity == 2:
log_progress({
"log": "Retrieved tools:",
"tools": tool_desc,
})
log_progress(
{
"log": "Retrieved tools:",
"tools": tool_desc,
}
)
_LOGGER.info(f"Tools: {tool_desc}")
tool_info_set = set(tool_info)
return "\n\n".join(tool_info_set)
Expand Down Expand Up @@ -291,10 +298,12 @@ def chat_with_workflow(
)
plan_i_str = "\n-".join([e["instructions"] for e in plan_i])
if self.verbosity == 1 or self.verbosity == 2:
self.log_progress({
"log": "Going to run the following plan(s) in sequence:\n",
"plan": plan_i,
})
self.log_progress(
{
"log": "Going to run the following plan(s) in sequence:\n",
"plan": plan_i,
}
)
_LOGGER.info(
f"""
{tabulate(tabular_data=plan_i, headers="keys", tablefmt="mixed_grid", maxcolwidths=_MAX_TABULATE_COL_WIDTH)}"""
Expand Down Expand Up @@ -330,10 +339,12 @@ def chat_with_workflow(
success = cast(bool, reflection["success"])
working_memory.append({"code": f"{code}\n{test}", "feedback": feedback})

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

return {
"code": code,
Expand Down

0 comments on commit ee62b54

Please sign in to comment.