175 lines
11 KiB
Python
175 lines
11 KiB
Python
|
|
from langchain.tools import Tool
|
|||
|
|
from server.agent.tools import *
|
|||
|
|
from server.agent.tools import rag_search1
|
|||
|
|
from server.agent.tools import duckduckgo_search
|
|||
|
|
from server.agent.tools.do_nothing import do_nothing, doNothingInput, get_next_tip
|
|||
|
|
from server.agent.tools.draw_plot import create_and_save_plot, draw_ink_pic, draw_realistic_pic, drawInkInput, drawPlotInput, drawRealisticInput
|
|||
|
|
from server.agent.tools.get_statistical_data import mysql_statistic
|
|||
|
|
from server.agent.tools.math import code_count, math_count
|
|||
|
|
from server.agent.tools.search_picture import search_pic
|
|||
|
|
from server.agent.tools.search_tool import search_tool
|
|||
|
|
|
|||
|
|
# 请注意,如果你是为了使用AgentLM,在这里,你应该使用英文版本。
|
|||
|
|
|
|||
|
|
tools = [
|
|||
|
|
# Tool.from_function(
|
|||
|
|
# func=calculate,
|
|||
|
|
# name="calculate",
|
|||
|
|
# description="Useful for when you need to answer questions about simple calculations",
|
|||
|
|
# args_schema=CalculatorInput,
|
|||
|
|
# ),
|
|||
|
|
# Tool.from_function(
|
|||
|
|
# func=arxiv,
|
|||
|
|
# name="arxiv",
|
|||
|
|
# description="A wrapper around Arxiv.org for the original English paper.",
|
|||
|
|
# args_schema=ArxivInput,
|
|||
|
|
# ),
|
|||
|
|
# Tool.from_function(
|
|||
|
|
# func=weathercheck,
|
|||
|
|
# name="weather_check",
|
|||
|
|
# description="",
|
|||
|
|
# args_schema=WeatherInput,
|
|||
|
|
# ),
|
|||
|
|
# Tool.from_function(
|
|||
|
|
# func=shell,
|
|||
|
|
# name="shell",
|
|||
|
|
# description="Use Shell to execute Linux commands",
|
|||
|
|
# args_schema=ShellInput,
|
|||
|
|
# ),
|
|||
|
|
# Tool.from_function(
|
|||
|
|
# func=search_knowledgebase_complex,
|
|||
|
|
# name="search_knowledgebase_complex",
|
|||
|
|
# description="Use this tool to check out local knowledgebase",
|
|||
|
|
# args_schema=KnowledgeSearchInput,
|
|||
|
|
# ),
|
|||
|
|
# Tool.from_function(
|
|||
|
|
# func=search_internet,
|
|||
|
|
# name="search_internet",
|
|||
|
|
# description="Use this tool to search the internet and retrieve information",
|
|||
|
|
# args_schema=SearchInternetInput,
|
|||
|
|
# ),
|
|||
|
|
# Tool.from_function(
|
|||
|
|
# func=wolfram,
|
|||
|
|
# name="Wolfram",
|
|||
|
|
# description="Useful for when you need to calculate difficult formulas",
|
|||
|
|
# args_schema=WolframInput,
|
|||
|
|
# ),
|
|||
|
|
# Tool.from_function(
|
|||
|
|
# func=search_youtube,
|
|||
|
|
# name="search_youtube",
|
|||
|
|
# description="use this tools to get videos",
|
|||
|
|
# args_schema=YoutubeInput,
|
|||
|
|
# ),
|
|||
|
|
# Tool.from_function(
|
|||
|
|
# func=chat_with_Yi34B,
|
|||
|
|
# name="chat_with_Yi34B",
|
|||
|
|
# description="Use this tool to chat",
|
|||
|
|
# args_schema=ChatWithYi34BInput,
|
|||
|
|
# ),
|
|||
|
|
|
|||
|
|
Tool.from_function(
|
|||
|
|
func=search_tool,
|
|||
|
|
name="知识库联想",
|
|||
|
|
# description="\n【工具参数说明】:\n 参数格式:参数需以逗号分隔,并以JSON格式提供\n 必需参数:\n 1. query:查询内容。\n2.knowledge_name:知识库名称,例如 政策库、项目库、期刊论文库、冶金行业新闻库、冶金专业知识库、冶金行业报告库\\n3.keywords【使用指南】:\n当需要利用文献资源辅助回答问题时,请使用此工具。\n输入必须包含三个参数:query、knowledge_name 和 keywords\nknowledge_name 必须是以下之一:政策库、期刊论文库、新闻库。\nkeywords 应尽可能多地涵盖相关领域,并确保与搜索主题高度相关。\n尽量提供中文关键词。\n示例:\n{\"knowledge_name\":\"政策库\",\"keywords\": [\"technology\", \"era\"]\n确保所有参数以JSON格式提供,以便工具能够正确解析和使用}",
|
|||
|
|
description="\n【参数说明】:\n 参数格式:参数必须使用JSON格式提供\n 必需参数:\n 1. query:查询内容。\n2.knowledge_name:知识库名称:必须从【中国钢铁行业动态库、政策库、期刊论文库、冶金新闻库(2024年以及之前)、冶金中文期刊库、冶金外文期刊库、冶金OA期刊库、冶金行业新闻库、冶金专业知识库、冶金行业报告库、报告库、美术专业知识库】中选择\n3.keywords:与搜索主题高度相关\n【使用指南】:\n当需要利用文献资源辅助回答问题时,请使用此工具。\n输入必须包含三个参数:{\"knowledge_name\":[\"XXX\",\"XXX\"],\"query\":\"XXX\",\"keywords\":[\"XXX\", \"XXX\", \"XXX\", \"XXX\"]}\n示例:\n{\"query\":\"人工智能的相关政策\",\"knowledge_name\":[\"政策库\"],\"keywords\": [\"人工智能\", \"国家级\"]}\n务必以JSON格式输入参数,以便工具能够正确解析和使用。",
|
|||
|
|
args_schema=RagSearchInput
|
|||
|
|
),
|
|||
|
|
Tool.from_function(
|
|||
|
|
func=knowledgebase_kgo_search,
|
|||
|
|
name="联网思索",
|
|||
|
|
description="\n【参数说明】:参数格式:以JSON格式提供,参数为:query\n query 为【user input】的原文,例如:\n{\"query\":\"人工智能是什么\"}\n注意!禁止改写【user input】的内容",
|
|||
|
|
# description="提示:联网思索工具仅供娱乐,名词解释,或知识库联想无法满足需求时才使用\n【参数说明】:参数格式:以JSON格式提供,参数为:query\n query 为【user input】的原文,例如:\n{\"query\":\"人工智能是什么\"}\n注意!禁止改写【user input】的内容",
|
|||
|
|
args_schema=KnowledgeKgoInput
|
|||
|
|
),
|
|||
|
|
# Tool.from_function(
|
|||
|
|
# func=duckduckgo_search,
|
|||
|
|
# name="联网思索",
|
|||
|
|
# description="【参数说明】:参数格式:必须以JSON格式提供\n必需参数:\n1.query:查询内容(如:\"粉末冶金\")。\n可选参数:\n2.time:查询时间范围(例如 \"m\" 表示过去一个月,\"w\" 表示过去一周,不传则默认 \"d\")\n3.resource_type:资源类型控制\n - \"default\" 或不传该参数:检索所有资源\n - \"video\":用户明确要求检索视频的时候,检索视频 - \"limit\":查询资料数量,如果用户没有明确要求,默认传3 \n\n【使用示例】:\n{\"query\":\"人工智能\",\"time\":\"m\",\"resource_type\":\"default\",\"limit\":3}\n确保参数以JSO-N格式提供,以便正确解析和使用。",
|
|||
|
|
# args_schema=DuckduckgoInput
|
|||
|
|
# ),
|
|||
|
|
# Tool.from_function(
|
|||
|
|
# func=do_nothing,
|
|||
|
|
# name="无需调用工具",
|
|||
|
|
# description="不需要使用工具的时候调用本方法以获取指示",
|
|||
|
|
# args_schema=doNothingInput
|
|||
|
|
# ),
|
|||
|
|
# Tool.from_function(
|
|||
|
|
# func=get_next_tip,
|
|||
|
|
# name="环节跳转",
|
|||
|
|
# description="第一阶段结束获取第二阶段提示",
|
|||
|
|
# args_schema=doNothingInput
|
|||
|
|
# ),
|
|||
|
|
Tool.from_function(
|
|||
|
|
func=create_and_save_plot,
|
|||
|
|
name="图表绘制",
|
|||
|
|
description="注意本工具一次只能画一张图<关键指令>使用本工具后你必须按工具返回要求输出图片</关键指令>【参数说明】:参数以<param></param>标签包裹。必须提供以下参数格式: 必需参数:\n 1. data:图表数据格式如下{\"XXX\": XX, \"XXX\": XX, \"XXX\": X, \"XXX\": X}其中XXX代表分类名称,xx代表分类数据量。\n2.title:图表标题3.xlabel:横轴标题(你按照分的几类属于哪个大类)必须有\n4.ylabel:纵轴标题(你的数值数据是什么)必须有\n 5.plot_type:图表类型必须从以下几个当中选一个作为输入【bar,pie,line】其中bar代表柱状图pie代表饼图line代表折线图你只能选一个作为输入,\n【使用指南】:\n当需要生成图表时,请使用此工具。\n输入必须包含以下参数::<tool_input><param>{\n\"data\": {\"XXX\": XX, \"XXX\": XX, \"XXX\": X, \"XXX\": X},\"title\": \"X\",\"xlabel\": \"X\",\"ylabel\": \"X\",\"plot_type\": \"X\"}\n示例:{'\"data\": {\"Category A\": 23, \"Category B\": 17, \"Category C\": 35, \"Category D\": 29},\"title\": \"My Chart\",\"xlabel\": \"Category\",\"ylabel\": \"Value\",\"plot_type\": \"pie\"}</param></tool_input>\n请务必以json格式输入方便使用。\n",
|
|||
|
|
args_schema=drawPlotInput
|
|||
|
|
),
|
|||
|
|
|
|||
|
|
Tool.from_function(
|
|||
|
|
func=math_count,
|
|||
|
|
name="数学运算",
|
|||
|
|
description="【参数说明】:参数格式:以JSON格式提供,参数为:query\n query 为数学问题描述,例如:\n{\"query\":\"9.9和9.11谁大\"}\n",
|
|||
|
|
args_schema=drawPlotInput
|
|||
|
|
),
|
|||
|
|
Tool.from_function(
|
|||
|
|
func=code_count,
|
|||
|
|
name="代码专家",
|
|||
|
|
description="【参数说明】:参数格式:以JSON格式提供,参数为:query\n query 为代码问题描述,例如:\n{\"query\":\"写一个es增量数据处理的脚本\"}\n",
|
|||
|
|
args_schema=drawPlotInput
|
|||
|
|
),
|
|||
|
|
Tool.from_function(
|
|||
|
|
func=weathercheck,
|
|||
|
|
name="天气工具",
|
|||
|
|
description="【参数说明】:注意:仅支持三天内天气查询,参数格式:以JSON格式提供,参数为:location\n location 为查询天气的城市名称,例如:\n{\"location\":\"北京\"}\n",
|
|||
|
|
args_schema=drawPlotInput
|
|||
|
|
),
|
|||
|
|
Tool.from_function(
|
|||
|
|
func=search_pic,
|
|||
|
|
name="美术作品获取",
|
|||
|
|
description="【参数说明】:参数格式:以JSON格式提供,参数为:query\n query 为查询美术作品的描述,务必是美术作品的描述,不要直接输入美术作品四个字而是如山水画写生画,草原,太阳等等,例如:\n{\"query\":\"山水画\"}\n,需将该工具返回的图片链接以markdown格式给出",
|
|||
|
|
args_schema=drawPlotInput
|
|||
|
|
),
|
|||
|
|
Tool.from_function(
|
|||
|
|
func=mysql_statistic,
|
|||
|
|
name="统计数据查询",
|
|||
|
|
description="提示统计库数据最多只有2023年及之前的199几年的最多【参数说明】:参数格式:以JSON格式提供,并必须以<param></param>标签包裹。参数为:query\n query 为详细的查询问题例如:\n<tool_input> <param>{\"query\":\"原油出口统计数据\"}</param> </tool_input>\n,需将返回数据做成数据表和图表",
|
|||
|
|
args_schema=drawPlotInput
|
|||
|
|
),
|
|||
|
|
# Tool.from_function(
|
|||
|
|
# func=draw_realistic_pic,
|
|||
|
|
# name="实景绘制",
|
|||
|
|
# description="【参数说明】:参数格式:以JSON格式提供,参数为:query\n query 为图片需求描述,例如:\n{\"query\":\"画一张风景图\"}\n",
|
|||
|
|
# args_schema=drawRealisticInput
|
|||
|
|
# ),
|
|||
|
|
# Tool.from_function(
|
|||
|
|
# func=draw_ink_pic,
|
|||
|
|
# name="水墨画绘制",
|
|||
|
|
# description="【参数说明】:参数格式:以JSON格式提供,参数为:query\n query 为图片需求描述,例如:\n{\"query\":\"画一个红苹果\"}\n",
|
|||
|
|
# args_schema=drawInkInput
|
|||
|
|
# ),
|
|||
|
|
|
|||
|
|
# Tool.from_function(
|
|||
|
|
# func=rag_search1,
|
|||
|
|
# name="rag_search",
|
|||
|
|
# description="Use this tool to search for relevant information in the policy knowledge base, with the query is the user's questions ,with the knowledge base name being t_policy_total_bge_new_v2.",
|
|||
|
|
# args_schema=RagSearchInput,
|
|||
|
|
# ),
|
|||
|
|
# Tool.from_function(
|
|||
|
|
# func=policy_knowledgebase_search,
|
|||
|
|
# name="policy_knowledgebase",
|
|||
|
|
# description="Use this tool to search for policy knowledge base",
|
|||
|
|
# args_schema=PolicyKnowledgeInput,
|
|||
|
|
# ),
|
|||
|
|
# Tool.from_function(
|
|||
|
|
# func=report_knowledgebase_search,
|
|||
|
|
# name="report_knowledgebase",
|
|||
|
|
# description="Use this tool to search for report knowledge base",
|
|||
|
|
# args_schema=ReportKnowledgeInput,
|
|||
|
|
# ),
|
|||
|
|
]
|
|||
|
|
|
|||
|
|
tool_names = [tool.name for tool in tools]
|
|||
|
|
# 网络搜索工具
|
|||
|
|
search_tool_names = [search_internet for tool in tools]
|