Skip to content

🌟 The Multi-Agent Framework: First AI Software Company, Towards Natural Language Programming

Merge branch 'mgx_ops' into update_RoleZero_summary_prompt

黄伟韬99877a4eab19
diff --cc metagpt/roles/di/role_zero.py
index 37392673a,4edb2e37d..4064088f7
--- a/metagpt/roles/di/role_zero.py
+++ b/metagpt/roles/di/role_zero.py
@@@ -492,12 -492,15 +492,15 @@@ class RoleZero(Role)
async def _end(self):
self._set_state(-1)
memory = self.rc.memory.get(self.memory_k)
- # Ensure reply to the human before the "end" command is executed.
+ # Ensure reply to the human before the "end" command is executed. Hard code k=5 for checking.
if not any(["reply_to_human" in memory.content for memory in self.get_memories(k=5)]):
+ logger.info("manually reply to human")
- reply_to_human_prompt = REPORT_TO_HUMAN_PROMPT.format(
- requirements_constraints=self.requirements_constraints,
- )
+ pattern = r"\[Language Restrictions\](.*?)\n"
+ match = re.search(pattern, self.requirements_constraints, re.DOTALL)
+ reply_to_human_prompt = REPORT_TO_HUMAN_PROMPT.format(lanaguge_restruction=match.group(0) if match else "")
- reply_content = await self.llm.aask(self.llm.format_msg(memory + [UserMessage(reply_to_human_prompt)]))
+ async with ThoughtReporter(enable_llm_stream=True) as reporter:
+ await reporter.async_report({"type": "quick"})
+ reply_content = await self.llm.aask(self.llm.format_msg(memory + [UserMessage(reply_to_human_prompt)]))
await self.reply_to_human(content=reply_content)
self.rc.memory.add(AIMessage(content=reply_content, cause_by=RunCommand))
outputs = ""