vision-agent 0.2.203__tar.gz → 0.2.205__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {vision_agent-0.2.203 → vision_agent-0.2.205}/PKG-INFO +1 -1
- {vision_agent-0.2.203 → vision_agent-0.2.205}/pyproject.toml +1 -1
- {vision_agent-0.2.203 → vision_agent-0.2.205}/vision_agent/agent/vision_agent_planner_v2.py +3 -1
- {vision_agent-0.2.203 → vision_agent-0.2.205}/vision_agent/agent/vision_agent_prompts.py +1 -1
- {vision_agent-0.2.203 → vision_agent-0.2.205}/vision_agent/tools/planner_tools.py +59 -31
- {vision_agent-0.2.203 → vision_agent-0.2.205}/LICENSE +0 -0
- {vision_agent-0.2.203 → vision_agent-0.2.205}/README.md +0 -0
- {vision_agent-0.2.203 → vision_agent-0.2.205}/vision_agent/.sim_tools/df.csv +0 -0
- {vision_agent-0.2.203 → vision_agent-0.2.205}/vision_agent/.sim_tools/embs.npy +0 -0
- {vision_agent-0.2.203 → vision_agent-0.2.205}/vision_agent/__init__.py +0 -0
- {vision_agent-0.2.203 → vision_agent-0.2.205}/vision_agent/agent/README.md +0 -0
- {vision_agent-0.2.203 → vision_agent-0.2.205}/vision_agent/agent/__init__.py +0 -0
- {vision_agent-0.2.203 → vision_agent-0.2.205}/vision_agent/agent/agent.py +0 -0
- {vision_agent-0.2.203 → vision_agent-0.2.205}/vision_agent/agent/agent_utils.py +0 -0
- {vision_agent-0.2.203 → vision_agent-0.2.205}/vision_agent/agent/types.py +0 -0
- {vision_agent-0.2.203 → vision_agent-0.2.205}/vision_agent/agent/vision_agent.py +0 -0
- {vision_agent-0.2.203 → vision_agent-0.2.205}/vision_agent/agent/vision_agent_coder.py +0 -0
- {vision_agent-0.2.203 → vision_agent-0.2.205}/vision_agent/agent/vision_agent_coder_prompts.py +0 -0
- {vision_agent-0.2.203 → vision_agent-0.2.205}/vision_agent/agent/vision_agent_coder_prompts_v2.py +0 -0
- {vision_agent-0.2.203 → vision_agent-0.2.205}/vision_agent/agent/vision_agent_coder_v2.py +0 -0
- {vision_agent-0.2.203 → vision_agent-0.2.205}/vision_agent/agent/vision_agent_planner.py +0 -0
- {vision_agent-0.2.203 → vision_agent-0.2.205}/vision_agent/agent/vision_agent_planner_prompts.py +0 -0
- {vision_agent-0.2.203 → vision_agent-0.2.205}/vision_agent/agent/vision_agent_planner_prompts_v2.py +0 -0
- {vision_agent-0.2.203 → vision_agent-0.2.205}/vision_agent/agent/vision_agent_prompts_v2.py +0 -0
- {vision_agent-0.2.203 → vision_agent-0.2.205}/vision_agent/agent/vision_agent_v2.py +0 -0
- {vision_agent-0.2.203 → vision_agent-0.2.205}/vision_agent/clients/__init__.py +0 -0
- {vision_agent-0.2.203 → vision_agent-0.2.205}/vision_agent/clients/http.py +0 -0
- {vision_agent-0.2.203 → vision_agent-0.2.205}/vision_agent/clients/landing_public_api.py +0 -0
- {vision_agent-0.2.203 → vision_agent-0.2.205}/vision_agent/fonts/__init__.py +0 -0
- {vision_agent-0.2.203 → vision_agent-0.2.205}/vision_agent/fonts/default_font_ch_en.ttf +0 -0
- {vision_agent-0.2.203 → vision_agent-0.2.205}/vision_agent/lmm/__init__.py +0 -0
- {vision_agent-0.2.203 → vision_agent-0.2.205}/vision_agent/lmm/lmm.py +0 -0
- {vision_agent-0.2.203 → vision_agent-0.2.205}/vision_agent/lmm/types.py +0 -0
- {vision_agent-0.2.203 → vision_agent-0.2.205}/vision_agent/tools/__init__.py +0 -0
- {vision_agent-0.2.203 → vision_agent-0.2.205}/vision_agent/tools/meta_tools.py +0 -0
- {vision_agent-0.2.203 → vision_agent-0.2.205}/vision_agent/tools/prompts.py +0 -0
- {vision_agent-0.2.203 → vision_agent-0.2.205}/vision_agent/tools/tool_utils.py +0 -0
- {vision_agent-0.2.203 → vision_agent-0.2.205}/vision_agent/tools/tools.py +0 -0
- {vision_agent-0.2.203 → vision_agent-0.2.205}/vision_agent/tools/tools_types.py +0 -0
- {vision_agent-0.2.203 → vision_agent-0.2.205}/vision_agent/utils/__init__.py +0 -0
- {vision_agent-0.2.203 → vision_agent-0.2.205}/vision_agent/utils/exceptions.py +0 -0
- {vision_agent-0.2.203 → vision_agent-0.2.205}/vision_agent/utils/execute.py +0 -0
- {vision_agent-0.2.203 → vision_agent-0.2.205}/vision_agent/utils/image_utils.py +0 -0
- {vision_agent-0.2.203 → vision_agent-0.2.205}/vision_agent/utils/sim.py +0 -0
- {vision_agent-0.2.203 → vision_agent-0.2.205}/vision_agent/utils/type_defs.py +0 -0
- {vision_agent-0.2.203 → vision_agent-0.2.205}/vision_agent/utils/video.py +0 -0
@@ -367,8 +367,10 @@ def replace_interaction_with_obs(chat: List[AgentMessage]) -> List[AgentMessage]
|
|
367
367
|
response = json.loads(chat[i + 1].content)
|
368
368
|
function_name = response["function_name"]
|
369
369
|
tool_doc = get_tool_documentation(function_name)
|
370
|
+
if "box_threshold" in response:
|
371
|
+
tool_doc = f"Use the following function with box_threshold={response['box_threshold']}\n\n{tool_doc}"
|
370
372
|
new_chat.append(AgentMessage(role="observation", content=tool_doc))
|
371
|
-
except json.JSONDecodeError:
|
373
|
+
except (json.JSONDecodeError, KeyError):
|
372
374
|
raise ValueError(f"Invalid JSON in interaction response: {chat_i}")
|
373
375
|
else:
|
374
376
|
new_chat.append(chat_i)
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import inspect
|
1
2
|
import logging
|
2
3
|
import shutil
|
3
4
|
import tempfile
|
@@ -63,12 +64,55 @@ def extract_tool_info(
|
|
63
64
|
return tool, tool_thoughts, tool_docstring, ""
|
64
65
|
|
65
66
|
|
67
|
+
def replace_box_threshold(code: str, functions: List[str], box_threshold: float) -> str:
|
68
|
+
class ReplaceBoxThresholdTransformer(cst.CSTTransformer):
|
69
|
+
def leave_Call(
|
70
|
+
self, original_node: cst.Call, updated_node: cst.Call
|
71
|
+
) -> cst.Call:
|
72
|
+
if (
|
73
|
+
isinstance(updated_node.func, cst.Name)
|
74
|
+
and updated_node.func.value in functions
|
75
|
+
) or (
|
76
|
+
isinstance(updated_node.func, cst.Attribute)
|
77
|
+
and updated_node.func.attr.value in functions
|
78
|
+
):
|
79
|
+
new_args = []
|
80
|
+
found = False
|
81
|
+
for arg in updated_node.args:
|
82
|
+
if arg.keyword and arg.keyword.value == "box_threshold":
|
83
|
+
new_arg = arg.with_changes(value=cst.Float(str(box_threshold)))
|
84
|
+
new_args.append(new_arg)
|
85
|
+
found = True
|
86
|
+
else:
|
87
|
+
new_args.append(arg)
|
88
|
+
|
89
|
+
if not found:
|
90
|
+
new_args.append(
|
91
|
+
cst.Arg(
|
92
|
+
keyword=cst.Name("box_threshold"),
|
93
|
+
value=cst.Float(str(box_threshold)),
|
94
|
+
equal=cst.AssignEqual(
|
95
|
+
whitespace_before=cst.SimpleWhitespace(""),
|
96
|
+
whitespace_after=cst.SimpleWhitespace(""),
|
97
|
+
),
|
98
|
+
)
|
99
|
+
)
|
100
|
+
return updated_node.with_changes(args=new_args)
|
101
|
+
return updated_node
|
102
|
+
|
103
|
+
tree = cst.parse_module(code)
|
104
|
+
transformer = ReplaceBoxThresholdTransformer()
|
105
|
+
new_tree = tree.visit(transformer)
|
106
|
+
return new_tree.code
|
107
|
+
|
108
|
+
|
66
109
|
def run_tool_testing(
|
67
110
|
task: str,
|
68
111
|
image_paths: List[str],
|
69
112
|
lmm: LMM,
|
70
113
|
exclude_tools: Optional[List[str]],
|
71
114
|
code_interpreter: CodeInterpreter,
|
115
|
+
process_code: Callable[[str], str] = lambda x: x,
|
72
116
|
) -> tuple[str, str, Execution]:
|
73
117
|
"""Helper function to generate and run tool testing code."""
|
74
118
|
query = lmm.generate(CATEGORIZE_TOOL_REQUEST.format(task=task))
|
@@ -101,6 +145,7 @@ def run_tool_testing(
|
|
101
145
|
code = extract_tag(response, "code") # type: ignore
|
102
146
|
if code is None:
|
103
147
|
raise ValueError(f"Could not extract code from response: {response}")
|
148
|
+
code = process_code(code)
|
104
149
|
tool_output = code_interpreter.exec_isolation(DefaultImports.prepend_imports(code))
|
105
150
|
tool_output_str = tool_output.text(include_results=False).strip()
|
106
151
|
|
@@ -119,6 +164,7 @@ def run_tool_testing(
|
|
119
164
|
media=str(image_paths),
|
120
165
|
)
|
121
166
|
code = extract_code(lmm.generate(prompt, media=image_paths)) # type: ignore
|
167
|
+
code = process_code(code)
|
122
168
|
tool_output = code_interpreter.exec_isolation(
|
123
169
|
DefaultImports.prepend_imports(code)
|
124
170
|
)
|
@@ -221,36 +267,7 @@ def get_tool_documentation(tool_name: str) -> str:
|
|
221
267
|
def get_tool_for_task_human_reviewer(
|
222
268
|
task: str, images: List[np.ndarray], exclude_tools: Optional[List[str]] = None
|
223
269
|
) -> None:
|
224
|
-
# NOTE: this
|
225
|
-
"""Given a task and one or more images this function will find a tool to accomplish
|
226
|
-
the jobs. It prints the tool documentation and thoughts on why it chose the tool.
|
227
|
-
|
228
|
-
It can produce tools for the following types of tasks:
|
229
|
-
- Object detection and counting
|
230
|
-
- Classification
|
231
|
-
- Segmentation
|
232
|
-
- OCR
|
233
|
-
- VQA
|
234
|
-
- Depth and pose estimation
|
235
|
-
- Video object tracking
|
236
|
-
|
237
|
-
Wait until the documentation is printed to use the function so you know what the
|
238
|
-
input and output signatures are.
|
239
|
-
|
240
|
-
Parameters:
|
241
|
-
task: str: The task to accomplish.
|
242
|
-
images: List[np.ndarray]: The images to use for the task.
|
243
|
-
exclude_tools: Optional[List[str]]: A list of tool names to exclude from the
|
244
|
-
recommendations. This is helpful if you are calling get_tool_for_task twice
|
245
|
-
and do not want the same tool recommended.
|
246
|
-
|
247
|
-
Returns:
|
248
|
-
The tool to use for the task is printed to stdout
|
249
|
-
|
250
|
-
Examples
|
251
|
-
--------
|
252
|
-
>>> get_tool_for_task("Give me an OCR model that can find 'hot chocolate' in the image", [image])
|
253
|
-
"""
|
270
|
+
# NOTE: this will have the same documentation as get_tool_for_task
|
254
271
|
lmm = AnthropicLMM()
|
255
272
|
|
256
273
|
with (
|
@@ -263,8 +280,19 @@ def get_tool_for_task_human_reviewer(
|
|
263
280
|
Image.fromarray(image).save(image_path)
|
264
281
|
image_paths.append(image_path)
|
265
282
|
|
283
|
+
tools = [
|
284
|
+
t.__name__
|
285
|
+
for t in T.TOOLS
|
286
|
+
if inspect.signature(t).parameters.get("box_threshold") # type: ignore
|
287
|
+
]
|
288
|
+
|
266
289
|
_, _, tool_output = run_tool_testing(
|
267
|
-
task,
|
290
|
+
task,
|
291
|
+
image_paths,
|
292
|
+
lmm,
|
293
|
+
exclude_tools,
|
294
|
+
code_interpreter,
|
295
|
+
process_code=lambda x: replace_box_threshold(x, tools, 0.05),
|
268
296
|
)
|
269
297
|
|
270
298
|
# need to re-display results for the outer notebook to see them
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{vision_agent-0.2.203 → vision_agent-0.2.205}/vision_agent/agent/vision_agent_coder_prompts.py
RENAMED
File without changes
|
{vision_agent-0.2.203 → vision_agent-0.2.205}/vision_agent/agent/vision_agent_coder_prompts_v2.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
{vision_agent-0.2.203 → vision_agent-0.2.205}/vision_agent/agent/vision_agent_planner_prompts.py
RENAMED
File without changes
|
{vision_agent-0.2.203 → vision_agent-0.2.205}/vision_agent/agent/vision_agent_planner_prompts_v2.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|