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

fix: add back some logging for ui #176

Merged
merged 8 commits into from
Jul 22, 2024
Merged
Changes from 2 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
32 changes: 20 additions & 12 deletions vision_agent/agent/vision_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ def write_plans(
tool_desc: str,
working_memory: str,
model: LMM,
test_multi_plan: bool,
) -> Dict[str, Any]:
chat = copy.deepcopy(chat)
if chat[-1]["role"] != "user":
Expand Down Expand Up @@ -491,15 +492,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 @@ -524,7 +518,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 @@ -692,16 +686,30 @@ def chat_with_workflow(
self.planner,
)

if not test_multi_plan:
self.log_progress(
{
"type": "plans",
"status": "completed",
"payload": plans[list(plans.keys())[0]],
}
)
self.log_progress(
{
"type": "tools",
"status": "started",
}
)

if self.verbosity >= 1 and test_multi_plan:
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(
tool_infos, tool_lists = retrieve_tools(
plans,
self.tool_recommender,
self.log_progress,
self.verbosity,
)

Expand Down Expand Up @@ -732,9 +740,9 @@ def chat_with_workflow(

self.log_progress(
{
"type": "plans",
"type": "tools",
"status": "completed",
"payload": plan_i,
"payload": tool_lists[best_plan],
}
)
if self.verbosity >= 1:
Expand Down
Loading