feat: 更新调用函数
This commit is contained in:
@ -3,7 +3,7 @@
|
|||||||
[](https://www.python.org/)
|
[](https://www.python.org/)
|
||||||
[](https://nodejs.org/zh-cn/)
|
[](https://nodejs.org/zh-cn/)
|
||||||
|
|
||||||
一个基于飞书(Lark)的全场景MCP Function Call AI Agent,实现大模型通过飞书进行函数调用和消息处理。
|
一个基于飞书(Lark)的AI Agent,实现大模型通过飞书进行函数调用和消息处理。
|
||||||
|
|
||||||
|
|
||||||
**无需配置飞书机器人,你的飞书账号即是AI助手。**
|
**无需配置飞书机器人,你的飞书账号即是AI助手。**
|
||||||
|
|||||||
@ -6,8 +6,7 @@ import datetime
|
|||||||
from loguru import logger
|
from loguru import logger
|
||||||
from sqlalchemy import func, desc
|
from sqlalchemy import func, desc
|
||||||
from mcp.server.fastmcp import FastMCP
|
from mcp.server.fastmcp import FastMCP
|
||||||
|
from typing_extensions import Annotated
|
||||||
|
|
||||||
|
|
||||||
BASE_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..'))
|
BASE_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..'))
|
||||||
if BASE_DIR not in sys.path:
|
if BASE_DIR not in sys.path:
|
||||||
@ -39,7 +38,9 @@ def list_tools() -> str:
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
@register_tool(name="get_weather", description="获取城市天气")
|
@register_tool(name="get_weather", description="获取城市天气")
|
||||||
def get_weather(city):
|
def get_weather(
|
||||||
|
city: Annotated[str, "城市名称"] = "北京"
|
||||||
|
):
|
||||||
"""
|
"""
|
||||||
获取城市天气
|
获取城市天气
|
||||||
:param city: 城市名称
|
:param city: 城市名称
|
||||||
|
|||||||
@ -63,13 +63,12 @@ class MessageService:
|
|||||||
async with Client(self.mcp_transport) as mcp_client:
|
async with Client(self.mcp_transport) as mcp_client:
|
||||||
tools = []
|
tools = []
|
||||||
for tool in await mcp_client.list_tools():
|
for tool in await mcp_client.list_tools():
|
||||||
info = tool.model_dump() if hasattr(tool, "model_dump") else tool.dict()
|
|
||||||
tools.append({
|
tools.append({
|
||||||
"type": "function",
|
"type": "function",
|
||||||
"function": {
|
"function": {
|
||||||
"name": info["name"],
|
"name": tool.name,
|
||||||
"description": info.get("description", ""),
|
"description": tool.description,
|
||||||
"parameters": info.get("parameters", {})
|
"parameters": tool.inputSchema,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
messages = [
|
messages = [
|
||||||
|
|||||||
Reference in New Issue
Block a user