diff --git a/examples/mgx/run_mgx.py b/examples/mgx/run_mgx.py index f4eb31579..1dc59d71a 100644 --- a/examples/mgx/run_mgx.py +++ b/examples/mgx/run_mgx.py @@ -12,7 +12,7 @@ requirement = ( async def main(requirement: str = ""): - mgx = MGX(use_intent=True) + mgx = MGX(use_intent=True, tools=[""]) await mgx.run(requirement) diff --git a/metagpt/actions/di/detect_intent.py b/metagpt/actions/di/detect_intent.py index 1fb1c9089..bfefcacff 100644 --- a/metagpt/actions/di/detect_intent.py +++ b/metagpt/actions/di/detect_intent.py @@ -29,7 +29,7 @@ class SOPItemDef(BaseModel): class SOPItem(Enum): SOFTWARE_DEVELOPMENT = SOPItemDef( name="software development", - description="Intentions related to or including software development, such as developing or building software, games, app, websites, etc. Excluding bug fixes, report any issues.", + description="Intentions related to or including software development, such as developing or building software, games, app, websites, etc. Excluding bug fixes, report any issues, environment setup, operations and pip install.", sop=[ "Writes a PRD based on software requirements.", "Writes a design to the project repository, based on the PRD of the project.", @@ -55,9 +55,18 @@ class SOPItem(Enum): "Stage and commit changes for the project repository using Git.", ], ) + WEBPAGE_IMITATION = SOPItemDef( + name="webpage_imitation", + description="webpage browsing, imitation and other applications etc.", + sop=[ + "Utilize Selenium and WebDriver for rendering.", + "Capture a screenshot of the rendered webpage.", + "Convert image to a webpage including HTML, CSS and JS in one go.", + ], + ) OTHER = SOPItemDef( name="other", - description="Other intentions that do not fall into the above categories, including data science, machine learning, deep learning, etc.", + description="Other intentions that do not fall into the above categories, including data science, machine learning, deep learning and text-to-image etc.", sop=[], ) @@ -97,7 +106,7 @@ class DetectIntent(Action): async def run(self, with_message: Message, **kwargs) -> Tuple[str, str]: user_requirement = with_message.content mappings = {i + 1: si for i, si in enumerate(SOPItem)} - intentions = "\n".join([f"{i+1}. {si.type_name}: {si.value.description}" for i, si in enumerate(SOPItem)]) + intentions = "\n".join([f"{i + 1}. {si.type_name}: {si.value.description}" for i, si in enumerate(SOPItem)]) prompt = DETECT_PROMPT.format(user_requirement=user_requirement, intentions=intentions) rsp = await self._aask(prompt) @@ -110,7 +119,7 @@ class DetectIntent(Action): req_with_sop = ( REQ_WITH_SOP.format( - user_requirement=user_requirement, sop="\n".join([f"{i+1}. {v}" for i, v in enumerate(sop)]) + user_requirement=user_requirement, sop="\n".join([f"{i + 1}. {v}" for i, v in enumerate(sop)]) ) if sop else user_requirement diff --git a/metagpt/roles/di/mgx.py b/metagpt/roles/di/mgx.py index 0fa7c77b6..1715b9b6c 100644 --- a/metagpt/roles/di/mgx.py +++ b/metagpt/roles/di/mgx.py @@ -28,6 +28,7 @@ class MGX(DataInterpreter): if self.use_intent: # add mode user_message = Message(content=goal, role="user") goal = await self._detect_intent(user_message) + logger.info(f"Goal is {goal}") await self.planner.update_plan(goal=goal) diff --git a/metagpt/strategy/task_type.py b/metagpt/strategy/task_type.py index d21705c16..2bc53b964 100644 --- a/metagpt/strategy/task_type.py +++ b/metagpt/strategy/task_type.py @@ -67,6 +67,10 @@ class TaskType(Enum): name="email login", desc="For logging to an email.", ) + DEVELOP_SOFTWARE = TaskTypeDef( + name="develop software", + desc="SOP related to develop software such as Writes a PRD, Writes a design, Writes a project plan and Writes code to implement designed features according to the project plan", + ) @property def type_name(self): diff --git a/metagpt/tools/libs/software_development.py b/metagpt/tools/libs/software_development.py index f8a409878..a5bfdd47d 100644 --- a/metagpt/tools/libs/software_development.py +++ b/metagpt/tools/libs/software_development.py @@ -48,6 +48,7 @@ async def write_prd(idea: str, project_path: Optional[str | Path] = None) -> Pat if project_path and Path(project_path).exists(): ctx.config.project_path = Path(project_path) ctx.config.inc = True + role = ProductManager(context=ctx) msg = await role.run(with_message=Message(content=idea, cause_by=UserRequirement)) await role.run(with_message=msg) @@ -84,8 +85,9 @@ async def write_design(prd_path: str | Path) -> Path: Path: The path to the system design files under the project directory. Example: + >>> from metagpt.tools.libs.software_development import write_prd >>> from metagpt.tools.libs.software_development import write_design - >>> prd_path = '/path/to/project_path/docs/prd' # Returned by `write_prd` + >>> prd_path = await write_prd("Create a new feature for the application") >>> system_design_path = await write_desgin(prd_path) >>> print(system_design_path) '/path/to/project_path/docs/system_design/'