|
11 | 11 | from src import config, graph_base, knowledge_base |
12 | 12 | from src.utils import logger |
13 | 13 |
|
14 | | -# TODO[修改建议]:前端需要通过interrupt进行交互,点击是或否来批准执行 |
15 | | -# 返回中断点: |
16 | | -# is_approved : bool = True 或者 False |
17 | | -# resume_command = Command(resume=is_approved) |
18 | | -# stream = graph.stream(resume_command, config=config, stream_mode="messages") |
19 | | -# graph.invoke(resume_command, config=config) |
| 14 | + |
20 | 15 | @tool(name_or_callable="人工审批工具", description="请求人工审批工具,用于在执行重要操作前获得人类确认。") |
21 | 16 | def get_approved_user_goal( |
22 | 17 | operation_description: str, |
@@ -54,50 +49,6 @@ def get_approved_user_goal( |
54 | 49 |
|
55 | 50 | return result |
56 | 51 |
|
57 | | -# TODO[修改建议]:前端需要通过interrupt进行交互,点击是或否来批准执行 |
58 | | -# 返回中断点: |
59 | | -# is_approved : bool = True 或者 False |
60 | | -# resume_command = Command(resume=is_approved) |
61 | | -# stream = graph.stream(resume_command, config=config, stream_mode="messages") |
62 | | -# graph.invoke(resume_command, config=config) |
63 | | -@tool(name_or_callable="人工审批工具", description="请求人工审批工具,用于在执行重要操作前获得人类确认。") |
64 | | -def get_approved_user_goal( |
65 | | - operation_description: str, |
66 | | -) -> dict: |
67 | | - """ |
68 | | - 请求人工审批,在执行重要操作前获得人类确认。 |
69 | | -
|
70 | | - Args: |
71 | | - operation_description: 需要审批的操作描述,例如 "调用知识库工具" |
72 | | - Returns: |
73 | | - dict: 包含审批结果的字典,格式为 {"approved": bool, "message": str} |
74 | | - """ |
75 | | - # 构建详细的中断信息 |
76 | | - interrupt_info = { |
77 | | - "question": "是否批准以下操作?", |
78 | | - "operation": operation_description, |
79 | | - } |
80 | | - |
81 | | - # 触发人工审批 |
82 | | - is_approved = interrupt(interrupt_info) |
83 | | - |
84 | | - # 返回审批结果 |
85 | | - if is_approved: |
86 | | - result = { |
87 | | - "approved": True, |
88 | | - "message": f"✅ 操作已批准:{operation_description}", |
89 | | - } |
90 | | - print(f"✅ 人工审批通过: {operation_description}") |
91 | | - else: |
92 | | - result = { |
93 | | - "approved": False, |
94 | | - "message": f"❌ 操作被拒绝:{operation_description}", |
95 | | - } |
96 | | - print(f"❌ 人工审批被拒绝: {operation_description}") |
97 | | - |
98 | | - return result |
99 | | - |
100 | | - |
101 | 52 | @tool(name_or_callable="查询知识图谱", description="使用这个工具可以查询知识图谱中包含的三元组信息。") |
102 | 53 | def query_knowledge_graph(query: Annotated[str, "The keyword to query knowledge graph."]) -> Any: |
103 | 54 | """Use this to query knowledge graph, which include some food domain knowledge.""" |
|
0 commit comments