vision-agent 0.2.33__py3-none-any.whl → 0.2.34__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 +101 -50
- {vision_agent-0.2.33.dist-info → vision_agent-0.2.34.dist-info}/METADATA +1 -1
- {vision_agent-0.2.33.dist-info → vision_agent-0.2.34.dist-info}/RECORD +5 -5
- {vision_agent-0.2.33.dist-info → vision_agent-0.2.34.dist-info}/LICENSE +0 -0
- {vision_agent-0.2.33.dist-info → vision_agent-0.2.34.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,26 @@ 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 = []
|
237
267
|
for task in plan:
|
238
268
|
tools = tool_recommender.top_k(task["instructions"], k=2, thresh=0.3)
|
239
269
|
tool_info.extend([e["doc"] for e in tools])
|
240
270
|
tool_desc.extend([e["desc"] for e in tools])
|
271
|
+
log_progress(
|
272
|
+
{
|
273
|
+
"type": "tools",
|
274
|
+
"status": "completed",
|
275
|
+
"payload": tools,
|
276
|
+
}
|
277
|
+
)
|
241
278
|
if verbosity == 2:
|
242
|
-
log_progress(
|
243
|
-
{
|
244
|
-
"log": "Retrieved tools:",
|
245
|
-
"tools": tool_desc,
|
246
|
-
}
|
247
|
-
)
|
248
279
|
_LOGGER.info(f"Tools: {tool_desc}")
|
249
280
|
tool_info_set = set(tool_info)
|
250
281
|
return "\n\n".join(tool_info_set)
|
@@ -372,6 +403,12 @@ class VisionAgent(Agent):
|
|
372
403
|
retries = 0
|
373
404
|
|
374
405
|
while not success and retries < self.max_retries:
|
406
|
+
self.log_progress(
|
407
|
+
{
|
408
|
+
"type": "plans",
|
409
|
+
"status": "started",
|
410
|
+
}
|
411
|
+
)
|
375
412
|
plan_i = write_plan(
|
376
413
|
chat,
|
377
414
|
T.TOOL_DESCRIPTIONS,
|
@@ -380,13 +417,15 @@ class VisionAgent(Agent):
|
|
380
417
|
media=[media] if media else None,
|
381
418
|
)
|
382
419
|
plan_i_str = "\n-".join([e["instructions"] for e in plan_i])
|
420
|
+
|
421
|
+
self.log_progress(
|
422
|
+
{
|
423
|
+
"type": "plans",
|
424
|
+
"status": "completed",
|
425
|
+
"payload": plan_i,
|
426
|
+
}
|
427
|
+
)
|
383
428
|
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
429
|
|
391
430
|
_LOGGER.info(
|
392
431
|
f"""
|
@@ -418,6 +457,12 @@ class VisionAgent(Agent):
|
|
418
457
|
plan.append({"code": code, "test": test, "plan": plan_i})
|
419
458
|
|
420
459
|
if self_reflection:
|
460
|
+
self.log_progress(
|
461
|
+
{
|
462
|
+
"type": "self_reflection",
|
463
|
+
"status": "started",
|
464
|
+
}
|
465
|
+
)
|
421
466
|
reflection = reflect(
|
422
467
|
chat,
|
423
468
|
FULL_TASK.format(
|
@@ -427,23 +472,29 @@ class VisionAgent(Agent):
|
|
427
472
|
self.planner,
|
428
473
|
)
|
429
474
|
if self.verbosity > 0:
|
430
|
-
self.log_progress(
|
431
|
-
{
|
432
|
-
"log": "Reflection:",
|
433
|
-
"reflection": reflection,
|
434
|
-
}
|
435
|
-
)
|
436
475
|
_LOGGER.info(f"Reflection: {reflection}")
|
437
476
|
feedback = cast(str, reflection["feedback"])
|
438
477
|
success = cast(bool, reflection["success"])
|
478
|
+
self.log_progress(
|
479
|
+
{
|
480
|
+
"type": "self_reflection",
|
481
|
+
"status": "completed" if success else "failed",
|
482
|
+
"payload": reflection,
|
483
|
+
}
|
484
|
+
)
|
439
485
|
working_memory.append({"code": f"{code}\n{test}", "feedback": feedback})
|
440
486
|
|
441
487
|
retries += 1
|
442
488
|
|
443
489
|
self.log_progress(
|
444
490
|
{
|
445
|
-
"
|
446
|
-
"
|
491
|
+
"type": "final_code",
|
492
|
+
"status": "completed" if success else "failed",
|
493
|
+
"payload": {
|
494
|
+
"code": code,
|
495
|
+
"test": test,
|
496
|
+
"result": results["test_result"],
|
497
|
+
},
|
447
498
|
}
|
448
499
|
)
|
449
500
|
|
@@ -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=SAk1-UWVxdpjMbcUsx2afbgQO8VjbwfKUKdM_MUs8Ck,16640
|
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.34.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
34
|
+
vision_agent-0.2.34.dist-info/METADATA,sha256=G7TLFwGHMZmxNOCXouYlajbIwhIE4YTbyRCOOeBVpPY,6698
|
35
|
+
vision_agent-0.2.34.dist-info/WHEEL,sha256=7Z8_27uaHI_UZAc4Uox4PpBhQ9Y5_modZXWMxtUi4NU,88
|
36
|
+
vision_agent-0.2.34.dist-info/RECORD,,
|
File without changes
|
File without changes
|