refactor: 删除重复的 tools
This commit is contained in:
parent
8987cf5d8a
commit
076e23eec3
@ -11,12 +11,7 @@ from pydantic import BaseModel, Field
|
||||
from src import config, graph_base, knowledge_base
|
||||
from src.utils import logger
|
||||
|
||||
# TODO[修改建议]:前端需要通过interrupt进行交互,点击是或否来批准执行
|
||||
# 返回中断点:
|
||||
# is_approved : bool = True 或者 False
|
||||
# resume_command = Command(resume=is_approved)
|
||||
# stream = graph.stream(resume_command, config=config, stream_mode="messages")
|
||||
# graph.invoke(resume_command, config=config)
|
||||
|
||||
@tool(name_or_callable="人工审批工具", description="请求人工审批工具,用于在执行重要操作前获得人类确认。")
|
||||
def get_approved_user_goal(
|
||||
operation_description: str,
|
||||
@ -54,50 +49,6 @@ def get_approved_user_goal(
|
||||
|
||||
return result
|
||||
|
||||
# TODO[修改建议]:前端需要通过interrupt进行交互,点击是或否来批准执行
|
||||
# 返回中断点:
|
||||
# is_approved : bool = True 或者 False
|
||||
# resume_command = Command(resume=is_approved)
|
||||
# stream = graph.stream(resume_command, config=config, stream_mode="messages")
|
||||
# graph.invoke(resume_command, config=config)
|
||||
@tool(name_or_callable="人工审批工具", description="请求人工审批工具,用于在执行重要操作前获得人类确认。")
|
||||
def get_approved_user_goal(
|
||||
operation_description: str,
|
||||
) -> dict:
|
||||
"""
|
||||
请求人工审批,在执行重要操作前获得人类确认。
|
||||
|
||||
Args:
|
||||
operation_description: 需要审批的操作描述,例如 "调用知识库工具"
|
||||
Returns:
|
||||
dict: 包含审批结果的字典,格式为 {"approved": bool, "message": str}
|
||||
"""
|
||||
# 构建详细的中断信息
|
||||
interrupt_info = {
|
||||
"question": "是否批准以下操作?",
|
||||
"operation": operation_description,
|
||||
}
|
||||
|
||||
# 触发人工审批
|
||||
is_approved = interrupt(interrupt_info)
|
||||
|
||||
# 返回审批结果
|
||||
if is_approved:
|
||||
result = {
|
||||
"approved": True,
|
||||
"message": f"✅ 操作已批准:{operation_description}",
|
||||
}
|
||||
print(f"✅ 人工审批通过: {operation_description}")
|
||||
else:
|
||||
result = {
|
||||
"approved": False,
|
||||
"message": f"❌ 操作被拒绝:{operation_description}",
|
||||
}
|
||||
print(f"❌ 人工审批被拒绝: {operation_description}")
|
||||
|
||||
return result
|
||||
|
||||
|
||||
@tool(name_or_callable="查询知识图谱", description="使用这个工具可以查询知识图谱中包含的三元组信息。")
|
||||
def query_knowledge_graph(query: Annotated[str, "The keyword to query knowledge graph."]) -> Any:
|
||||
"""Use this to query knowledge graph, which include some food domain knowledge."""
|
||||
|
||||
@ -39,7 +39,7 @@ async def context_based_model(request: ModelRequest, handler) -> ModelResponse:
|
||||
|
||||
|
||||
class SqlReporterAgent(BaseAgent):
|
||||
name = "SQL 报告助手"
|
||||
name = "数据库报表助手"
|
||||
description = "一个能够生成 SQL 查询报告的智能体助手。同时调用 Charts MCP 生成图表。"
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
|
||||
Loading…
Reference in New Issue
Block a user