vision-agent 0.0.31__py3-none-any.whl → 0.0.32__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -49,6 +49,33 @@ def format_tools(tools: Dict[int, Any]) -> str:
49
49
  return tool_str
50
50
 
51
51
 
52
+ def topological_sort(tasks: List[Dict]) -> List[Dict]:
53
+ in_degree = {task["id"]: 0 for task in tasks}
54
+ for task in tasks:
55
+ for dep in task["dep"]:
56
+ if dep in in_degree:
57
+ in_degree[task["id"]] += 1
58
+
59
+ queue = [task for task in tasks if in_degree[task["id"]] == 0]
60
+ sorted_order = []
61
+
62
+ while queue:
63
+ current = queue.pop(0)
64
+ sorted_order.append(current)
65
+
66
+ for task in tasks:
67
+ if current["id"] in task["dep"]:
68
+ in_degree[task["id"]] -= 1
69
+ if in_degree[task["id"]] == 0:
70
+ queue.append(task)
71
+
72
+ if len(sorted_order) != len(tasks):
73
+ completed_ids = set([task["id"] for task in sorted_order])
74
+ remaining_tasks = [task for task in tasks if task["id"] not in completed_ids]
75
+ sorted_order.extend(remaining_tasks)
76
+ return sorted_order
77
+
78
+
52
79
  def task_decompose(
53
80
  model: Union[LLM, LMM, Agent], question: str, tools: Dict[int, Any]
54
81
  ) -> Optional[Dict]:
@@ -265,6 +292,10 @@ class EasyTool(Agent):
265
292
  if tasks is not None:
266
293
  task_list = [{"task": task, "id": i + 1} for i, task in enumerate(tasks)]
267
294
  task_list = task_topology(self.task_model, question, task_list)
295
+ try:
296
+ task_list = topological_sort(task_list)
297
+ except Exception:
298
+ _LOGGER.error(f"Failed topological_sort on: {task_list}")
268
299
  else:
269
300
  task_list = []
270
301
 
@@ -274,7 +305,6 @@ class EasyTool(Agent):
274
305
  answers = []
275
306
  for task in task_list:
276
307
  task_depend[task["id"]] = {"task": task["task"], "answer": ""} # type: ignore
277
- # TODO topological sort task_list
278
308
  all_tool_results = []
279
309
  for task in task_list:
280
310
  task_str = task["task"]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: vision-agent
3
- Version: 0.0.31
3
+ Version: 0.0.32
4
4
  Summary: Toolset for Vision Agent
5
5
  Author: Landing AI
6
6
  Author-email: dev@landing.ai
@@ -1,7 +1,7 @@
1
1
  vision_agent/__init__.py,sha256=wD1cssVTAJ55uTViNfBGooqJUV0p9fmVAuTMHHrmUBU,229
2
2
  vision_agent/agent/__init__.py,sha256=WZrGKMglRlwy0xL77Kr7S0Lrk696gOYI5CeaiJNRmlw,89
3
3
  vision_agent/agent/agent.py,sha256=PRLItaPfMc94H6mAIPj_gBvJ8RezDEPanB6Cmu81A0M,306
4
- vision_agent/agent/easytool.py,sha256=tp0U--TjfN_pqHagl9Y_LTEqvk6iOcoEETmLNVE8Ras,10161
4
+ vision_agent/agent/easytool.py,sha256=LhilXcYnhcayALE_EVPegzNWGNMnTKH0-9QFtc7xtVg,11175
5
5
  vision_agent/agent/easytool_prompts.py,sha256=tTuWwthYVELTVH3iLaZUbtX0MJsYG5TWC7Pim844cJ4,4505
6
6
  vision_agent/agent/reflexion.py,sha256=DXxFenwlZSPUKsA4vkoZ-xcdKF4YVReEZWcMKgFdfWg,9774
7
7
  vision_agent/agent/reflexion_prompts.py,sha256=UPGkt_qgHBMUY0VPVoF-BqhR0d_6WPjjrhbYLBYOtnQ,9342
@@ -17,7 +17,7 @@ vision_agent/lmm/lmm.py,sha256=ARcbgkcyP83TbVVoXI9B-gtG0gJuTaG_MjcUGbams4U,8052
17
17
  vision_agent/tools/__init__.py,sha256=aX0pU3pXU1V0Cj9FzYCvdsX76TAglFMHx59kNhXHbPs,131
18
18
  vision_agent/tools/prompts.py,sha256=9RBbyqlNlExsGKlJ89Jkph83DAEJ8PCVGaHoNbyN7TM,1416
19
19
  vision_agent/tools/tools.py,sha256=ZCak2hERXBR3SAy5zLe165PIoQQX_TykvO9ve8ZXvYY,15140
20
- vision_agent-0.0.31.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
21
- vision_agent-0.0.31.dist-info/METADATA,sha256=YNf_AG8E1Ryb6lPtua8-EwFsa-LY3ESQSNtlenKQ9UY,4384
22
- vision_agent-0.0.31.dist-info/WHEEL,sha256=7Z8_27uaHI_UZAc4Uox4PpBhQ9Y5_modZXWMxtUi4NU,88
23
- vision_agent-0.0.31.dist-info/RECORD,,
20
+ vision_agent-0.0.32.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
21
+ vision_agent-0.0.32.dist-info/METADATA,sha256=oQdX4D0FzapLeEyRQF_-YmSxgDYrdITkVTI89KSlJu0,4384
22
+ vision_agent-0.0.32.dist-info/WHEEL,sha256=7Z8_27uaHI_UZAc4Uox4PpBhQ9Y5_modZXWMxtUi4NU,88
23
+ vision_agent-0.0.32.dist-info/RECORD,,