From eec69e64a3131c9c58b38920906a2fd4f0477dc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8E=98=E6=9D=83=20=E9=A9=AC?= Date: Sun, 7 Apr 2024 13:01:03 +0800 Subject: [PATCH] fixbug: type error --- metagpt/actions/di/detect_intent.py | 2 ++ metagpt/roles/di/mgx.py | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/metagpt/actions/di/detect_intent.py b/metagpt/actions/di/detect_intent.py index 8f56f4ae8..d41317321 100644 --- a/metagpt/actions/di/detect_intent.py +++ b/metagpt/actions/di/detect_intent.py @@ -90,6 +90,8 @@ You should follow the following Standard Operating Procedure: class DetectIntent(Action): async def run(self, user_requirement: str) -> Tuple[str, str]: + if not isinstance(user_requirement, str): + raise ValueError(f"str type error: {user_requirement}") intentions = "\n".join([f"{si.type_name}: {si.value.description}" for si in SOPItem]) prompt = DETECT_PROMPT.format(user_requirement=user_requirement, intentions=intentions) diff --git a/metagpt/roles/di/mgx.py b/metagpt/roles/di/mgx.py index b2caa930b..33377e5f1 100644 --- a/metagpt/roles/di/mgx.py +++ b/metagpt/roles/di/mgx.py @@ -16,7 +16,8 @@ class MGX(DataInterpreter): async def _detect_intent(self, user_msgs: List[Message] = None, **kwargs): todo = DetectIntent(context=self.context) - request_with_sop, sop_type = await todo.run(user_msgs) + user_requirement = "\n".join([f"> {i.role}: {i.content}" for i in user_msgs]) + request_with_sop, sop_type = await todo.run(user_requirement) logger.info(f"{sop_type} {request_with_sop}") return request_with_sop