From 6b4c00f28638c07ba7ec70e8118977a4c59c9fb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E4=BC=9F=E9=9F=AC?= Date: Mon, 19 Aug 2024 19:15:33 +0800 Subject: [PATCH] Remove the 'User Message' tag in the quick answer process. --- metagpt/roles/di/role_zero.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/metagpt/roles/di/role_zero.py b/metagpt/roles/di/role_zero.py index c6cbfdfa8..674960be4 100644 --- a/metagpt/roles/di/role_zero.py +++ b/metagpt/roles/di/role_zero.py @@ -295,6 +295,9 @@ class RoleZero(Role): if "QUICK" in intent_result or "AMBIGUOUS" in intent_result: # llm call with the original context async with ThoughtReporter(enable_llm_stream=True) as reporter: await reporter.async_report({"type": "quick"}) + # remove "[Message] from A to B :" tag. + pattern = r"\[Message\] from .* to .*:\s*" + memory[-1].content = re.sub(pattern, "", memory[-1].content, count=1) answer = await self.llm.aask( self.llm.format_msg(memory), system_msgs=[QUICK_RESPONSE_SYSTEM_PROMPT.format(role_info=self._get_prefix())],