vision-agent 0.2.112__py3-none-any.whl → 0.2.113__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
@@ -128,7 +128,11 @@ def write_plans(
128
128
 
129
129
  user_request = chat[-1]["content"]
130
130
  context = USER_REQ.format(user_request=user_request)
131
- prompt = PLAN.format(context=context, tool_desc=tool_desc, feedback=working_memory)
131
+ prompt = PLAN.format(
132
+ context=context,
133
+ tool_desc=tool_desc,
134
+ feedback=working_memory,
135
+ )
132
136
  chat[-1]["content"] = prompt
133
137
  return extract_json(model(chat, stream=False)) # type: ignore
134
138
 
@@ -674,6 +678,7 @@ class VisionAgentCoder(Agent):
674
678
  chat: List[Message],
675
679
  test_multi_plan: bool = True,
676
680
  display_visualization: bool = False,
681
+ customized_tool_names: Optional[List[str]] = None,
677
682
  ) -> Dict[str, Any]:
678
683
  """Chat with VisionAgentCoder and return intermediate information regarding the
679
684
  task.
@@ -689,6 +694,8 @@ class VisionAgentCoder(Agent):
689
694
  with the first plan.
690
695
  display_visualization (bool): If True, it opens a new window locally to
691
696
  show the image(s) created by visualization code (if there is any).
697
+ customized_tool_names (List[str]): A list of customized tools for agent to pick and use.
698
+ If not provided, default to full tool set from vision_agent.tools.
692
699
 
693
700
  Returns:
694
701
  Dict[str, Any]: A dictionary containing the code, test, test result, plan,
@@ -742,7 +749,9 @@ class VisionAgentCoder(Agent):
742
749
  )
743
750
  plans = write_plans(
744
751
  int_chat,
745
- T.TOOL_DESCRIPTIONS,
752
+ T.get_tool_descriptions_by_names(
753
+ customized_tool_names, T.FUNCTION_TOOLS, T.UTIL_TOOLS # type: ignore
754
+ ),
746
755
  format_memory(working_memory),
747
756
  self.planner,
748
757
  )
@@ -754,7 +763,6 @@ class VisionAgentCoder(Agent):
754
763
  _LOGGER.info(
755
764
  f"\n{tabulate(tabular_data=p_fixed, headers='keys', tablefmt='mixed_grid', maxcolwidths=_MAX_TABULATE_COL_WIDTH)}"
756
765
  )
757
-
758
766
  tool_infos = retrieve_tools(
759
767
  plans,
760
768
  self.tool_recommender,
@@ -1,15 +1,16 @@
1
1
  from typing import Callable, List, Optional
2
2
 
3
- from .meta_tools import (
4
- META_TOOL_DOCSTRING,
5
- )
3
+ from .meta_tools import META_TOOL_DOCSTRING
6
4
  from .prompts import CHOOSE_PARAMS, SYSTEM_PROMPT
5
+ from .tool_utils import get_tool_descriptions_by_names
7
6
  from .tools import (
7
+ FUNCTION_TOOLS,
8
8
  TOOL_DESCRIPTIONS,
9
9
  TOOL_DOCSTRING,
10
10
  TOOLS,
11
11
  TOOLS_DF,
12
12
  TOOLS_INFO,
13
+ UTIL_TOOLS,
13
14
  UTILITIES_DOCSTRING,
14
15
  blip_image_caption,
15
16
  clip,
@@ -142,6 +142,31 @@ def get_tool_descriptions(funcs: List[Callable[..., Any]]) -> str:
142
142
  return descriptions
143
143
 
144
144
 
145
+ def get_tool_descriptions_by_names(
146
+ tool_name: Optional[List[str]],
147
+ funcs: List[Callable[..., Any]],
148
+ util_funcs: List[
149
+ Callable[..., Any]
150
+ ], # util_funcs will always be added to the list of functions
151
+ ) -> str:
152
+ if tool_name is None:
153
+ return get_tool_descriptions(funcs + util_funcs)
154
+
155
+ invalid_names = [
156
+ name for name in tool_name if name not in {func.__name__ for func in funcs}
157
+ ]
158
+
159
+ if invalid_names:
160
+ raise ValueError(f"Invalid customized tool names: {', '.join(invalid_names)}")
161
+
162
+ filtered_funcs = (
163
+ funcs
164
+ if not tool_name
165
+ else [func for func in funcs if func.__name__ in tool_name]
166
+ )
167
+ return get_tool_descriptions(filtered_funcs + util_funcs)
168
+
169
+
145
170
  def get_tools_df(funcs: List[Callable[..., Any]]) -> pd.DataFrame:
146
171
  data: Dict[str, List[str]] = {"desc": [], "doc": []}
147
172
 
@@ -1650,7 +1650,7 @@ def florencev2_fine_tuned_object_detection(
1650
1650
  return return_data
1651
1651
 
1652
1652
 
1653
- TOOLS = [
1653
+ FUNCTION_TOOLS = [
1654
1654
  owl_v2,
1655
1655
  extract_frames,
1656
1656
  ocr,
@@ -1671,6 +1671,9 @@ TOOLS = [
1671
1671
  generate_pose_image,
1672
1672
  closest_mask_distance,
1673
1673
  closest_box_distance,
1674
+ ]
1675
+
1676
+ UTIL_TOOLS = [
1674
1677
  save_json,
1675
1678
  load_image,
1676
1679
  save_image,
@@ -1679,6 +1682,9 @@ TOOLS = [
1679
1682
  overlay_segmentation_masks,
1680
1683
  overlay_heat_map,
1681
1684
  ]
1685
+
1686
+ TOOLS = FUNCTION_TOOLS + UTIL_TOOLS
1687
+
1682
1688
  TOOLS_DF = get_tools_df(TOOLS) # type: ignore
1683
1689
  TOOL_DESCRIPTIONS = get_tool_descriptions(TOOLS) # type: ignore
1684
1690
  TOOL_DOCSTRING = get_tool_documentation(TOOLS) # type: ignore
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: vision-agent
3
- Version: 0.2.112
3
+ Version: 0.2.113
4
4
  Summary: Toolset for Vision Agent
5
5
  Author: Landing AI
6
6
  Author-email: dev@landing.ai
@@ -3,7 +3,7 @@ vision_agent/agent/__init__.py,sha256=qpduQ9YufJQfMmG6jwKC2xmlbtR2qK8_1eQC1sGA9K
3
3
  vision_agent/agent/agent.py,sha256=Bt8yhjCFXuRdZaHxKEesG40V09nWRt45sZluri1R3AA,575
4
4
  vision_agent/agent/agent_utils.py,sha256=ArHrmHIEkWxkxkUHm0WH7pOnWqqoOvNdTrgIpl-DAow,1124
5
5
  vision_agent/agent/vision_agent.py,sha256=5rgO-pScVOS3t4sWnLBnGYYkGftGgF4U0FpZzFVrDAY,8447
6
- vision_agent/agent/vision_agent_coder.py,sha256=HaIOxPQajP2CJT7TbffSkz0MDbYxEs6_P9Ykz71nkUc,31209
6
+ vision_agent/agent/vision_agent_coder.py,sha256=LuwqDIFOincCu6md6y1QEM8oiV1KXD70vcrBu5inc-E,31604
7
7
  vision_agent/agent/vision_agent_coder_prompts.py,sha256=xIya1txRZM8qoQHAWTEkEFCL8L3iZD7QD09t3ZtdxSE,11305
8
8
  vision_agent/agent/vision_agent_prompts.py,sha256=ydUU_Wvw-jqdL_vObSUr-VCQvjSwA5Fd74TbbhUzyxk,6112
9
9
  vision_agent/clients/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -14,11 +14,11 @@ vision_agent/fonts/default_font_ch_en.ttf,sha256=1YM0Z3XqLDjSNbF7ihQFSAIUdjF9m1r
14
14
  vision_agent/lmm/__init__.py,sha256=YuUZRsMHdn8cMOv6iBU8yUqlIOLrbZQqZl9KPnofsHQ,103
15
15
  vision_agent/lmm/lmm.py,sha256=TgEwrtQqpnWlBYEvsSU6DbkY3Y7MM8wRb4lMQgSiM0k,19435
16
16
  vision_agent/lmm/types.py,sha256=8TSRoTbXyCKVJiH-wHXI2OiGOMSkYv1vLGYeAXtNpOQ,153
17
- vision_agent/tools/__init__.py,sha256=lyD7X-CXS4215K8mPXrzEoFVDHeQaNYn6KSn_uVoxlY,2108
17
+ vision_agent/tools/__init__.py,sha256=Y6Y7McmdC8cm6UsJgExBLEPi4StBkqfY4y8_Mp7LlWU,2190
18
18
  vision_agent/tools/meta_tools.py,sha256=q6h7hZarZrsWRloVE6PbTZwW8J2N1uUM9Ac-XxsT6hk,13365
19
19
  vision_agent/tools/prompts.py,sha256=V1z4YJLXZuUl_iZ5rY0M5hHc_2tmMEUKr0WocXKGt4E,1430
20
- vision_agent/tools/tool_utils.py,sha256=1_ZnBubUctJYTv3GsSzRJ6cbQ0Y42yolBvehs6dZYao,5762
21
- vision_agent/tools/tools.py,sha256=F3bf7uL84p4Cfe2b8ek-KSeWgABkUccvsdwBi3CgTCM,58561
20
+ vision_agent/tools/tool_utils.py,sha256=qMsb9d8QtpXGgF9rpPO2dA390BewKdYO68oWKDu-TGg,6504
21
+ vision_agent/tools/tools.py,sha256=JscejDn05jpYW6psPkRDesegPtZJshNWCncGFPOpI7c,58626
22
22
  vision_agent/tools/tools_types.py,sha256=z6_XtUhWgh201yM7Z0CYtiLBEGdHPc_QUydMDHZ84EA,2216
23
23
  vision_agent/utils/__init__.py,sha256=CW84HnhqI6XQVuxf2KifkLnSuO7EOhmuL09-gAymAak,219
24
24
  vision_agent/utils/exceptions.py,sha256=booSPSuoULF7OXRr_YbC4dtKt6gM_HyiFQHBuaW86C4,2052
@@ -27,7 +27,7 @@ vision_agent/utils/image_utils.py,sha256=c1LrmaHD331za8DbA1myJpgUmWoDzePaOK6-dsd
27
27
  vision_agent/utils/sim.py,sha256=7JvtWGN0Ik5ife3qQYWs7Fm3T8AnAXGFd5HnvDC15mQ,4433
28
28
  vision_agent/utils/type_defs.py,sha256=BE12s3JNQy36QvauXHjwyeffVh5enfcvd4vTzSwvEZI,1384
29
29
  vision_agent/utils/video.py,sha256=rNmU9KEIkZB5-EztZNlUiKYN0mm_55A_2VGUM0QpqLA,8779
30
- vision_agent-0.2.112.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
31
- vision_agent-0.2.112.dist-info/METADATA,sha256=XBqbIsjZ128JvvmHvwKFkCP6-8MCpmZRsjr7osRdqGU,10732
32
- vision_agent-0.2.112.dist-info/WHEEL,sha256=7Z8_27uaHI_UZAc4Uox4PpBhQ9Y5_modZXWMxtUi4NU,88
33
- vision_agent-0.2.112.dist-info/RECORD,,
30
+ vision_agent-0.2.113.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
31
+ vision_agent-0.2.113.dist-info/METADATA,sha256=LqtIm3in007iaat5hJSRPB02YBKQTPZxL27m_69d7r4,10732
32
+ vision_agent-0.2.113.dist-info/WHEEL,sha256=7Z8_27uaHI_UZAc4Uox4PpBhQ9Y5_modZXWMxtUi4NU,88
33
+ vision_agent-0.2.113.dist-info/RECORD,,