高级 API¶
列出可用的工具¶
- agentlego.apis.list_tools(with_description=False)[源代码]
List all the registered tools.
- 参数:
with_description (bool) – Whether to return the description of tools. Defaults to False.
- 返回:
list of tool names by default, or list of tuples (tool_name, description) if
with_description=True.- 返回类型:
示例
>>> from agentlego import list_tools >>> # list all tools with description >>> for name, description in list_tools(with_description=True): ... print(name, description)
根据类名加载工具¶
- agentlego.apis.load_tool(tool_type, name=None, description=None, device=None, **kwargs)[源代码]
Load a configurable callable tool for different task.
- 参数:
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.
- 返回:
The constructed tool.
- 返回类型:
BaseTool
示例
>>> from agentlego import load_tool >>> # load tool with tool name >>> tool, meta = load_tool('GoogleSearch', with_url=True)
搜索工具¶
- agentlego.search.search_tool(query, kind='thefuzz', topk=5)[源代码]
Search several proper tools according to the query.
- 参数:
示例
>>> 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')