vision-agent 0.2.20__tar.gz → 0.2.22__tar.gz

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.
Files changed (34) hide show
  1. {vision_agent-0.2.20 → vision_agent-0.2.22}/PKG-INFO +1 -1
  2. {vision_agent-0.2.20 → vision_agent-0.2.22}/pyproject.toml +1 -1
  3. {vision_agent-0.2.20 → vision_agent-0.2.22}/vision_agent/agent/vision_agent.py +5 -3
  4. {vision_agent-0.2.20 → vision_agent-0.2.22}/vision_agent/agent/vision_agent_v2.py +34 -16
  5. {vision_agent-0.2.20 → vision_agent-0.2.22}/LICENSE +0 -0
  6. {vision_agent-0.2.20 → vision_agent-0.2.22}/README.md +0 -0
  7. {vision_agent-0.2.20 → vision_agent-0.2.22}/vision_agent/__init__.py +0 -0
  8. {vision_agent-0.2.20 → vision_agent-0.2.22}/vision_agent/agent/__init__.py +0 -0
  9. {vision_agent-0.2.20 → vision_agent-0.2.22}/vision_agent/agent/agent.py +0 -0
  10. {vision_agent-0.2.20 → vision_agent-0.2.22}/vision_agent/agent/agent_coder.py +0 -0
  11. {vision_agent-0.2.20 → vision_agent-0.2.22}/vision_agent/agent/agent_coder_prompts.py +0 -0
  12. {vision_agent-0.2.20 → vision_agent-0.2.22}/vision_agent/agent/easytool.py +0 -0
  13. {vision_agent-0.2.20 → vision_agent-0.2.22}/vision_agent/agent/easytool_prompts.py +0 -0
  14. {vision_agent-0.2.20 → vision_agent-0.2.22}/vision_agent/agent/reflexion.py +0 -0
  15. {vision_agent-0.2.20 → vision_agent-0.2.22}/vision_agent/agent/reflexion_prompts.py +0 -0
  16. {vision_agent-0.2.20 → vision_agent-0.2.22}/vision_agent/agent/vision_agent_prompts.py +0 -0
  17. {vision_agent-0.2.20 → vision_agent-0.2.22}/vision_agent/agent/vision_agent_v2_prompt.py +0 -0
  18. {vision_agent-0.2.20 → vision_agent-0.2.22}/vision_agent/fonts/__init__.py +0 -0
  19. {vision_agent-0.2.20 → vision_agent-0.2.22}/vision_agent/fonts/default_font_ch_en.ttf +0 -0
  20. {vision_agent-0.2.20 → vision_agent-0.2.22}/vision_agent/llm/__init__.py +0 -0
  21. {vision_agent-0.2.20 → vision_agent-0.2.22}/vision_agent/llm/llm.py +0 -0
  22. {vision_agent-0.2.20 → vision_agent-0.2.22}/vision_agent/lmm/__init__.py +0 -0
  23. {vision_agent-0.2.20 → vision_agent-0.2.22}/vision_agent/lmm/lmm.py +0 -0
  24. {vision_agent-0.2.20 → vision_agent-0.2.22}/vision_agent/tools/__init__.py +0 -0
  25. {vision_agent-0.2.20 → vision_agent-0.2.22}/vision_agent/tools/prompts.py +0 -0
  26. {vision_agent-0.2.20 → vision_agent-0.2.22}/vision_agent/tools/tool_utils.py +0 -0
  27. {vision_agent-0.2.20 → vision_agent-0.2.22}/vision_agent/tools/tools.py +0 -0
  28. {vision_agent-0.2.20 → vision_agent-0.2.22}/vision_agent/tools/tools_v2.py +0 -0
  29. {vision_agent-0.2.20 → vision_agent-0.2.22}/vision_agent/utils/__init__.py +0 -0
  30. {vision_agent-0.2.20 → vision_agent-0.2.22}/vision_agent/utils/execute.py +0 -0
  31. {vision_agent-0.2.20 → vision_agent-0.2.22}/vision_agent/utils/image_utils.py +0 -0
  32. {vision_agent-0.2.20 → vision_agent-0.2.22}/vision_agent/utils/sim.py +0 -0
  33. {vision_agent-0.2.20 → vision_agent-0.2.22}/vision_agent/utils/type_defs.py +0 -0
  34. {vision_agent-0.2.20 → vision_agent-0.2.22}/vision_agent/utils/video.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: vision-agent
3
- Version: 0.2.20
3
+ Version: 0.2.22
4
4
  Summary: Toolset for Vision Agent
5
5
  Author: Landing AI
6
6
  Author-email: dev@landing.ai
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
4
4
 
5
5
  [tool.poetry]
6
6
  name = "vision-agent"
7
- version = "0.2.20"
7
+ version = "0.2.22"
8
8
  description = "Toolset for Vision Agent"
9
9
  authors = ["Landing AI <dev@landing.ai>"]
10
10
  readme = "README.md"
@@ -464,15 +464,17 @@ class VisionAgent(Agent):
464
464
  report_progress_callback: a callback to report the progress of the agent. This is useful for streaming logs in a web application where multiple VisionAgent instances are running in parallel. This callback ensures that the progress are not mixed up.
465
465
  """
466
466
  self.task_model = (
467
- OpenAILLM(json_mode=True, temperature=0.1)
467
+ OpenAILLM(model_name="gpt-4-turbo", json_mode=True, temperature=0.0)
468
468
  if task_model is None
469
469
  else task_model
470
470
  )
471
471
  self.answer_model = (
472
- OpenAILLM(temperature=0.1) if answer_model is None else answer_model
472
+ OpenAILLM(model_name="gpt-4-turbo", temperature=0.0)
473
+ if answer_model is None
474
+ else answer_model
473
475
  )
474
476
  self.reflect_model = (
475
- OpenAILMM(json_mode=True, temperature=0.1)
477
+ OpenAILMM(model_name="gpt-4-turbo", json_mode=True, temperature=0.0)
476
478
  if reflect_model is None
477
479
  else reflect_model
478
480
  )
@@ -51,6 +51,21 @@ def extract_code(code: str) -> str:
51
51
  return code
52
52
 
53
53
 
54
+ def extract_json(json_str: str) -> Dict[str, Any]:
55
+ try:
56
+ json_dict = json.loads(json_str)
57
+ except json.JSONDecodeError:
58
+ if "```json" in json_str:
59
+ json_str = json_str[json_str.find("```json") + len("```json") :]
60
+ json_str = json_str[: json_str.find("```")]
61
+ elif "```" in json_str:
62
+ json_str = json_str[json_str.find("```") + len("```") :]
63
+ # get the last ``` not one from an intermediate string
64
+ json_str = json_str[: json_str.find("}```")]
65
+ json_dict = json.loads(json_str)
66
+ return json_dict # type: ignore
67
+
68
+
54
69
  def write_plan(
55
70
  chat: List[Dict[str, str]],
56
71
  plan: Optional[List[Dict[str, Any]]],
@@ -65,8 +80,8 @@ def write_plan(
65
80
  context = USER_REQ_CONTEXT.format(user_requirement=user_requirements)
66
81
  prompt = PLAN.format(context=context, plan=str(plan), tool_desc=tool_desc)
67
82
  chat[-1]["content"] = prompt
68
- plan = json.loads(model.chat(chat).replace("```", "").strip())
69
- return plan["user_req"], plan["plan"] # type: ignore
83
+ new_plan = extract_json(model.chat(chat))
84
+ return new_plan["user_req"], new_plan["plan"]
70
85
 
71
86
 
72
87
  def write_code(
@@ -133,7 +148,7 @@ def debug_code(
133
148
  {"role": "system", "content": DEBUG_SYS_MSG},
134
149
  {"role": "user", "content": prompt},
135
150
  ]
136
- code_and_ref = json.loads(model.chat(messages).replace("```", "").strip())
151
+ code_and_ref = extract_json(model.chat(messages))
137
152
  if hasattr(model, "kwargs"):
138
153
  del model.kwargs["response_format"]
139
154
  return extract_code(code_and_ref["improved_impl"]), code_and_ref["reflection"]
@@ -149,7 +164,7 @@ def write_and_exec_code(
149
164
  exec: Execute,
150
165
  retrieved_ltm: str,
151
166
  max_retry: int = 3,
152
- verbose: bool = False,
167
+ verbosity: int = 0,
153
168
  ) -> Tuple[bool, str, str, Dict[str, List[str]]]:
154
169
  success = False
155
170
  counter = 0
@@ -159,6 +174,9 @@ def write_and_exec_code(
159
174
  user_req, subtask, retrieved_ltm, tool_info, orig_code, model
160
175
  )
161
176
  success, result = exec.run_isolation(code)
177
+ if verbosity == 2:
178
+ _CONSOLE.print(Syntax(code, "python", theme="gruvbox-dark", line_numbers=True))
179
+ _LOGGER.info(f"\tCode success: {success}, result: {str(result)}")
162
180
  working_memory: Dict[str, List[str]] = {}
163
181
  while not success and counter < max_retry:
164
182
  if subtask not in working_memory:
@@ -180,11 +198,11 @@ def write_and_exec_code(
180
198
  )
181
199
  success, result = exec.run_isolation(code)
182
200
  counter += 1
183
- if verbose:
201
+ if verbosity == 2:
184
202
  _CONSOLE.print(
185
203
  Syntax(code, "python", theme="gruvbox-dark", line_numbers=True)
186
204
  )
187
- _LOGGER.info(f"\tDebugging reflection, result: {reflection}, {result}")
205
+ _LOGGER.info(f"\tDebugging reflection: {reflection}, result: {result}")
188
206
 
189
207
  if success:
190
208
  working_memory[subtask].append(
@@ -204,7 +222,7 @@ def run_plan(
204
222
  code: str,
205
223
  tool_recommender: Sim,
206
224
  long_term_memory: Optional[Sim] = None,
207
- verbose: bool = False,
225
+ verbosity: int = 0,
208
226
  ) -> Tuple[str, str, List[Dict[str, Any]], Dict[str, List[str]]]:
209
227
  active_plan = [e for e in plan if "success" not in e or not e["success"]]
210
228
  current_code = code
@@ -235,7 +253,7 @@ def run_plan(
235
253
  tool_info,
236
254
  exec,
237
255
  retrieved_ltm,
238
- verbose=verbose,
256
+ verbosity=verbosity,
239
257
  )
240
258
  if task["type"] == "code":
241
259
  current_code = code
@@ -244,11 +262,11 @@ def run_plan(
244
262
 
245
263
  working_memory.update(working_memory_i)
246
264
 
247
- if verbose:
265
+ if verbosity == 1:
248
266
  _CONSOLE.print(
249
267
  Syntax(code, "python", theme="gruvbox-dark", line_numbers=True)
250
268
  )
251
- _LOGGER.info(f"\tCode success, result: {success}, {str(result)}")
269
+ _LOGGER.info(f"\tCode success: {success} result: {str(result)}")
252
270
 
253
271
  task["success"] = success
254
272
  task["result"] = result
@@ -283,23 +301,23 @@ class VisionAgentV2(Agent):
283
301
  timeout: int = 600,
284
302
  tool_recommender: Optional[Sim] = None,
285
303
  long_term_memory: Optional[Sim] = None,
286
- verbose: bool = False,
304
+ verbosity: int = 0,
287
305
  ) -> None:
288
- self.planner = OpenAILLM(temperature=0.1, json_mode=True)
289
- self.coder = OpenAILLM(temperature=0.1)
306
+ self.planner = OpenAILLM(temperature=0.0, json_mode=True)
307
+ self.coder = OpenAILLM(temperature=0.0)
290
308
  self.exec = Execute(timeout=timeout)
291
309
  if tool_recommender is None:
292
310
  self.tool_recommender = Sim(TOOLS_DF, sim_key="desc")
293
311
  else:
294
312
  self.tool_recommender = tool_recommender
295
- self.verbose = verbose
313
+ self.verbosity = verbosity
296
314
  self._working_memory: Dict[str, List[str]] = {}
297
315
  if long_term_memory is not None:
298
316
  if "doc" not in long_term_memory.df.columns:
299
317
  raise ValueError("Long term memory must have a 'doc' column.")
300
318
  self.long_term_memory = long_term_memory
301
319
  self.max_retries = 3
302
- if self.verbose:
320
+ if self.verbosity:
303
321
  _LOGGER.setLevel(logging.INFO)
304
322
 
305
323
  def __call__(
@@ -355,7 +373,7 @@ class VisionAgentV2(Agent):
355
373
  working_code,
356
374
  self.tool_recommender,
357
375
  self.long_term_memory,
358
- self.verbose,
376
+ self.verbosity,
359
377
  )
360
378
  success = all(task["success"] for task in plan)
361
379
  working_memory.update(working_memory_i)
File without changes
File without changes