- 实现了基于LangChain的MCP Agent,支持连接MCP服务器调用工具 - 添加了环境配置文件(.env),包含LLM模型和API配置信息 - 创建了完整的工具系统,包括BaseTool基类和Bash、Terminate、Add等工具 - 集成了天气查询工具,支持通过中国气象局API获取天气预报信息 - 实现了交互式对话功能,支持多轮工具调用和结果处理 - 添加了详细的CLAUDE.md开发指导文档
31 lines
753 B
Python
31 lines
753 B
Python
from app.tools.base import BaseTool, ToolResult
|
|
|
|
|
|
_ADD_DESCRIPTION = """计算两个整数的和。"""
|
|
|
|
|
|
class Add(BaseTool):
|
|
"""加法计算工具"""
|
|
|
|
name: str = "add"
|
|
description: str = _ADD_DESCRIPTION
|
|
parameters: dict = {
|
|
"type": "object",
|
|
"properties": {
|
|
"a": {
|
|
"type": "integer",
|
|
"description": "第一个加数",
|
|
},
|
|
"b": {
|
|
"type": "integer",
|
|
"description": "第二个加数",
|
|
},
|
|
},
|
|
"required": ["a", "b"],
|
|
}
|
|
|
|
async def execute(self, a: int, b: int) -> ToolResult:
|
|
"""执行加法计算"""
|
|
result = a + b
|
|
return self.success_response({"result": result})
|