Update my_tools.py
Browse files123456from smolagents import DuckDuckGoSearchTool, PythonInterpreterToolmy_tool_list = [DuckDuckGoSearchTool(), # 用来查网页PythonInterpreterTool(), # 可以跑代码、算数、分析 CSV]1234567891011121314151617181920212223from smolagents import DuckDuckGoSearchTool, Toolimport wikipediaapiclass WikipediaSearchTool(Tool):name = "wikipedia_search"description = "查找英文维基百科的页面简介,输入应为一个词或短词组"inputs = {"query": {"type": "string", "description": "维基百科搜索关键词,例如人名/专名"}}output_type = "string"def __init__(self, lang="en"):super().__init__()self.wiki = wikipediaapi.Wikipedia(language=lang, user_agent="celum")def forward(self, query: str):page = self.wiki.page(query)if not page.exists():return "No Wikipedia page found."return page.summary[:1000]wiki_tool = WikipediaSearchTool()ddg_tool = DuckDuckGoSearchTool() # smolagents 自带my_tool_list = [wiki_tool, ddg_tool]
my_tools.py+22-5