myagent-ai 1.10.5 → 1.10.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
Binary file
|
package/agents/main_agent.py
CHANGED
|
@@ -53,6 +53,8 @@ class MainAgent(BaseAgent):
|
|
|
53
53
|
<get_knowledge>下一轮执行时需要从知识库搜索获得的知识,填写检索关键词或描述。如context中已包含充足的<knowledge>内容,则为空。如需更多专业知识支撑,则填写相关搜索词。</get_knowledge>
|
|
54
54
|
<askuser>需要询问用户的内容,如无,则为空</askuser>
|
|
55
55
|
<finish>true/false,是否结束循环调用llm。如"askuser"为非空,则"finish"输出true。否则,根据"context"判断任务是否已完成,是否结束llm回调</finish>
|
|
56
|
+
<finish_reason>当 finish=true 时必填,详细说明为什么现在结束任务(如:任务已完成/需要用户补充信息/信息不足无法继续等)。finish=false 时为空。</finish_reason>
|
|
57
|
+
<next_step>当 finish=false 时必填,描述下一步计划做什么(简洁明了,1-2句话)。finish=true 时为空。</next_step>
|
|
56
58
|
|
|
57
59
|
</output>
|
|
58
60
|
|
|
@@ -70,7 +72,9 @@ class MainAgent(BaseAgent):
|
|
|
70
72
|
11. <get_knowledge>: 如果当前 <knowledge> 内容不足以完成任务,填写需要从知识库搜索的关键词;否则为空
|
|
71
73
|
12. <askuser>: 当信息不足需要用户补充时,在此填写要问的问题
|
|
72
74
|
13. <finish>: 当任务已完成或需要等待用户回应时为 true;否则为 false 继续执行
|
|
73
|
-
14.
|
|
75
|
+
14. <finish_reason>: **finish=true 时必须填写**,详细说明结束原因(任务完成/等待用户/信息不足/无法处理等)
|
|
76
|
+
15. <next_step>: **finish=false 时必须填写**,描述下一步计划做什么,要求简洁明确(1-2句话)
|
|
77
|
+
16. 使用中文输出所有内容
|
|
74
78
|
|
|
75
79
|
## 工具选择指南
|
|
76
80
|
- **搜索信息**: 用 `web_search`(返回标题+URL+摘要),不要用 browser_open
|
|
@@ -464,6 +468,8 @@ class MainAgent(BaseAgent):
|
|
|
464
468
|
"remember": truncate_str(parsed.remember, 200),
|
|
465
469
|
"ask_user": truncate_str(parsed.ask_user, 200),
|
|
466
470
|
"finish": parsed.finish,
|
|
471
|
+
"finish_reason": truncate_str(parsed.finish_reason, 200),
|
|
472
|
+
"next_step": truncate_str(parsed.next_step, 200),
|
|
467
473
|
"parse_success": parsed.parse_success,
|
|
468
474
|
}},
|
|
469
475
|
stream_callback,
|
|
Binary file
|
package/core/output_parser.py
CHANGED
|
@@ -86,6 +86,8 @@ class ParsedOutput:
|
|
|
86
86
|
get_knowledge: Knowledge search keywords for the next loop iteration.
|
|
87
87
|
The ContextBuilder will use this to perform RAG retrieval.
|
|
88
88
|
finish: When ``True`` the execution loop should terminate.
|
|
89
|
+
finish_reason: When finish=True, explains why the task is ending.
|
|
90
|
+
next_step: When finish=False, describes what to do next.
|
|
89
91
|
raw_text: The verbatim raw text returned by the LLM.
|
|
90
92
|
parse_success: Whether the XML was parsed successfully (``True``)
|
|
91
93
|
or the regex fallback was used (``False``).
|
|
@@ -99,6 +101,8 @@ class ParsedOutput:
|
|
|
99
101
|
ask_user: str = ""
|
|
100
102
|
get_knowledge: str = ""
|
|
101
103
|
finish: bool = False
|
|
104
|
+
finish_reason: str = ""
|
|
105
|
+
next_step: str = ""
|
|
102
106
|
response: str = "" # 模型对用户的直接回复(友好自然的话语)
|
|
103
107
|
raw_text: str = ""
|
|
104
108
|
parse_success: bool = False
|
|
@@ -363,6 +367,8 @@ def _parse_xml_content(xml_content: str) -> ParsedOutput:
|
|
|
363
367
|
parsed.ask_user = _safe_strip(root.findtext("askuser"))
|
|
364
368
|
parsed.get_knowledge = _safe_strip(root.findtext("get_knowledge"))
|
|
365
369
|
parsed.finish = _parse_bool(root.findtext("finish"), False)
|
|
370
|
+
parsed.finish_reason = _safe_strip(root.findtext("finish_reason"))
|
|
371
|
+
parsed.next_step = _safe_strip(root.findtext("next_step"))
|
|
366
372
|
parsed.response = _safe_strip(root.findtext("response"))
|
|
367
373
|
|
|
368
374
|
return parsed
|
|
@@ -393,6 +399,8 @@ def _fallback_regex_parse(raw_text: str) -> ParsedOutput:
|
|
|
393
399
|
parsed.ask_user = _safe_strip(tag_map.get("askuser"))
|
|
394
400
|
parsed.get_knowledge = _safe_strip(tag_map.get("get_knowledge"))
|
|
395
401
|
parsed.finish = _parse_bool(tag_map.get("finish"), False)
|
|
402
|
+
parsed.finish_reason = _safe_strip(tag_map.get("finish_reason"))
|
|
403
|
+
parsed.next_step = _safe_strip(tag_map.get("next_step"))
|
|
396
404
|
parsed.response = _safe_strip(tag_map.get("response"))
|
|
397
405
|
|
|
398
406
|
# For toolstocal we attempt to find individual <tool> blocks.
|
|
@@ -482,6 +490,8 @@ def parse_output(raw_text: str) -> ParsedOutput:
|
|
|
482
490
|
parsed.ask_user = _safe_strip(root.findtext("askuser"))
|
|
483
491
|
parsed.get_knowledge = _safe_strip(root.findtext("get_knowledge"))
|
|
484
492
|
parsed.finish = _parse_bool(root.findtext("finish"), False)
|
|
493
|
+
parsed.finish_reason = _safe_strip(root.findtext("finish_reason"))
|
|
494
|
+
parsed.next_step = _safe_strip(root.findtext("next_step"))
|
|
485
495
|
parsed.response = _safe_strip(root.findtext("response"))
|
|
486
496
|
return parsed
|
|
487
497
|
except ET.ParseError:
|