High-level APIs¶
List available tools¶
- agentlego.apis.list_tools(with_description=False)[source]
List all the registered tools.
- Parameters:
with_description (bool) – Whether to return the description of tools. Defaults to False.
- Returns:
list of tool names by default, or list of tuples (tool_name, description) if
with_description=True.- Return type:
Examples
>>> from agentlego import list_tools >>> # list all tools with description >>> for name, description in list_tools(with_description=True): ... print(name, description)
Load a tool by class name¶
- agentlego.apis.load_tool(tool_type, name=None, description=None, device=None, **kwargs)[source]
Load a configurable callable tool for different task.
- Parameters:
tool_name (str) – tool name for specific task. You can find more description about supported tools by
list_tools().name (str | None) – The name to override the default name. Defaults to None.
description (str) – The description to override the default description. Defaults to None.
device (str) – The device to load the tool. Defaults to None.
**kwargs – key-word arguments to build the specific tools. These arguments are related
tool. You can find the arguments of the specific tool type according to the given tool in the documentations of the tools.
- Returns:
The constructed tool.
- Return type:
BaseTool
Examples
>>> from agentlego import load_tool >>> # load tool with tool name >>> tool, meta = load_tool('GoogleSearch', with_url=True)
Search tools¶
- agentlego.search.search_tool(query, kind='thefuzz', topk=5)[source]
Search several proper tools according to the query.
- Parameters:
Examples
>>> from agentlego import search_tool >>> # use the thefuzz to search tools >>> search_tool('human pose') >>> # use the openai API to search tools >>> search_tool('human pose', kind='openai') >>> # use the sentence-transformers to search tools >>> search_tool('human pose', kind='st')