vision-agent 0.2.175__tar.gz → 0.2.177__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. {vision_agent-0.2.175 → vision_agent-0.2.177}/PKG-INFO +10 -10
  2. {vision_agent-0.2.175 → vision_agent-0.2.177}/README.md +9 -9
  3. {vision_agent-0.2.175 → vision_agent-0.2.177}/pyproject.toml +1 -1
  4. {vision_agent-0.2.175 → vision_agent-0.2.177}/vision_agent/agent/vision_agent.py +16 -4
  5. {vision_agent-0.2.175 → vision_agent-0.2.177}/vision_agent/tools/__init__.py +17 -1
  6. {vision_agent-0.2.175 → vision_agent-0.2.177}/vision_agent/tools/meta_tools.py +37 -11
  7. {vision_agent-0.2.175 → vision_agent-0.2.177}/LICENSE +0 -0
  8. {vision_agent-0.2.175 → vision_agent-0.2.177}/vision_agent/__init__.py +0 -0
  9. {vision_agent-0.2.175 → vision_agent-0.2.177}/vision_agent/agent/__init__.py +0 -0
  10. {vision_agent-0.2.175 → vision_agent-0.2.177}/vision_agent/agent/agent.py +0 -0
  11. {vision_agent-0.2.175 → vision_agent-0.2.177}/vision_agent/agent/agent_utils.py +0 -0
  12. {vision_agent-0.2.175 → vision_agent-0.2.177}/vision_agent/agent/vision_agent_coder.py +0 -0
  13. {vision_agent-0.2.175 → vision_agent-0.2.177}/vision_agent/agent/vision_agent_coder_prompts.py +0 -0
  14. {vision_agent-0.2.175 → vision_agent-0.2.177}/vision_agent/agent/vision_agent_planner.py +0 -0
  15. {vision_agent-0.2.175 → vision_agent-0.2.177}/vision_agent/agent/vision_agent_planner_prompts.py +0 -0
  16. {vision_agent-0.2.175 → vision_agent-0.2.177}/vision_agent/agent/vision_agent_prompts.py +0 -0
  17. {vision_agent-0.2.175 → vision_agent-0.2.177}/vision_agent/clients/__init__.py +0 -0
  18. {vision_agent-0.2.175 → vision_agent-0.2.177}/vision_agent/clients/http.py +0 -0
  19. {vision_agent-0.2.175 → vision_agent-0.2.177}/vision_agent/clients/landing_public_api.py +0 -0
  20. {vision_agent-0.2.175 → vision_agent-0.2.177}/vision_agent/fonts/__init__.py +0 -0
  21. {vision_agent-0.2.175 → vision_agent-0.2.177}/vision_agent/fonts/default_font_ch_en.ttf +0 -0
  22. {vision_agent-0.2.175 → vision_agent-0.2.177}/vision_agent/lmm/__init__.py +0 -0
  23. {vision_agent-0.2.175 → vision_agent-0.2.177}/vision_agent/lmm/lmm.py +0 -0
  24. {vision_agent-0.2.175 → vision_agent-0.2.177}/vision_agent/lmm/types.py +0 -0
  25. {vision_agent-0.2.175 → vision_agent-0.2.177}/vision_agent/tools/prompts.py +0 -0
  26. {vision_agent-0.2.175 → vision_agent-0.2.177}/vision_agent/tools/tool_utils.py +0 -0
  27. {vision_agent-0.2.175 → vision_agent-0.2.177}/vision_agent/tools/tools.py +0 -0
  28. {vision_agent-0.2.175 → vision_agent-0.2.177}/vision_agent/tools/tools_types.py +0 -0
  29. {vision_agent-0.2.175 → vision_agent-0.2.177}/vision_agent/utils/__init__.py +0 -0
  30. {vision_agent-0.2.175 → vision_agent-0.2.177}/vision_agent/utils/exceptions.py +0 -0
  31. {vision_agent-0.2.175 → vision_agent-0.2.177}/vision_agent/utils/execute.py +0 -0
  32. {vision_agent-0.2.175 → vision_agent-0.2.177}/vision_agent/utils/image_utils.py +0 -0
  33. {vision_agent-0.2.175 → vision_agent-0.2.177}/vision_agent/utils/sim.py +0 -0
  34. {vision_agent-0.2.175 → vision_agent-0.2.177}/vision_agent/utils/type_defs.py +0 -0
  35. {vision_agent-0.2.175 → vision_agent-0.2.177}/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.175
3
+ Version: 0.2.177
4
4
  Summary: Toolset for Vision Agent
5
5
  Author: Landing AI
6
6
  Author-email: dev@landing.ai
@@ -53,25 +53,25 @@ Description-Content-Type: text/markdown
53
53
  ![version](https://img.shields.io/pypi/pyversions/vision-agent)
54
54
  </div>
55
55
 
56
- Vision Agent is a library that helps you utilize agent frameworks to generate code to
56
+ VisionAgent is a library that helps you utilize agent frameworks to generate code to
57
57
  solve your vision task. Many current vision problems can easily take hours or days to
58
58
  solve, you need to find the right model, figure out how to use it and program it to
59
- accomplish the task you want. Vision Agent aims to provide an in-seconds experience by
59
+ accomplish the task you want. VisionAgent aims to provide an in-seconds experience by
60
60
  allowing users to describe their problem in text and have the agent framework generate
61
61
  code to solve the task for them. Check out our discord for updates and roadmaps!
62
62
 
63
63
  ## Table of Contents
64
64
  - [🚀Quick Start](#quick-start)
65
65
  - [📚Documentation](#documentation)
66
- - [🔍🤖Vision Agent](#vision-agent-basic-usage)
66
+ - [🔍🤖VisionAgent](#vision-agent-basic-usage)
67
67
  - [🛠️Tools](#tools)
68
68
  - [🤖LMMs](#lmms)
69
- - [💻🤖Vision Agent Coder](#vision-agent-coder)
69
+ - [💻🤖VisionAgent Coder](#vision-agent-coder)
70
70
  - [🏗️Additional Backends](#additional-backends)
71
71
 
72
72
  ## Quick Start
73
73
  ### Web Application
74
- The fastest way to test out Vision Agent is to use our web application. You can find it
74
+ The fastest way to test out VisionAgent is to use our web application. You can find it
75
75
  [here](https://va.landing.ai/).
76
76
 
77
77
 
@@ -108,9 +108,9 @@ be images or video files.
108
108
 
109
109
  ## Documentation
110
110
 
111
- [Vision Agent Library Docs](https://landing-ai.github.io/vision-agent/)
111
+ [VisionAgent Library Docs](https://landing-ai.github.io/vision-agent/)
112
112
 
113
- ## Vision Agent Basic Usage
113
+ ## VisionAgent Basic Usage
114
114
  ### Chatting and Message Formats
115
115
  `VisionAgent` is an agent that can chat with you and call other tools or agents to
116
116
  write vision code for you. You can interact with it like you would ChatGPT or any other
@@ -292,7 +292,7 @@ response = lmm(
292
292
  )
293
293
  ```
294
294
 
295
- ## Vision Agent Coder
295
+ ## VisionAgent Coder
296
296
  Underneath the hood, `VisionAgent` uses `VisionAgentCoder` to generate code to solve
297
297
  vision tasks. You can use `VisionAgentCoder` directly to generate code if you want:
298
298
 
@@ -488,7 +488,7 @@ export AZURE_OPENAI_EMBEDDING_MODEL_DEPLOYMENT_NAME="your_embedding_model_deploy
488
488
 
489
489
  > NOTE: make sure your Azure model deployment have enough quota (token per minute) to support it. The default value 8000TPM is not enough.
490
490
 
491
- You can then run Vision Agent using the Azure OpenAI models:
491
+ You can then run VisionAgent using the Azure OpenAI models:
492
492
 
493
493
  ```python
494
494
  import vision_agent as va
@@ -11,25 +11,25 @@
11
11
  ![version](https://img.shields.io/pypi/pyversions/vision-agent)
12
12
  </div>
13
13
 
14
- Vision Agent is a library that helps you utilize agent frameworks to generate code to
14
+ VisionAgent is a library that helps you utilize agent frameworks to generate code to
15
15
  solve your vision task. Many current vision problems can easily take hours or days to
16
16
  solve, you need to find the right model, figure out how to use it and program it to
17
- accomplish the task you want. Vision Agent aims to provide an in-seconds experience by
17
+ accomplish the task you want. VisionAgent aims to provide an in-seconds experience by
18
18
  allowing users to describe their problem in text and have the agent framework generate
19
19
  code to solve the task for them. Check out our discord for updates and roadmaps!
20
20
 
21
21
  ## Table of Contents
22
22
  - [🚀Quick Start](#quick-start)
23
23
  - [📚Documentation](#documentation)
24
- - [🔍🤖Vision Agent](#vision-agent-basic-usage)
24
+ - [🔍🤖VisionAgent](#vision-agent-basic-usage)
25
25
  - [🛠️Tools](#tools)
26
26
  - [🤖LMMs](#lmms)
27
- - [💻🤖Vision Agent Coder](#vision-agent-coder)
27
+ - [💻🤖VisionAgent Coder](#vision-agent-coder)
28
28
  - [🏗️Additional Backends](#additional-backends)
29
29
 
30
30
  ## Quick Start
31
31
  ### Web Application
32
- The fastest way to test out Vision Agent is to use our web application. You can find it
32
+ The fastest way to test out VisionAgent is to use our web application. You can find it
33
33
  [here](https://va.landing.ai/).
34
34
 
35
35
 
@@ -66,9 +66,9 @@ be images or video files.
66
66
 
67
67
  ## Documentation
68
68
 
69
- [Vision Agent Library Docs](https://landing-ai.github.io/vision-agent/)
69
+ [VisionAgent Library Docs](https://landing-ai.github.io/vision-agent/)
70
70
 
71
- ## Vision Agent Basic Usage
71
+ ## VisionAgent Basic Usage
72
72
  ### Chatting and Message Formats
73
73
  `VisionAgent` is an agent that can chat with you and call other tools or agents to
74
74
  write vision code for you. You can interact with it like you would ChatGPT or any other
@@ -250,7 +250,7 @@ response = lmm(
250
250
  )
251
251
  ```
252
252
 
253
- ## Vision Agent Coder
253
+ ## VisionAgent Coder
254
254
  Underneath the hood, `VisionAgent` uses `VisionAgentCoder` to generate code to solve
255
255
  vision tasks. You can use `VisionAgentCoder` directly to generate code if you want:
256
256
 
@@ -446,7 +446,7 @@ export AZURE_OPENAI_EMBEDDING_MODEL_DEPLOYMENT_NAME="your_embedding_model_deploy
446
446
 
447
447
  > NOTE: make sure your Azure model deployment have enough quota (token per minute) to support it. The default value 8000TPM is not enough.
448
448
 
449
- You can then run Vision Agent using the Azure OpenAI models:
449
+ You can then run VisionAgent using the Azure OpenAI models:
450
450
 
451
451
  ```python
452
452
  import vision_agent as va
@@ -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.175"
7
+ version = "0.2.177"
8
8
  description = "Toolset for Vision Agent"
9
9
  authors = ["Landing AI <dev@landing.ai>"]
10
10
  readme = "README.md"
@@ -212,6 +212,19 @@ def add_step_descriptions(response: Dict[str, Any]) -> Dict[str, Any]:
212
212
  return response
213
213
 
214
214
 
215
+ def setup_artifacts() -> Artifacts:
216
+ # this is setting remote artifacts path
217
+ sandbox = os.environ.get("CODE_SANDBOX_RUNTIME", None)
218
+ if sandbox is None or sandbox == "local":
219
+ remote = WORKSPACE / "artifacts.pkl"
220
+ elif sandbox == "e2b":
221
+ remote = Path("/home/user/artifacts.pkl")
222
+ else:
223
+ raise ValueError(f"Unknown code sandbox runtime {sandbox}")
224
+ artifacts = Artifacts(remote, Path(os.getcwd()) / "artifacts.pkl")
225
+ return artifacts
226
+
227
+
215
228
  def new_format_to_old_format(new_format: Dict[str, Any]) -> Dict[str, Any]:
216
229
  thoughts = new_format["thinking"] if new_format["thinking"] is not None else ""
217
230
  response = new_format["response"] if new_format["response"] is not None else ""
@@ -384,8 +397,7 @@ class VisionAgent(Agent):
384
397
  raise ValueError("chat cannot be empty")
385
398
 
386
399
  if not artifacts:
387
- # this is setting remote artifacts path
388
- artifacts = Artifacts("", "")
400
+ artifacts = setup_artifacts()
389
401
 
390
402
  # NOTE: each chat should have a dedicated code interpreter instance to avoid concurrency issues
391
403
  code_interpreter = (
@@ -400,7 +412,7 @@ class VisionAgent(Agent):
400
412
 
401
413
  if code_interpreter.remote_path != artifacts.remote_save_path.parent:
402
414
  raise ValueError(
403
- f"Code interpreter remote path {code_interpreter.remote_path} does not match {artifacts.remote_save_path.parent}"
415
+ f"Code interpreter remote path {code_interpreter.remote_path} does not match artifacts remote path {artifacts.remote_save_path.parent}"
404
416
  )
405
417
 
406
418
  with code_interpreter:
@@ -415,7 +427,7 @@ class VisionAgent(Agent):
415
427
  artifacts.artifacts[Path(media).name] = open(media, "rb").read()
416
428
 
417
429
  media_remote_path = (
418
- Path(code_interpreter.remote_path) / Path(media).name
430
+ Path(artifacts.remote_save_path.parent) / Path(media).name
419
431
  )
420
432
  chat_i["content"] += f" Media name {media_remote_path}" # type: ignore
421
433
  media_list.append(media_remote_path)
@@ -1,5 +1,17 @@
1
1
  from typing import Callable, List, Optional
2
2
 
3
+ from .meta_tools import (
4
+ create_code_artifact,
5
+ edit_code_artifact,
6
+ edit_vision_code,
7
+ generate_vision_code,
8
+ get_tool_descriptions,
9
+ list_artifacts,
10
+ object_detection_fine_tuning,
11
+ open_code_artifact,
12
+ use_object_detection_fine_tuning,
13
+ view_media_artifact,
14
+ )
3
15
  from .prompts import CHOOSE_PARAMS, SYSTEM_PROMPT
4
16
  from .tool_utils import get_tool_descriptions_by_names
5
17
  from .tools import (
@@ -65,7 +77,11 @@ def register_tool(imports: Optional[List] = None) -> Callable:
65
77
  def decorator(tool: Callable) -> Callable:
66
78
  import inspect
67
79
 
68
- from .tools import get_tool_descriptions, get_tools_df, get_tools_info
80
+ from .tools import ( # noqa: F811
81
+ get_tool_descriptions,
82
+ get_tools_df,
83
+ get_tools_info,
84
+ )
69
85
 
70
86
  global TOOLS, TOOLS_DF, TOOL_DESCRIPTIONS, TOOL_DOCSTRING, TOOLS_INFO
71
87
 
@@ -76,6 +76,14 @@ class Artifacts:
76
76
  def __init__(
77
77
  self, remote_save_path: Union[str, Path], local_save_path: Union[str, Path]
78
78
  ) -> None:
79
+ """Initializes the Artifacts object with it's remote and local save paths.
80
+
81
+ Parameters:
82
+ remote_save_path (Union[str, Path]): The path to save the artifacts in the
83
+ remote environment. For example "/home/user/artifacts.pkl".
84
+ local_save_path (Union[str, Path]): The path to save the artifacts in the
85
+ local environment. For example "/Users/my_user/workspace/artifacts.pkl".
86
+ """
79
87
  self.remote_save_path = Path(remote_save_path)
80
88
  self.local_save_path = Path(local_save_path)
81
89
  self.artifacts: Dict[str, Any] = {}
@@ -85,31 +93,46 @@ class Artifacts:
85
93
  def load(
86
94
  self,
87
95
  artifacts_path: Union[str, Path],
88
- load_to: Optional[Union[str, Path]] = None,
96
+ load_to_dir: Optional[Union[str, Path]] = None,
89
97
  ) -> None:
90
- """Loads are artifacts into the load_to path. If load_to is None, it will load
91
- into remote_save_path. If an artifact value is None it will skip loading it.
98
+ """Loads are artifacts into the load_to_dir directory. If load_to_dir is None,
99
+ it will load into remote_save_path directory. If an artifact value is None it
100
+ will skip loading it.
92
101
 
93
102
  Parameters:
94
- artifacts_path (Union[str, Path]): The file path to load the artifacts from
103
+ artifacts_path (Union[str, Path]): The file path to load the artifacts from.
104
+ If you are in the remote environment this would be remote_save_path, if
105
+ you are in the local environment this would be local_save_path.
106
+ load_to_dir (Optional[Union[str, Path]): The directory to load the artifacts
107
+ into. If None, it will load into remote_save_path directory.
95
108
  """
96
109
  with open(artifacts_path, "rb") as f:
97
110
  self.artifacts = pkl.load(f)
98
111
 
99
- load_to = self.remote_save_path.parent if load_to is None else Path(load_to)
112
+ load_to_dir = (
113
+ self.remote_save_path.parent if load_to_dir is None else Path(load_to_dir)
114
+ )
100
115
 
101
116
  for k, v in self.artifacts.items():
102
117
  if v is not None:
103
118
  mode = "w" if isinstance(v, str) else "wb"
104
- with open(load_to / k, mode) as f:
119
+ with open(load_to_dir / k, mode) as f:
105
120
  f.write(v)
106
121
 
107
- def show(self, uploaded_file_path: Optional[Union[str, Path]] = None) -> str:
108
- """Shows the artifacts that have been loaded and their remote save paths."""
122
+ def show(self, uploaded_file_dir: Optional[Union[str, Path]] = None) -> str:
123
+ """Prints out the artifacts and the directory they have been loaded to. If you
124
+ pass in upload_file_dir, it will show the artifacts have been loaded to the
125
+ upload_file_dir directory. If you don't pass in upload_file_dir, it will show
126
+ the artifacts have been loaded to the remote_save_path directory.
127
+
128
+ Parameters:
129
+ uploaded_file_dir (Optional[Union[str, Path]): The directory the artifacts
130
+ have been loaded to.
131
+ """
109
132
  loaded_path = (
110
- Path(uploaded_file_path)
111
- if uploaded_file_path is not None
112
- else self.remote_save_path
133
+ Path(uploaded_file_dir)
134
+ if uploaded_file_dir is not None
135
+ else self.remote_save_path.parent
113
136
  )
114
137
  output_str = "[Artifacts loaded]\n"
115
138
  for k in self.artifacts.keys():
@@ -121,6 +144,9 @@ class Artifacts:
121
144
  return output_str
122
145
 
123
146
  def save(self, local_path: Optional[Union[str, Path]] = None) -> None:
147
+ """Saves the artifacts to the local_save_path directory. If local_path is None,
148
+ it will save to the local_save_path directory.
149
+ """
124
150
  save_path = Path(local_path) if local_path is not None else self.local_save_path
125
151
  with open(save_path, "wb") as f:
126
152
  pkl.dump(self.artifacts, f)
File without changes