mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-06-02 14:45:17 +02:00
Merge branch 'fixbug/gitlab/mgx_ops' into 'mgx_ops'
fixbug: type error See merge request pub/MetaGPT!21
This commit is contained in:
commit
a9f08e7dd6
3 changed files with 10 additions and 7 deletions
|
|
@ -7,6 +7,7 @@ from typing import Tuple
|
|||
from pydantic import BaseModel
|
||||
|
||||
from metagpt.actions import Action
|
||||
from metagpt.schema import Message
|
||||
|
||||
|
||||
class SOPItemDef(BaseModel):
|
||||
|
|
@ -89,7 +90,8 @@ You should follow the following Standard Operating Procedure:
|
|||
|
||||
|
||||
class DetectIntent(Action):
|
||||
async def run(self, user_requirement: str) -> Tuple[str, str]:
|
||||
async def run(self, with_message: Message, **kwargs) -> Tuple[str, str]:
|
||||
user_requirement = with_message.content
|
||||
intentions = "\n".join([f"{si.type_name}: {si.value.description}" for si in SOPItem])
|
||||
prompt = DETECT_PROMPT.format(user_requirement=user_requirement, intentions=intentions)
|
||||
|
||||
|
|
@ -111,7 +113,7 @@ async def main():
|
|||
detect_intent = DetectIntent()
|
||||
|
||||
for user_requirement in user_requirements:
|
||||
req_with_sop, sop_type = await detect_intent.run(user_requirement)
|
||||
req_with_sop, sop_type = await detect_intent.run(Message(role="user", content=user_requirement))
|
||||
print(req_with_sop)
|
||||
print(f"Detected SOP Type: {sop_type}")
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
# @Author : stellahong (stellahong@fuzhi.ai)
|
||||
# @Desc :
|
||||
import asyncio
|
||||
from typing import Dict, List
|
||||
from typing import Dict
|
||||
|
||||
from metagpt.actions.di.detect_intent import DetectIntent
|
||||
from metagpt.logs import logger
|
||||
|
|
@ -14,9 +14,9 @@ class MGX(DataInterpreter):
|
|||
use_intent: bool = True
|
||||
intents: Dict = {}
|
||||
|
||||
async def _detect_intent(self, user_msgs: List[Message] = None, **kwargs):
|
||||
async def _detect_intent(self, user_msg: Message):
|
||||
todo = DetectIntent(context=self.context)
|
||||
request_with_sop, sop_type = await todo.run(user_msgs)
|
||||
request_with_sop, sop_type = await todo.run(user_msg)
|
||||
logger.info(f"{sop_type} {request_with_sop}")
|
||||
return request_with_sop
|
||||
|
||||
|
|
@ -27,7 +27,7 @@ class MGX(DataInterpreter):
|
|||
goal = self.rc.memory.get()[-1].content # retreive latest user requirement
|
||||
if self.use_intent: # add mode
|
||||
user_message = Message(content=goal, role="user")
|
||||
goal = await self._detect_intent(user_msgs=[user_message])
|
||||
goal = await self._detect_intent(user_message)
|
||||
logger.info(f"Goal is {goal}")
|
||||
|
||||
await self.planner.update_plan(goal=goal)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import pytest
|
||||
|
||||
from metagpt.actions.di.detect_intent import DetectIntent
|
||||
from metagpt.schema import Message
|
||||
|
||||
SOFTWARE_DEV_REQ1 = """
|
||||
I'd like to create a personalized website that features the 'Game of Life' simulation.
|
||||
|
|
@ -51,5 +52,5 @@ git clone 'https://github.com/spec-first/connexion' and format to MetaGPT projec
|
|||
)
|
||||
async def test_detect_intent(requirement, expected_intent_type):
|
||||
di = DetectIntent()
|
||||
_, intent_type = await di.run(requirement)
|
||||
_, intent_type = await di.run(Message(role="user", content=requirement))
|
||||
assert intent_type == expected_intent_type
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue