vision-agent 0.2.135__tar.gz → 0.2.137__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. {vision_agent-0.2.135 → vision_agent-0.2.137}/PKG-INFO +1 -1
  2. {vision_agent-0.2.135 → vision_agent-0.2.137}/pyproject.toml +1 -1
  3. {vision_agent-0.2.135 → vision_agent-0.2.137}/vision_agent/agent/vision_agent.py +2 -21
  4. {vision_agent-0.2.135 → vision_agent-0.2.137}/vision_agent/tools/meta_tools.py +60 -8
  5. {vision_agent-0.2.135 → vision_agent-0.2.137}/vision_agent/utils/execute.py +4 -4
  6. {vision_agent-0.2.135 → vision_agent-0.2.137}/LICENSE +0 -0
  7. {vision_agent-0.2.135 → vision_agent-0.2.137}/README.md +0 -0
  8. {vision_agent-0.2.135 → vision_agent-0.2.137}/vision_agent/__init__.py +0 -0
  9. {vision_agent-0.2.135 → vision_agent-0.2.137}/vision_agent/agent/__init__.py +0 -0
  10. {vision_agent-0.2.135 → vision_agent-0.2.137}/vision_agent/agent/agent.py +0 -0
  11. {vision_agent-0.2.135 → vision_agent-0.2.137}/vision_agent/agent/agent_utils.py +0 -0
  12. {vision_agent-0.2.135 → vision_agent-0.2.137}/vision_agent/agent/vision_agent_coder.py +0 -0
  13. {vision_agent-0.2.135 → vision_agent-0.2.137}/vision_agent/agent/vision_agent_coder_prompts.py +0 -0
  14. {vision_agent-0.2.135 → vision_agent-0.2.137}/vision_agent/agent/vision_agent_prompts.py +0 -0
  15. {vision_agent-0.2.135 → vision_agent-0.2.137}/vision_agent/clients/__init__.py +0 -0
  16. {vision_agent-0.2.135 → vision_agent-0.2.137}/vision_agent/clients/http.py +0 -0
  17. {vision_agent-0.2.135 → vision_agent-0.2.137}/vision_agent/clients/landing_public_api.py +0 -0
  18. {vision_agent-0.2.135 → vision_agent-0.2.137}/vision_agent/fonts/__init__.py +0 -0
  19. {vision_agent-0.2.135 → vision_agent-0.2.137}/vision_agent/fonts/default_font_ch_en.ttf +0 -0
  20. {vision_agent-0.2.135 → vision_agent-0.2.137}/vision_agent/lmm/__init__.py +0 -0
  21. {vision_agent-0.2.135 → vision_agent-0.2.137}/vision_agent/lmm/lmm.py +0 -0
  22. {vision_agent-0.2.135 → vision_agent-0.2.137}/vision_agent/lmm/types.py +0 -0
  23. {vision_agent-0.2.135 → vision_agent-0.2.137}/vision_agent/tools/__init__.py +0 -0
  24. {vision_agent-0.2.135 → vision_agent-0.2.137}/vision_agent/tools/prompts.py +0 -0
  25. {vision_agent-0.2.135 → vision_agent-0.2.137}/vision_agent/tools/tool_utils.py +0 -0
  26. {vision_agent-0.2.135 → vision_agent-0.2.137}/vision_agent/tools/tools.py +0 -0
  27. {vision_agent-0.2.135 → vision_agent-0.2.137}/vision_agent/tools/tools_types.py +0 -0
  28. {vision_agent-0.2.135 → vision_agent-0.2.137}/vision_agent/utils/__init__.py +0 -0
  29. {vision_agent-0.2.135 → vision_agent-0.2.137}/vision_agent/utils/exceptions.py +0 -0
  30. {vision_agent-0.2.135 → vision_agent-0.2.137}/vision_agent/utils/image_utils.py +0 -0
  31. {vision_agent-0.2.135 → vision_agent-0.2.137}/vision_agent/utils/sim.py +0 -0
  32. {vision_agent-0.2.135 → vision_agent-0.2.137}/vision_agent/utils/type_defs.py +0 -0
  33. {vision_agent-0.2.135 → vision_agent-0.2.137}/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.135
3
+ Version: 0.2.137
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.135"
7
+ version = "0.2.137"
8
8
  description = "Toolset for Vision Agent"
9
9
  authors = ["Landing AI <dev@landing.ai>"]
10
10
  readme = "README.md"
@@ -13,9 +13,8 @@ from vision_agent.agent.vision_agent_prompts import (
13
13
  VA_CODE,
14
14
  )
15
15
  from vision_agent.lmm import LMM, Message, OpenAILMM
16
- from vision_agent.tools import META_TOOL_DOCSTRING, save_image, load_image
16
+ from vision_agent.tools import META_TOOL_DOCSTRING
17
17
  from vision_agent.tools.meta_tools import Artifacts, use_extra_vision_agent_args
18
- from vision_agent.tools.tools import extract_frames, save_video
19
18
  from vision_agent.utils import CodeInterpreterFactory
20
19
  from vision_agent.utils.execute import CodeInterpreter, Execution
21
20
 
@@ -223,25 +222,7 @@ class VisionAgent(Agent):
223
222
  for chat_i in int_chat:
224
223
  if "media" in chat_i:
225
224
  for media in chat_i["media"]:
226
- if type(media) is str and media.startswith(("http", "https")):
227
- # TODO: Ideally we should not call VA.tools here, we should come to revisit how to better support remote image later
228
- file_path = str(
229
- Path(self.local_artifacts_path).parent
230
- / Path(media).name
231
- )
232
- if file_path.lower().endswith(
233
- ".mp4"
234
- ) or file_path.lower().endswith(".mov"):
235
- video_frames = extract_frames(media)
236
- save_video(
237
- [frame for frame, _ in video_frames], file_path
238
- )
239
- else:
240
- ndarray = load_image(media)
241
- save_image(ndarray, file_path)
242
- media = file_path
243
- else:
244
- media = cast(str, media)
225
+ media = cast(str, media)
245
226
  artifacts.artifacts[Path(media).name] = open(media, "rb").read()
246
227
 
247
228
  media_remote_path = (
@@ -1,4 +1,5 @@
1
1
  import difflib
2
+ import json
2
3
  import os
3
4
  import pickle as pkl
4
5
  import re
@@ -70,8 +71,8 @@ def redisplay_results(execution: Execution) -> None:
70
71
  display({MimeType.TEXT_LATEX: result.latex}, raw=True)
71
72
  if result.json is not None:
72
73
  display({MimeType.APPLICATION_JSON: result.json}, raw=True)
73
- if result.artifact_name is not None:
74
- display({MimeType.TEXT_ARTIFACT_NAME: result.artifact_name}, raw=True)
74
+ if result.artifact is not None:
75
+ display({MimeType.APPLICATION_ARTIFACT: result.artifact}, raw=True)
75
76
  if result.extra is not None:
76
77
  display(result.extra, raw=True)
77
78
 
@@ -210,7 +211,18 @@ def create_code_artifact(artifacts: Artifacts, name: str) -> str:
210
211
  return_str = f"[Artifact {name} created]"
211
212
  print(return_str)
212
213
 
213
- display({MimeType.TEXT_ARTIFACT_NAME: name}, raw=True)
214
+ display(
215
+ {
216
+ MimeType.APPLICATION_ARTIFACT: json.dumps(
217
+ {
218
+ "name": name,
219
+ "content": artifacts[name],
220
+ "action": "create",
221
+ }
222
+ )
223
+ },
224
+ raw=True,
225
+ )
214
226
  return return_str
215
227
 
216
228
 
@@ -294,7 +306,18 @@ def edit_code_artifact(
294
306
 
295
307
  artifacts[name] = "".join(edited_lines)
296
308
 
297
- display({MimeType.TEXT_ARTIFACT_NAME: name}, raw=True)
309
+ display(
310
+ {
311
+ MimeType.APPLICATION_ARTIFACT: json.dumps(
312
+ {
313
+ "name": name,
314
+ "content": artifacts[name],
315
+ "action": "edit",
316
+ }
317
+ )
318
+ },
319
+ raw=True,
320
+ )
298
321
  return open_code_artifact(artifacts, name, cur_line)
299
322
 
300
323
 
@@ -350,7 +373,19 @@ def generate_vision_code(
350
373
  code_lines = code.splitlines(keepends=True)
351
374
  total_lines = len(code_lines)
352
375
 
353
- display({MimeType.TEXT_ARTIFACT_NAME: name}, raw=True)
376
+ display(
377
+ {
378
+ MimeType.APPLICATION_ARTIFACT: json.dumps(
379
+ {
380
+ "name": name,
381
+ "content": code,
382
+ "contentType": "vision_code",
383
+ "action": "create",
384
+ }
385
+ )
386
+ },
387
+ raw=True,
388
+ )
354
389
  return view_lines(code_lines, 0, total_lines, name, total_lines)
355
390
 
356
391
 
@@ -415,7 +450,18 @@ def edit_vision_code(
415
450
  code_lines = code.splitlines(keepends=True)
416
451
  total_lines = len(code_lines)
417
452
 
418
- display({MimeType.TEXT_ARTIFACT_NAME: name}, raw=True)
453
+ display(
454
+ {
455
+ MimeType.APPLICATION_ARTIFACT: json.dumps(
456
+ {
457
+ "name": name,
458
+ "content": code,
459
+ "action": "edit",
460
+ }
461
+ )
462
+ },
463
+ raw=True,
464
+ )
419
465
  return view_lines(code_lines, 0, total_lines, name, total_lines)
420
466
 
421
467
 
@@ -429,7 +475,6 @@ def write_media_artifact(artifacts: Artifacts, local_path: str) -> str:
429
475
  with open(local_path, "rb") as f:
430
476
  media = f.read()
431
477
  artifacts[Path(local_path).name] = media
432
- display({MimeType.TEXT_ARTIFACT_NAME: Path(local_path).name}, raw=True)
433
478
  return f"[Media {Path(local_path).name} saved]"
434
479
 
435
480
 
@@ -596,7 +641,14 @@ def use_florence2_fine_tuning(
596
641
  diff = get_diff_with_prompts(name, code, new_code)
597
642
  print(diff)
598
643
 
599
- display({MimeType.TEXT_ARTIFACT_NAME: name}, raw=True)
644
+ display(
645
+ {
646
+ MimeType.APPLICATION_ARTIFACT: json.dumps(
647
+ {"name": name, "content": new_code}
648
+ )
649
+ },
650
+ raw=True,
651
+ )
600
652
  return diff
601
653
 
602
654
 
@@ -56,7 +56,7 @@ class MimeType(str, Enum):
56
56
  TEXT_LATEX = "text/latex"
57
57
  APPLICATION_JSON = "application/json"
58
58
  APPLICATION_JAVASCRIPT = "application/javascript"
59
- TEXT_ARTIFACT_NAME = "text/artifact/name"
59
+ APPLICATION_ARTIFACT = "application/artifact"
60
60
 
61
61
 
62
62
  class FileSerializer:
@@ -129,7 +129,7 @@ class Result:
129
129
  self.latex = data.pop(MimeType.TEXT_LATEX, None)
130
130
  self.json = data.pop(MimeType.APPLICATION_JSON, None)
131
131
  self.javascript = data.pop(MimeType.APPLICATION_JAVASCRIPT, None)
132
- self.artifact_name = data.pop(MimeType.TEXT_ARTIFACT_NAME, None)
132
+ self.artifact = data.pop(MimeType.APPLICATION_ARTIFACT, None)
133
133
  self.extra = data
134
134
  # Only keeping the PNG representation if both PNG and JPEG are present
135
135
  if self.png and self.jpeg:
@@ -207,8 +207,8 @@ class Result:
207
207
  formats.append("javascript")
208
208
  if self.mp4:
209
209
  formats.append("mp4")
210
- if self.artifact_name:
211
- formats.append("artifact_name")
210
+ if self.artifact:
211
+ formats.append("artifact")
212
212
  if self.extra:
213
213
  formats.extend(iter(self.extra))
214
214
  return formats
File without changes
File without changes