vision-agent 0.2.175__py3-none-any.whl → 0.2.176__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- vision_agent/agent/vision_agent.py +16 -4
- vision_agent/tools/meta_tools.py +37 -11
- {vision_agent-0.2.175.dist-info → vision_agent-0.2.176.dist-info}/METADATA +10 -10
- {vision_agent-0.2.175.dist-info → vision_agent-0.2.176.dist-info}/RECORD +6 -6
- {vision_agent-0.2.175.dist-info → vision_agent-0.2.176.dist-info}/LICENSE +0 -0
- {vision_agent-0.2.175.dist-info → vision_agent-0.2.176.dist-info}/WHEEL +0 -0
@@ -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
|
-
|
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(
|
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)
|
vision_agent/tools/meta_tools.py
CHANGED
@@ -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
|
-
|
96
|
+
load_to_dir: Optional[Union[str, Path]] = None,
|
89
97
|
) -> None:
|
90
|
-
"""Loads are artifacts into the
|
91
|
-
into remote_save_path. If an artifact value is None 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
|
-
|
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(
|
119
|
+
with open(load_to_dir / k, mode) as f:
|
105
120
|
f.write(v)
|
106
121
|
|
107
|
-
def show(self,
|
108
|
-
"""
|
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(
|
111
|
-
if
|
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)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: vision-agent
|
3
|
-
Version: 0.2.
|
3
|
+
Version: 0.2.176
|
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
|
-
|
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.
|
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
|
-
- [🔍🤖
|
66
|
+
- [🔍🤖VisionAgent](#vision-agent-basic-usage)
|
67
67
|
- [🛠️Tools](#tools)
|
68
68
|
- [🤖LMMs](#lmms)
|
69
|
-
- [💻🤖
|
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
|
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
|
-
[
|
111
|
+
[VisionAgent Library Docs](https://landing-ai.github.io/vision-agent/)
|
112
112
|
|
113
|
-
##
|
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
|
-
##
|
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
|
491
|
+
You can then run VisionAgent using the Azure OpenAI models:
|
492
492
|
|
493
493
|
```python
|
494
494
|
import vision_agent as va
|
@@ -2,7 +2,7 @@ vision_agent/__init__.py,sha256=EAb4-f9iyuEYkBrX4ag1syM8Syx8118_t0R6_C34M9w,57
|
|
2
2
|
vision_agent/agent/__init__.py,sha256=RRMPhH8mgm_pCtEKiVFSjJyDi4lCr4F7k05AhK01xlM,436
|
3
3
|
vision_agent/agent/agent.py,sha256=2cjIOxEuSJrqbfPXYoV0qER5ihXsPFCoEFJa4jpqan0,597
|
4
4
|
vision_agent/agent/agent_utils.py,sha256=WYJF11PfKXlRMPnogGz3s7c2TlWoxoGzuLiIptVYE1s,5524
|
5
|
-
vision_agent/agent/vision_agent.py,sha256=
|
5
|
+
vision_agent/agent/vision_agent.py,sha256=x0-TElnTRW7abyq2wAwKRiTUExBGg24C-c74wO1oKtI,26336
|
6
6
|
vision_agent/agent/vision_agent_coder.py,sha256=3Q1VWrN-BNUoSD4OAqKazvXkP2c04PXDYu2Z1f5dQb0,31960
|
7
7
|
vision_agent/agent/vision_agent_coder_prompts.py,sha256=gPLVXQMNSzYnQYpNm0wlH_5FPkOTaFDV24bqzK3jQ40,12221
|
8
8
|
vision_agent/agent/vision_agent_planner.py,sha256=mjmnXG9CvYf_ZA7ZJ3ri4H-2U_Km55gF1sZYRSOlxpY,19027
|
@@ -17,7 +17,7 @@ vision_agent/lmm/__init__.py,sha256=jyY1sJb_tYKg5-Wzs3p1lvwFkc-aUNZfMcLy3TOC4Zg,
|
|
17
17
|
vision_agent/lmm/lmm.py,sha256=B5ClgwvbybVCWkf9opDMLjTtJZemUU4KUkQoRxGh43I,16787
|
18
18
|
vision_agent/lmm/types.py,sha256=ZEXR_ptBL0ZwDMTDYkgxUCmSZFmBYPQd2jreNzr_8UY,221
|
19
19
|
vision_agent/tools/__init__.py,sha256=u-vS5iORB4ccvxoAjbtpvhTALDhXGilcATIq1_eZhKo,2332
|
20
|
-
vision_agent/tools/meta_tools.py,sha256=
|
20
|
+
vision_agent/tools/meta_tools.py,sha256=by7TIbH7lsLIayX_Pe2mS1iw8aeLn2T8yqAo8SkB9Kg,32074
|
21
21
|
vision_agent/tools/prompts.py,sha256=V1z4YJLXZuUl_iZ5rY0M5hHc_2tmMEUKr0WocXKGt4E,1430
|
22
22
|
vision_agent/tools/tool_utils.py,sha256=VPGqGJ2ZYEJA6AW7K9X7hQv6vRlMtAQcybE4izdToCw,8196
|
23
23
|
vision_agent/tools/tools.py,sha256=iKsBZxJ5--xWK-mqgZ1jbX_bfGS5HmAp-VRZ69m9yPg,77921
|
@@ -29,7 +29,7 @@ vision_agent/utils/image_utils.py,sha256=rm9GfXvD4JrjnqKrP_f2gfq4SzmqYC0IdC1kKwd
|
|
29
29
|
vision_agent/utils/sim.py,sha256=ZuSS07TUXFGjipmiQoY8TKRmSes7XXCdtU9PI8PC1sw,5609
|
30
30
|
vision_agent/utils/type_defs.py,sha256=BE12s3JNQy36QvauXHjwyeffVh5enfcvd4vTzSwvEZI,1384
|
31
31
|
vision_agent/utils/video.py,sha256=fOPR48-SuwMbE5eB5rc2F7lVo6k1mVHn26eEJ0QCslc,5602
|
32
|
-
vision_agent-0.2.
|
33
|
-
vision_agent-0.2.
|
34
|
-
vision_agent-0.2.
|
35
|
-
vision_agent-0.2.
|
32
|
+
vision_agent-0.2.176.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
33
|
+
vision_agent-0.2.176.dist-info/METADATA,sha256=W86hwl87xkxa59Hn9rw8_FQGiMW3JncY9WQAmC5jxs0,18330
|
34
|
+
vision_agent-0.2.176.dist-info/WHEEL,sha256=7Z8_27uaHI_UZAc4Uox4PpBhQ9Y5_modZXWMxtUi4NU,88
|
35
|
+
vision_agent-0.2.176.dist-info/RECORD,,
|
File without changes
|
File without changes
|