fixbug: type error

This commit is contained in:
莘权 马 2024-04-07 13:01:03 +08:00
parent 6ff2767e25
commit eec69e64a3
2 changed files with 4 additions and 1 deletions

View file

@ -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)

View file

@ -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