- 重命名工具获取函数为 get_buildin_tools 和 get_buildin_tools_info - 改进工具ID生成和描述构建逻辑 - 添加详细的日志记录和错误处理 - 优化知识库工具创建流程,避免闭包问题 - 分离静态工具和知识库工具获取逻辑 - 增强计算器和知识图谱查询工具的错误处理
16 lines
543 B
Python
16 lines
543 B
Python
from fastapi import APIRouter, Depends
|
|
from src.agents.tools_factory import get_buildin_tools_info
|
|
from server.models.user_model import User
|
|
from server.utils.auth_middleware import get_required_user
|
|
|
|
tool = chat = APIRouter(prefix="/tool", tags=["tool"])
|
|
|
|
@tool.get("/tools")
|
|
async def get_tools(current_user: User = Depends(get_required_user)):
|
|
"""获取所有可用工具的信息"""
|
|
try:
|
|
tools_info = get_buildin_tools_info()
|
|
return {"tools": tools_info}
|
|
except Exception as e:
|
|
return {"error": str(e)}
|