Merge branch 'mgx_ops' of https://gitlab.deepwisdomai.com/pub/MetaGPT into mgx_ops

This commit is contained in:
stellahsr 2024-04-09 14:39:05 +08:00
commit f9e61807d5
5 changed files with 22 additions and 6 deletions

View file

@ -12,7 +12,7 @@ requirement = (
async def main(requirement: str = ""):
mgx = MGX(use_intent=True)
mgx = MGX(use_intent=True, tools=["<all>"])
await mgx.run(requirement)

View file

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

View file

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

View file

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

View file

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