vision-agent 0.2.33__py3-none-any.whl → 0.2.35__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.
- vision_agent/agent/vision_agent.py +105 -50
- {vision_agent-0.2.33.dist-info → vision_agent-0.2.35.dist-info}/METADATA +1 -1
- {vision_agent-0.2.33.dist-info → vision_agent-0.2.35.dist-info}/RECORD +5 -5
- {vision_agent-0.2.33.dist-info → vision_agent-0.2.35.dist-info}/LICENSE +0 -0
- {vision_agent-0.2.33.dist-info → vision_agent-0.2.35.dist-info}/WHEEL +0 -0
@@ -126,6 +126,12 @@ def write_and_test_code(
|
|
126
126
|
max_retries: int = 3,
|
127
127
|
input_media: Optional[Union[str, Path]] = None,
|
128
128
|
) -> Dict[str, Any]:
|
129
|
+
log_progress(
|
130
|
+
{
|
131
|
+
"type": "code",
|
132
|
+
"status": "started",
|
133
|
+
}
|
134
|
+
)
|
129
135
|
code = extract_code(
|
130
136
|
coder(CODE.format(docstring=tool_info, question=task, feedback=working_memory))
|
131
137
|
)
|
@@ -141,35 +147,44 @@ def write_and_test_code(
|
|
141
147
|
)
|
142
148
|
)
|
143
149
|
|
150
|
+
log_progress(
|
151
|
+
{
|
152
|
+
"type": "code",
|
153
|
+
"status": "running",
|
154
|
+
"payload": {
|
155
|
+
"code": code,
|
156
|
+
"test": test,
|
157
|
+
},
|
158
|
+
}
|
159
|
+
)
|
144
160
|
success, result = _EXECUTE.run_isolation(f"{_DEFAULT_IMPORT}\n{code}\n{test}")
|
161
|
+
log_progress(
|
162
|
+
{
|
163
|
+
"type": "code",
|
164
|
+
"status": "completed" if success else "failed",
|
165
|
+
"payload": {
|
166
|
+
"code": code,
|
167
|
+
"test": test,
|
168
|
+
"result": result,
|
169
|
+
},
|
170
|
+
}
|
171
|
+
)
|
145
172
|
if verbosity == 2:
|
146
173
|
_LOGGER.info("Initial code and tests:")
|
147
|
-
log_progress(
|
148
|
-
{
|
149
|
-
"log": "Code:",
|
150
|
-
"code": code,
|
151
|
-
}
|
152
|
-
)
|
153
|
-
log_progress(
|
154
|
-
{
|
155
|
-
"log": "Test:",
|
156
|
-
"code": test,
|
157
|
-
}
|
158
|
-
)
|
159
174
|
_CONSOLE.print(
|
160
175
|
Syntax(f"{code}\n{test}", "python", theme="gruvbox-dark", line_numbers=True)
|
161
176
|
)
|
162
|
-
log_progress(
|
163
|
-
{
|
164
|
-
"log": "Result:",
|
165
|
-
"result": result,
|
166
|
-
}
|
167
|
-
)
|
168
177
|
_LOGGER.info(f"Initial result: {result}")
|
169
178
|
|
170
179
|
count = 0
|
171
180
|
new_working_memory = []
|
172
181
|
while not success and count < max_retries:
|
182
|
+
log_progress(
|
183
|
+
{
|
184
|
+
"type": "code",
|
185
|
+
"status": "started",
|
186
|
+
}
|
187
|
+
)
|
173
188
|
fixed_code_and_test = extract_json(
|
174
189
|
debugger(
|
175
190
|
FIX_BUG.format(
|
@@ -181,18 +196,33 @@ def write_and_test_code(
|
|
181
196
|
code = extract_code(fixed_code_and_test["code"])
|
182
197
|
if fixed_code_and_test["test"].strip() != "":
|
183
198
|
test = extract_code(fixed_code_and_test["test"])
|
199
|
+
log_progress(
|
200
|
+
{
|
201
|
+
"type": "code",
|
202
|
+
"status": "running",
|
203
|
+
"payload": {
|
204
|
+
"code": code,
|
205
|
+
"test": test,
|
206
|
+
},
|
207
|
+
}
|
208
|
+
)
|
184
209
|
new_working_memory.append(
|
185
210
|
{"code": f"{code}\n{test}", "feedback": fixed_code_and_test["reflections"]}
|
186
211
|
)
|
187
212
|
|
188
213
|
success, result = _EXECUTE.run_isolation(f"{_DEFAULT_IMPORT}\n{code}\n{test}")
|
214
|
+
log_progress(
|
215
|
+
{
|
216
|
+
"type": "code",
|
217
|
+
"status": "completed" if success else "failed",
|
218
|
+
"payload": {
|
219
|
+
"code": code,
|
220
|
+
"test": test,
|
221
|
+
"result": result,
|
222
|
+
},
|
223
|
+
}
|
224
|
+
)
|
189
225
|
if verbosity == 2:
|
190
|
-
log_progress(
|
191
|
-
{
|
192
|
-
"log": f"Debug attempt {count + 1}, reflection:",
|
193
|
-
"result": fixed_code_and_test["reflections"],
|
194
|
-
}
|
195
|
-
)
|
196
226
|
_LOGGER.info(
|
197
227
|
f"Debug attempt {count + 1}, reflection: {fixed_code_and_test['reflections']}"
|
198
228
|
)
|
@@ -201,12 +231,6 @@ def write_and_test_code(
|
|
201
231
|
f"{code}\n{test}", "python", theme="gruvbox-dark", line_numbers=True
|
202
232
|
)
|
203
233
|
)
|
204
|
-
log_progress(
|
205
|
-
{
|
206
|
-
"log": "Debug result:",
|
207
|
-
"result": result,
|
208
|
-
}
|
209
|
-
)
|
210
234
|
_LOGGER.info(f"Debug result: {result}")
|
211
235
|
count += 1
|
212
236
|
|
@@ -232,19 +256,30 @@ def retrieve_tools(
|
|
232
256
|
log_progress: Callable[[Dict[str, Any]], None],
|
233
257
|
verbosity: int = 0,
|
234
258
|
) -> str:
|
259
|
+
log_progress(
|
260
|
+
{
|
261
|
+
"type": "tools",
|
262
|
+
"status": "started",
|
263
|
+
}
|
264
|
+
)
|
235
265
|
tool_info = []
|
236
266
|
tool_desc = []
|
267
|
+
tool_list: List[Dict[str, str]] = []
|
237
268
|
for task in plan:
|
238
269
|
tools = tool_recommender.top_k(task["instructions"], k=2, thresh=0.3)
|
239
270
|
tool_info.extend([e["doc"] for e in tools])
|
240
271
|
tool_desc.extend([e["desc"] for e in tools])
|
241
|
-
|
242
|
-
|
243
|
-
{
|
244
|
-
"log": "Retrieved tools:",
|
245
|
-
"tools": tool_desc,
|
246
|
-
}
|
272
|
+
tool_list.extend(
|
273
|
+
{"description": e["desc"], "documentation": e["doc"]} for e in tools
|
247
274
|
)
|
275
|
+
log_progress(
|
276
|
+
{
|
277
|
+
"type": "tools",
|
278
|
+
"status": "completed",
|
279
|
+
"payload": tool_list,
|
280
|
+
}
|
281
|
+
)
|
282
|
+
if verbosity == 2:
|
248
283
|
_LOGGER.info(f"Tools: {tool_desc}")
|
249
284
|
tool_info_set = set(tool_info)
|
250
285
|
return "\n\n".join(tool_info_set)
|
@@ -372,6 +407,12 @@ class VisionAgent(Agent):
|
|
372
407
|
retries = 0
|
373
408
|
|
374
409
|
while not success and retries < self.max_retries:
|
410
|
+
self.log_progress(
|
411
|
+
{
|
412
|
+
"type": "plans",
|
413
|
+
"status": "started",
|
414
|
+
}
|
415
|
+
)
|
375
416
|
plan_i = write_plan(
|
376
417
|
chat,
|
377
418
|
T.TOOL_DESCRIPTIONS,
|
@@ -380,13 +421,15 @@ class VisionAgent(Agent):
|
|
380
421
|
media=[media] if media else None,
|
381
422
|
)
|
382
423
|
plan_i_str = "\n-".join([e["instructions"] for e in plan_i])
|
424
|
+
|
425
|
+
self.log_progress(
|
426
|
+
{
|
427
|
+
"type": "plans",
|
428
|
+
"status": "completed",
|
429
|
+
"payload": plan_i,
|
430
|
+
}
|
431
|
+
)
|
383
432
|
if self.verbosity >= 1:
|
384
|
-
self.log_progress(
|
385
|
-
{
|
386
|
-
"log": "Going to run the following plan(s) in sequence:\n",
|
387
|
-
"plan": plan_i,
|
388
|
-
}
|
389
|
-
)
|
390
433
|
|
391
434
|
_LOGGER.info(
|
392
435
|
f"""
|
@@ -418,6 +461,12 @@ class VisionAgent(Agent):
|
|
418
461
|
plan.append({"code": code, "test": test, "plan": plan_i})
|
419
462
|
|
420
463
|
if self_reflection:
|
464
|
+
self.log_progress(
|
465
|
+
{
|
466
|
+
"type": "self_reflection",
|
467
|
+
"status": "started",
|
468
|
+
}
|
469
|
+
)
|
421
470
|
reflection = reflect(
|
422
471
|
chat,
|
423
472
|
FULL_TASK.format(
|
@@ -427,23 +476,29 @@ class VisionAgent(Agent):
|
|
427
476
|
self.planner,
|
428
477
|
)
|
429
478
|
if self.verbosity > 0:
|
430
|
-
self.log_progress(
|
431
|
-
{
|
432
|
-
"log": "Reflection:",
|
433
|
-
"reflection": reflection,
|
434
|
-
}
|
435
|
-
)
|
436
479
|
_LOGGER.info(f"Reflection: {reflection}")
|
437
480
|
feedback = cast(str, reflection["feedback"])
|
438
481
|
success = cast(bool, reflection["success"])
|
482
|
+
self.log_progress(
|
483
|
+
{
|
484
|
+
"type": "self_reflection",
|
485
|
+
"status": "completed" if success else "failed",
|
486
|
+
"payload": reflection,
|
487
|
+
}
|
488
|
+
)
|
439
489
|
working_memory.append({"code": f"{code}\n{test}", "feedback": feedback})
|
440
490
|
|
441
491
|
retries += 1
|
442
492
|
|
443
493
|
self.log_progress(
|
444
494
|
{
|
445
|
-
"
|
446
|
-
"
|
495
|
+
"type": "final_code",
|
496
|
+
"status": "completed" if success else "failed",
|
497
|
+
"payload": {
|
498
|
+
"code": code,
|
499
|
+
"test": test,
|
500
|
+
"result": results["test_result"],
|
501
|
+
},
|
447
502
|
}
|
448
503
|
)
|
449
504
|
|
@@ -11,7 +11,7 @@ vision_agent/agent/easytool_v2.py,sha256=CjY-sSj3abxnSq3ZHZMt-7YvRWDXEZsC6RN8FFI
|
|
11
11
|
vision_agent/agent/easytool_v2_prompts.py,sha256=MZSIwovYgB-f-kdJ6btaNDVXptJn47bfOL3-Zn6NiC0,8573
|
12
12
|
vision_agent/agent/reflexion.py,sha256=AlM5AvBJvCslXlYQdZiadq4oVHsNBm3IF_03DglTxRo,10506
|
13
13
|
vision_agent/agent/reflexion_prompts.py,sha256=G7UAeNz_g2qCb2yN6OaIC7bQVUkda4m3z42EG8wAyfE,9342
|
14
|
-
vision_agent/agent/vision_agent.py,sha256=
|
14
|
+
vision_agent/agent/vision_agent.py,sha256=WMClrV5qhPyqnQscNgek2vVes6-A1jNwaHH0vzgy6Zk,16802
|
15
15
|
vision_agent/agent/vision_agent_prompts.py,sha256=0YbiS59IEWbiE43gCvOqfWrpudIAhTn8FHzXW0Y-Gaw,8201
|
16
16
|
vision_agent/fonts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
17
17
|
vision_agent/fonts/default_font_ch_en.ttf,sha256=1YM0Z3XqLDjSNbF7ihQFSAIUdjF9m1rtHiNC_6QosTE,1594400
|
@@ -30,7 +30,7 @@ vision_agent/utils/image_utils.py,sha256=_cdiS5YrLzqkq_ZgFUO897m5M4_SCIThwUy4lOk
|
|
30
30
|
vision_agent/utils/sim.py,sha256=oUZ-6eu8Io-UNt9GXJ0XRKtP-Wc0sPWVzYGVpB2yDFk,3001
|
31
31
|
vision_agent/utils/type_defs.py,sha256=BlI8ywWHAplC7kYWLvt4AOdnKpEW3qWEFm-GEOSkrFQ,1792
|
32
32
|
vision_agent/utils/video.py,sha256=xTElFSFp1Jw4ulOMnk81Vxsh-9dTxcWUO6P9fzEi3AM,7653
|
33
|
-
vision_agent-0.2.
|
34
|
-
vision_agent-0.2.
|
35
|
-
vision_agent-0.2.
|
36
|
-
vision_agent-0.2.
|
33
|
+
vision_agent-0.2.35.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
34
|
+
vision_agent-0.2.35.dist-info/METADATA,sha256=JX3Ic7LcwZvEApeSWwqX5u9urklsTLFsEAd8Disoxe0,6698
|
35
|
+
vision_agent-0.2.35.dist-info/WHEEL,sha256=7Z8_27uaHI_UZAc4Uox4PpBhQ9Y5_modZXWMxtUi4NU,88
|
36
|
+
vision_agent-0.2.35.dist-info/RECORD,,
|
File without changes
|
File without changes
|