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 logs for picking plans #173

Closed
wants to merge 1 commit into from
Closed
Changes from all 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
52 changes: 38 additions & 14 deletions vision_agent/agent/vision_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ def pick_plan(

if verbosity == 2:
_print_code("Code and test after attempted fix:", code)
_LOGGER.info(f"Code execution result after attempte {count}")
_LOGGER.info(f"Code execution result after attempt {count}")

count += 1

Expand Down Expand Up @@ -491,15 +491,8 @@ def _print_code(title: str, code: str, test: Optional[str] = None) -> None:
def retrieve_tools(
plans: Dict[str, List[Dict[str, str]]],
tool_recommender: Sim,
log_progress: Callable[[Dict[str, Any]], None],
verbosity: int = 0,
) -> Dict[str, str]:
log_progress(
{
"type": "tools",
"status": "started",
}
)
tool_info = []
tool_desc = []
tool_lists: Dict[str, List[Dict[str, str]]] = {}
Expand All @@ -510,7 +503,12 @@ def retrieve_tools(
tool_info.extend([e["doc"] for e in tools])
tool_desc.extend([e["desc"] for e in tools])
tool_lists[k].extend(
{"description": e["desc"], "documentation": e["doc"]} for e in tools
{
"plan": task["instructions"] if index == 0 else "",
"tool": e["desc"].strip().split()[0],
"documentation": e["doc"],
}
for index, e in enumerate(tools)
)

if verbosity == 2:
Expand All @@ -524,7 +522,7 @@ def retrieve_tools(
)
all_tools = "\n\n".join(set(tool_info))
tool_lists_unique["all"] = all_tools
return tool_lists_unique
return tool_lists_unique, tool_lists


class VisionAgent(Agent):
Expand Down Expand Up @@ -691,16 +689,40 @@ def chat_with_workflow(
self.planner,
)

unique_instructions_set = set()
unique_instructions = []

for plan in plans.values():
for item in plan:
instruction = item["instructions"]
if instruction not in unique_instructions_set:
unique_instructions_set.add(instruction)
unique_instructions.append(item)

self.log_progress(
{
"type": "plans",
"status": "completed",
"payload": unique_instructions,
}
)

if self.verbosity >= 1:
for p in plans:
_LOGGER.info(
f"\n{tabulate(tabular_data=plans[p], headers='keys', tablefmt='mixed_grid', maxcolwidths=_MAX_TABULATE_COL_WIDTH)}"
)

tool_infos = retrieve_tools(
self.log_progress(
{
"type": "pick_plans",
"status": "started",
}
)

tool_infos, tool_lists = retrieve_tools(
plans,
self.tool_recommender,
self.log_progress,
self.verbosity,
)
best_plan, tool_output_str = pick_plan(
Expand All @@ -715,6 +737,7 @@ def chat_with_workflow(
if best_plan in plans and best_plan in tool_infos:
plan_i = plans[best_plan]
tool_info = tool_infos[best_plan]
tool_list = tool_lists[best_plan]
else:
if self.verbosity >= 1:
_LOGGER.warning(
Expand All @@ -723,12 +746,13 @@ def chat_with_workflow(
k = list(plans.keys())[0]
plan_i = plans[k]
tool_info = tool_infos[k]
tool_list = tool_lists[k]

self.log_progress(
{
"type": "plans",
"type": "pick_plans",
"status": "completed",
"payload": plan_i,
"payload": tool_list,
}
)
if self.verbosity >= 1:
Expand Down
Loading