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