vision-agent 0.2.172__tar.gz → 0.2.174__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {vision_agent-0.2.172 → vision_agent-0.2.174}/PKG-INFO +2 -2
- {vision_agent-0.2.172 → vision_agent-0.2.174}/pyproject.toml +2 -2
- {vision_agent-0.2.172 → vision_agent-0.2.174}/vision_agent/agent/vision_agent.py +11 -12
- {vision_agent-0.2.172 → vision_agent-0.2.174}/vision_agent/agent/vision_agent_coder.py +101 -31
- {vision_agent-0.2.172 → vision_agent-0.2.174}/vision_agent/tools/meta_tools.py +74 -16
- {vision_agent-0.2.172 → vision_agent-0.2.174}/LICENSE +0 -0
- {vision_agent-0.2.172 → vision_agent-0.2.174}/README.md +0 -0
- {vision_agent-0.2.172 → vision_agent-0.2.174}/vision_agent/__init__.py +0 -0
- {vision_agent-0.2.172 → vision_agent-0.2.174}/vision_agent/agent/__init__.py +0 -0
- {vision_agent-0.2.172 → vision_agent-0.2.174}/vision_agent/agent/agent.py +0 -0
- {vision_agent-0.2.172 → vision_agent-0.2.174}/vision_agent/agent/agent_utils.py +0 -0
- {vision_agent-0.2.172 → vision_agent-0.2.174}/vision_agent/agent/vision_agent_coder_prompts.py +0 -0
- {vision_agent-0.2.172 → vision_agent-0.2.174}/vision_agent/agent/vision_agent_planner.py +0 -0
- {vision_agent-0.2.172 → vision_agent-0.2.174}/vision_agent/agent/vision_agent_planner_prompts.py +0 -0
- {vision_agent-0.2.172 → vision_agent-0.2.174}/vision_agent/agent/vision_agent_prompts.py +0 -0
- {vision_agent-0.2.172 → vision_agent-0.2.174}/vision_agent/clients/__init__.py +0 -0
- {vision_agent-0.2.172 → vision_agent-0.2.174}/vision_agent/clients/http.py +0 -0
- {vision_agent-0.2.172 → vision_agent-0.2.174}/vision_agent/clients/landing_public_api.py +0 -0
- {vision_agent-0.2.172 → vision_agent-0.2.174}/vision_agent/fonts/__init__.py +0 -0
- {vision_agent-0.2.172 → vision_agent-0.2.174}/vision_agent/fonts/default_font_ch_en.ttf +0 -0
- {vision_agent-0.2.172 → vision_agent-0.2.174}/vision_agent/lmm/__init__.py +0 -0
- {vision_agent-0.2.172 → vision_agent-0.2.174}/vision_agent/lmm/lmm.py +0 -0
- {vision_agent-0.2.172 → vision_agent-0.2.174}/vision_agent/lmm/types.py +0 -0
- {vision_agent-0.2.172 → vision_agent-0.2.174}/vision_agent/tools/__init__.py +0 -0
- {vision_agent-0.2.172 → vision_agent-0.2.174}/vision_agent/tools/prompts.py +0 -0
- {vision_agent-0.2.172 → vision_agent-0.2.174}/vision_agent/tools/tool_utils.py +0 -0
- {vision_agent-0.2.172 → vision_agent-0.2.174}/vision_agent/tools/tools.py +0 -0
- {vision_agent-0.2.172 → vision_agent-0.2.174}/vision_agent/tools/tools_types.py +0 -0
- {vision_agent-0.2.172 → vision_agent-0.2.174}/vision_agent/utils/__init__.py +0 -0
- {vision_agent-0.2.172 → vision_agent-0.2.174}/vision_agent/utils/exceptions.py +0 -0
- {vision_agent-0.2.172 → vision_agent-0.2.174}/vision_agent/utils/execute.py +0 -0
- {vision_agent-0.2.172 → vision_agent-0.2.174}/vision_agent/utils/image_utils.py +0 -0
- {vision_agent-0.2.172 → vision_agent-0.2.174}/vision_agent/utils/sim.py +0 -0
- {vision_agent-0.2.172 → vision_agent-0.2.174}/vision_agent/utils/type_defs.py +0 -0
- {vision_agent-0.2.172 → vision_agent-0.2.174}/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.
|
3
|
+
Version: 0.2.174
|
4
4
|
Summary: Toolset for Vision Agent
|
5
5
|
Author: Landing AI
|
6
6
|
Author-email: dev@landing.ai
|
@@ -16,6 +16,7 @@ Requires-Dist: e2b-code-interpreter (==0.0.11a37)
|
|
16
16
|
Requires-Dist: flake8 (>=7.0.0,<8.0.0)
|
17
17
|
Requires-Dist: ipykernel (>=6.29.4,<7.0.0)
|
18
18
|
Requires-Dist: langsmith (>=0.1.58,<0.2.0)
|
19
|
+
Requires-Dist: libcst (>=1.5.0,<2.0.0)
|
19
20
|
Requires-Dist: nbclient (>=0.10.0,<0.11.0)
|
20
21
|
Requires-Dist: nbformat (>=5.10.4,<6.0.0)
|
21
22
|
Requires-Dist: numpy (>=1.21.0,<2.0.0)
|
@@ -27,7 +28,6 @@ Requires-Dist: pillow-heif (>=0.16.0,<0.17.0)
|
|
27
28
|
Requires-Dist: pydantic (==2.7.4)
|
28
29
|
Requires-Dist: pydantic-settings (>=2.2.1,<3.0.0)
|
29
30
|
Requires-Dist: pytube (==15.0.0)
|
30
|
-
Requires-Dist: redbaron (>=0.9.2,<0.10.0)
|
31
31
|
Requires-Dist: requests (>=2.0.0,<3.0.0)
|
32
32
|
Requires-Dist: rich (>=13.7.1,<14.0.0)
|
33
33
|
Requires-Dist: scipy (>=1.13.0,<1.14.0)
|
@@ -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.
|
7
|
+
version = "0.2.174"
|
8
8
|
description = "Toolset for Vision Agent"
|
9
9
|
authors = ["Landing AI <dev@landing.ai>"]
|
10
10
|
readme = "README.md"
|
@@ -43,7 +43,7 @@ pytube = "15.0.0"
|
|
43
43
|
anthropic = "^0.31.0"
|
44
44
|
pydantic = "2.7.4"
|
45
45
|
av = "^11.0.0"
|
46
|
-
|
46
|
+
libcst = "^1.5.0"
|
47
47
|
|
48
48
|
[tool.poetry.group.dev.dependencies]
|
49
49
|
autoflake = "1.*"
|
@@ -492,19 +492,10 @@ class VisionAgent(Agent):
|
|
492
492
|
}
|
493
493
|
)
|
494
494
|
|
495
|
+
code_action = response.get("execute_python", None)
|
495
496
|
# sometimes it gets stuck in a loop, so we force it to exit
|
496
497
|
if last_response == response:
|
497
498
|
response["let_user_respond"] = True
|
498
|
-
|
499
|
-
finished = response.get("let_user_respond", False)
|
500
|
-
|
501
|
-
code_action = response.get("execute_python", None)
|
502
|
-
if code_action is not None:
|
503
|
-
code_action = use_extra_vision_agent_args(
|
504
|
-
code_action, test_multi_plan, custom_tool_names
|
505
|
-
)
|
506
|
-
|
507
|
-
if last_response == response:
|
508
499
|
self.streaming_message(
|
509
500
|
{
|
510
501
|
"role": "assistant",
|
@@ -514,7 +505,7 @@ class VisionAgent(Agent):
|
|
514
505
|
"value": "Agent is stuck in conversation loop, exited",
|
515
506
|
"traceback_raw": [],
|
516
507
|
},
|
517
|
-
"finished":
|
508
|
+
"finished": code_action is None,
|
518
509
|
}
|
519
510
|
)
|
520
511
|
else:
|
@@ -524,10 +515,18 @@ class VisionAgent(Agent):
|
|
524
515
|
"content": new_format_to_old_format(
|
525
516
|
add_step_descriptions(response)
|
526
517
|
),
|
527
|
-
"finished":
|
518
|
+
"finished": response.get("let_user_respond", False)
|
519
|
+
and code_action is None,
|
528
520
|
}
|
529
521
|
)
|
530
522
|
|
523
|
+
finished = response.get("let_user_respond", False)
|
524
|
+
|
525
|
+
if code_action is not None:
|
526
|
+
code_action = use_extra_vision_agent_args(
|
527
|
+
code_action, test_multi_plan, custom_tool_names
|
528
|
+
)
|
529
|
+
|
531
530
|
if code_action is not None:
|
532
531
|
result, obs = execute_code_action(
|
533
532
|
artifacts,
|
@@ -5,7 +5,7 @@ import sys
|
|
5
5
|
from pathlib import Path
|
6
6
|
from typing import Any, Callable, Dict, List, Optional, Sequence, Union, cast
|
7
7
|
|
8
|
-
|
8
|
+
import libcst as cst
|
9
9
|
from tabulate import tabulate
|
10
10
|
|
11
11
|
import vision_agent.tools as T
|
@@ -49,42 +49,112 @@ WORKSPACE = Path(os.getenv("WORKSPACE", ""))
|
|
49
49
|
_LOGGER = logging.getLogger(__name__)
|
50
50
|
|
51
51
|
|
52
|
-
def strip_function_calls(
|
52
|
+
def strip_function_calls( # noqa: C901
|
53
|
+
code: str, exclusions: Optional[List[str]] = None
|
54
|
+
) -> str:
|
53
55
|
"""This will strip out all code that calls functions except for functions included
|
54
56
|
in exclusions.
|
55
57
|
"""
|
56
58
|
if exclusions is None:
|
57
59
|
exclusions = []
|
58
60
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
node.
|
86
|
-
|
87
|
-
|
61
|
+
def check_and_remove_node(node: cst.CSTNode, exclusions: List[str]) -> cst.CSTNode:
|
62
|
+
if hasattr(node, "value") and isinstance(node.value, cst.Call):
|
63
|
+
if (
|
64
|
+
isinstance(node.value.func, cst.Name)
|
65
|
+
and node.value.func.value in exclusions
|
66
|
+
):
|
67
|
+
return node
|
68
|
+
return cst.RemoveFromParent() # type: ignore
|
69
|
+
return node
|
70
|
+
|
71
|
+
class StripFunctionCallsTransformer(cst.CSTTransformer):
|
72
|
+
def __init__(self, exclusions: List[str]):
|
73
|
+
# Store exclusions to skip removing certain function calls
|
74
|
+
self.exclusions = exclusions
|
75
|
+
self.in_function_or_class = False
|
76
|
+
|
77
|
+
def visit_FunctionDef(self, node: cst.FunctionDef) -> Optional[bool]:
|
78
|
+
self.in_function_or_class = True
|
79
|
+
return True
|
80
|
+
|
81
|
+
def leave_FunctionDef(
|
82
|
+
self, original_node: cst.FunctionDef, updated_node: cst.FunctionDef
|
83
|
+
) -> cst.BaseStatement:
|
84
|
+
self.in_function_or_class = False
|
85
|
+
return updated_node
|
86
|
+
|
87
|
+
def visit_ClassDef(self, node: cst.ClassDef) -> Optional[bool]:
|
88
|
+
self.in_function_or_class = True
|
89
|
+
return True
|
90
|
+
|
91
|
+
def leave_ClassDef(
|
92
|
+
self, node: cst.ClassDef, updated_node: cst.ClassDef
|
93
|
+
) -> cst.BaseStatement:
|
94
|
+
self.in_function_or_class = False
|
95
|
+
return updated_node
|
96
|
+
|
97
|
+
def leave_Expr(
|
98
|
+
self, original_node: cst.Expr, updated_node: cst.Expr
|
99
|
+
) -> cst.Expr:
|
100
|
+
if not self.in_function_or_class:
|
101
|
+
return cast(
|
102
|
+
cst.Expr, check_and_remove_node(updated_node, self.exclusions)
|
103
|
+
)
|
104
|
+
return updated_node
|
105
|
+
|
106
|
+
def leave_Assign(
|
107
|
+
self, original_node: cst.Assign, updated_node: cst.Assign
|
108
|
+
) -> cst.Assign:
|
109
|
+
if not self.in_function_or_class:
|
110
|
+
return cast(
|
111
|
+
cst.Assign, check_and_remove_node(updated_node, self.exclusions)
|
112
|
+
)
|
113
|
+
return updated_node
|
114
|
+
|
115
|
+
def leave_If(self, original_node: cst.If, updated_node: cst.If) -> cst.If:
|
116
|
+
if not self.in_function_or_class:
|
117
|
+
return cast(
|
118
|
+
cst.If, check_and_remove_node(updated_node, self.exclusions)
|
119
|
+
)
|
120
|
+
return updated_node
|
121
|
+
|
122
|
+
def leave_For(self, original_node: cst.For, updated_node: cst.For) -> cst.For:
|
123
|
+
if not self.in_function_or_class:
|
124
|
+
return cast(
|
125
|
+
cst.For, check_and_remove_node(updated_node, self.exclusions)
|
126
|
+
)
|
127
|
+
return updated_node
|
128
|
+
|
129
|
+
def leave_While(
|
130
|
+
self, original_node: cst.While, updated_node: cst.While
|
131
|
+
) -> cst.While:
|
132
|
+
if not self.in_function_or_class:
|
133
|
+
return cast(
|
134
|
+
cst.While, check_and_remove_node(updated_node, self.exclusions)
|
135
|
+
)
|
136
|
+
return updated_node
|
137
|
+
|
138
|
+
def leave_With(
|
139
|
+
self, original_node: cst.With, updated_node: cst.With
|
140
|
+
) -> cst.With:
|
141
|
+
if not self.in_function_or_class:
|
142
|
+
return cast(
|
143
|
+
cst.With, check_and_remove_node(updated_node, self.exclusions)
|
144
|
+
)
|
145
|
+
return updated_node
|
146
|
+
|
147
|
+
def leave_Try(self, original_node: cst.Try, updated_node: cst.Try) -> cst.Try:
|
148
|
+
if not self.in_function_or_class:
|
149
|
+
return cast(
|
150
|
+
cst.Try, check_and_remove_node(updated_node, self.exclusions)
|
151
|
+
)
|
152
|
+
return updated_node
|
153
|
+
|
154
|
+
tree = cst.parse_module(code)
|
155
|
+
transformer = StripFunctionCallsTransformer(exclusions)
|
156
|
+
modified_tree = tree.visit(transformer)
|
157
|
+
return modified_tree.code
|
88
158
|
|
89
159
|
|
90
160
|
def write_code(
|
@@ -8,8 +8,8 @@ import tempfile
|
|
8
8
|
from pathlib import Path
|
9
9
|
from typing import Any, Dict, List, Optional, Union
|
10
10
|
|
11
|
+
import libcst as cst
|
11
12
|
from IPython.display import display
|
12
|
-
from redbaron import RedBaron # type: ignore
|
13
13
|
|
14
14
|
import vision_agent as va
|
15
15
|
from vision_agent.agent.agent_utils import extract_json
|
@@ -663,21 +663,79 @@ def use_extra_vision_agent_args(
|
|
663
663
|
Returns:
|
664
664
|
str: The edited code.
|
665
665
|
"""
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
666
|
+
|
667
|
+
class VisionAgentTransformer(cst.CSTTransformer):
|
668
|
+
def __init__(
|
669
|
+
self, test_multi_plan: bool, custom_tool_names: Optional[List[str]]
|
670
|
+
):
|
671
|
+
self.test_multi_plan = test_multi_plan
|
672
|
+
self.custom_tool_names = custom_tool_names
|
673
|
+
|
674
|
+
def leave_Call(
|
675
|
+
self, original_node: cst.Call, updated_node: cst.Call
|
676
|
+
) -> cst.Call:
|
677
|
+
# Check if the function being called is generate_vision_code or edit_vision_code
|
678
|
+
if isinstance(updated_node.func, cst.Name) and updated_node.func.value in [
|
679
|
+
"generate_vision_code",
|
680
|
+
"edit_vision_code",
|
681
|
+
]:
|
682
|
+
# Add test_multi_plan argument to generate_vision_code calls
|
683
|
+
if updated_node.func.value == "generate_vision_code":
|
684
|
+
new_arg = cst.Arg(
|
685
|
+
keyword=cst.Name("test_multi_plan"),
|
686
|
+
value=cst.Name(str(self.test_multi_plan)),
|
687
|
+
equal=cst.AssignEqual(
|
688
|
+
whitespace_before=cst.SimpleWhitespace(""),
|
689
|
+
whitespace_after=cst.SimpleWhitespace(""),
|
690
|
+
),
|
691
|
+
)
|
692
|
+
updated_node = updated_node.with_changes(
|
693
|
+
args=[*updated_node.args, new_arg]
|
694
|
+
)
|
695
|
+
|
696
|
+
# Add custom_tool_names if provided
|
697
|
+
if self.custom_tool_names is not None:
|
698
|
+
list_arg = []
|
699
|
+
for i, tool_name in enumerate(self.custom_tool_names):
|
700
|
+
if i < len(self.custom_tool_names) - 1:
|
701
|
+
list_arg.append(
|
702
|
+
cst._nodes.expression.Element(
|
703
|
+
value=cst.SimpleString(value=f'"{tool_name}"'),
|
704
|
+
comma=cst.Comma(
|
705
|
+
whitespace_before=cst.SimpleWhitespace(""),
|
706
|
+
whitespace_after=cst.SimpleWhitespace(" "),
|
707
|
+
),
|
708
|
+
)
|
709
|
+
)
|
710
|
+
else:
|
711
|
+
list_arg.append(
|
712
|
+
cst._nodes.expression.Element(
|
713
|
+
value=cst.SimpleString(value=f'"{tool_name}"'),
|
714
|
+
)
|
715
|
+
)
|
716
|
+
new_arg = cst.Arg(
|
717
|
+
keyword=cst.Name("custom_tool_names"),
|
718
|
+
value=cst.List(list_arg),
|
719
|
+
equal=cst.AssignEqual(
|
720
|
+
whitespace_before=cst.SimpleWhitespace(""),
|
721
|
+
whitespace_after=cst.SimpleWhitespace(""),
|
722
|
+
),
|
723
|
+
)
|
724
|
+
updated_node = updated_node.with_changes(
|
725
|
+
args=[*updated_node.args, new_arg]
|
726
|
+
)
|
727
|
+
|
728
|
+
return updated_node
|
729
|
+
|
730
|
+
# Parse the input code into a CST node
|
731
|
+
tree = cst.parse_module(code)
|
732
|
+
|
733
|
+
# Apply the transformer to modify the CST
|
734
|
+
transformer = VisionAgentTransformer(test_multi_plan, custom_tool_names)
|
735
|
+
modified_tree = tree.visit(transformer)
|
736
|
+
|
737
|
+
# Return the modified code as a string
|
738
|
+
return modified_tree.code
|
681
739
|
|
682
740
|
|
683
741
|
def use_object_detection_fine_tuning(
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{vision_agent-0.2.172 → vision_agent-0.2.174}/vision_agent/agent/vision_agent_coder_prompts.py
RENAMED
File without changes
|
File without changes
|
{vision_agent-0.2.172 → vision_agent-0.2.174}/vision_agent/agent/vision_agent_planner_prompts.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
|