From 66ed891a72657e0fc29d70dc6a3cd4d6ec4e7266 Mon Sep 17 00:00:00 2001 From: wuyiqunLu <132986242+wuyiqunLu@users.noreply.github.com> Date: Mon, 26 Aug 2024 15:14:42 +0800 Subject: [PATCH 1/2] feat: add dict to map func name to func docstring (#209) --- vision_agent/tools/__init__.py | 6 ++++-- vision_agent/tools/tool_utils.py | 13 +++++++++++++ vision_agent/tools/tools.py | 2 ++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/vision_agent/tools/__init__.py b/vision_agent/tools/__init__.py index f9879626..51868dd9 100644 --- a/vision_agent/tools/__init__.py +++ b/vision_agent/tools/__init__.py @@ -7,6 +7,7 @@ TOOL_DOCSTRING, TOOLS, TOOLS_DF, + TOOLS_INFO, UTILITIES_DOCSTRING, blip_image_caption, clip, @@ -52,15 +53,16 @@ def register_tool(imports: Optional[List] = None) -> Callable: def decorator(tool: Callable) -> Callable: import inspect - from .tools import get_tool_descriptions, get_tools_df + from .tools import get_tool_descriptions, get_tools_df, get_tools_info - global TOOLS, TOOLS_DF, TOOL_DESCRIPTIONS, TOOL_DOCSTRING + global TOOLS, TOOLS_DF, TOOL_DESCRIPTIONS, TOOL_DOCSTRING, TOOLS_INFO if tool not in TOOLS: TOOLS.append(tool) TOOLS_DF = get_tools_df(TOOLS) # type: ignore TOOL_DESCRIPTIONS = get_tool_descriptions(TOOLS) # type: ignore TOOL_DOCSTRING = get_tool_documentation(TOOLS) # type: ignore + TOOLS_INFO = get_tools_info(TOOLS) # type: ignore globals()[tool.__name__] = tool if imports is not None: diff --git a/vision_agent/tools/tool_utils.py b/vision_agent/tools/tool_utils.py index 0ff56177..fda89526 100644 --- a/vision_agent/tools/tool_utils.py +++ b/vision_agent/tools/tool_utils.py @@ -142,3 +142,16 @@ def get_tools_df(funcs: List[Callable[..., Any]]) -> pd.DataFrame: data["doc"].append(doc) return pd.DataFrame(data) # type: ignore + + +def get_tools_info(funcs: List[Callable[..., Any]]) -> Dict[str, str]: + data: Dict[str, str] = {} + + for func in funcs: + desc = func.__doc__ + if desc is None: + desc = "" + + data[func.__name__] = f"{func.__name__}{inspect.signature(func)}:\n{desc}" + + return data diff --git a/vision_agent/tools/tools.py b/vision_agent/tools/tools.py index 0254a455..3070f1f2 100644 --- a/vision_agent/tools/tools.py +++ b/vision_agent/tools/tools.py @@ -19,6 +19,7 @@ get_tool_descriptions, get_tool_documentation, get_tools_df, + get_tools_info, ) from vision_agent.utils import extract_frames_from_video from vision_agent.utils.execute import FileSerializer, MimeType @@ -1317,6 +1318,7 @@ def overlay_heat_map( TOOLS_DF = get_tools_df(TOOLS) # type: ignore TOOL_DESCRIPTIONS = get_tool_descriptions(TOOLS) # type: ignore TOOL_DOCSTRING = get_tool_documentation(TOOLS) # type: ignore +TOOLS_INFO = get_tools_info(TOOLS) # type: ignore UTILITIES_DOCSTRING = get_tool_documentation( [ save_json, From 58115951f8a050c9f9f7be2012efe97ec00498ed Mon Sep 17 00:00:00 2001 From: GitHub Actions Bot Date: Mon, 26 Aug 2024 07:17:22 +0000 Subject: [PATCH 2/2] [skip ci] chore(release): vision-agent 0.2.110 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index e840301e..897791d2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api" [tool.poetry] name = "vision-agent" -version = "0.2.109" +version = "0.2.110" description = "Toolset for Vision Agent" authors = ["Landing AI "] readme = "README.md"