diff --git a/README.md b/README.md index e42b5b766..c94d0b7c8 100644 --- a/README.md +++ b/README.md @@ -75,6 +75,8 @@ # or `pip install --upgrade git+https://github.com/geekan/MetaGPT.git` # or `git clone https://github.com/geekan/MetaGPT && cd MetaGPT && pip install --upgrade -e .` ``` +**Install [node](https://nodejs.org/en/download) and [pnpm](https://pnpm.io/installation#using-npm) before actual use.** + For detailed installation guidance, please refer to [cli_install](https://docs.deepwisdom.ai/main/en/guide/get_started/installation.html#install-stable-version) or [docker_install](https://docs.deepwisdom.ai/main/en/guide/get_started/installation.html#install-with-docker) diff --git a/metagpt/config2.py b/metagpt/config2.py index 84b6059ef..02039f737 100644 --- a/metagpt/config2.py +++ b/metagpt/config2.py @@ -63,6 +63,7 @@ class Config(CLIParams, YamlModel): # Tool Parameters search: SearchConfig = SearchConfig() + enable_search: bool = False browser: BrowserConfig = BrowserConfig() mermaid: MermaidConfig = MermaidConfig() diff --git a/metagpt/prompts/di/architect.py b/metagpt/prompts/di/architect.py index 6d114abaa..af2530b32 100644 --- a/metagpt/prompts/di/architect.py +++ b/metagpt/prompts/di/architect.py @@ -74,6 +74,7 @@ Anything UNCLEAR: Mention unclear project aspects, then try to clarify it. {system_design_example} 5. Use Editor.write to write the system design in markdown format. The file path must be "{{project}}/docs/system_design.md". Use command_name "end" when the system design is finished. 6. If not memtioned, always use Editor.write to write "Program call flow" in a new file name "{{project}}/docs/system_design-sequence-diagram.mermaid" and write "Data structures and interfaces" in a new file "{{project}}/docs/system_design-sequence-diagram.mermaid-class-diagram". Mermaid code only. Do not add "```mermaid". +7. Just continue the work, if the template path does not exits. """.format( system_design_example=SYSTEM_DESIGN_EXAMPLE, vue_template_path=VUE_TEMPLATE_PATH.resolve().absolute(), diff --git a/metagpt/prompts/di/engineer2.py b/metagpt/prompts/di/engineer2.py index 25cd595cd..8948e2670 100644 --- a/metagpt/prompts/di/engineer2.py +++ b/metagpt/prompts/di/engineer2.py @@ -55,6 +55,7 @@ Note: 26. Engineer2.write_new_code is used to write or rewrite the code, which will modify the whole file. Editor.edit_file_by_replace is used to edit a small part of the file. 27. Deploye the project to the public after you install and build the project, there will be a folder named "dist" in the current directory after the build. 28. Use Engineer2.write_new_code to rewrite the whole file when you fail to use Editor.edit_file_by_replace more than three times. +29. Just continue the work, if the template path does not exits. """.format( vue_template_path=VUE_TEMPLATE_PATH.resolve().absolute(), react_template_path=REACT_TEMPLATE_PATH.resolve().absolute(), diff --git a/metagpt/roles/__init__.py b/metagpt/roles/__init__.py index 08a0406b3..c853604db 100644 --- a/metagpt/roles/__init__.py +++ b/metagpt/roles/__init__.py @@ -14,6 +14,9 @@ from metagpt.roles.engineer import Engineer from metagpt.roles.qa_engineer import QaEngineer from metagpt.roles.searcher import Searcher from metagpt.roles.sales import Sales +from metagpt.roles.di.data_analyst import DataAnalyst +from metagpt.roles.di.team_leader import TeamLeader +from metagpt.roles.di.engineer2 import Engineer2 __all__ = [ @@ -25,4 +28,7 @@ __all__ = [ "QaEngineer", "Searcher", "Sales", + "DataAnalyst", + "TeamLeader", + "Engineer2", ] diff --git a/metagpt/roles/di/role_zero.py b/metagpt/roles/di/role_zero.py index 5799d5e16..abb0e7269 100644 --- a/metagpt/roles/di/role_zero.py +++ b/metagpt/roles/di/role_zero.py @@ -127,8 +127,9 @@ class RoleZero(Role): "Plan.replace_task": self.planner.plan.replace_task, "RoleZero.ask_human": self.ask_human, "RoleZero.reply_to_human": self.reply_to_human, - "SearchEnhancedQA.run": SearchEnhancedQA().run, } + if self.config.enable_search: + self.tool_execution_map["SearchEnhancedQA.run"] = SearchEnhancedQA().run self.tool_execution_map.update( { f"Browser.{i}": getattr(self.browser, i) diff --git a/metagpt/software_company.py b/metagpt/software_company.py index 73dcdd5db..19c6bdbe4 100644 --- a/metagpt/software_company.py +++ b/metagpt/software_company.py @@ -7,7 +7,6 @@ from pathlib import Path import typer from metagpt.const import CONFIG_ROOT -from metagpt.utils.common import any_to_str app = typer.Typer(add_completion=False, pretty_exceptions_show_locals=False) @@ -31,10 +30,10 @@ def generate_repo( from metagpt.context import Context from metagpt.roles import ( Architect, - Engineer, + DataAnalyst, + Engineer2, ProductManager, - ProjectManager, - QaEngineer, + TeamLeader, ) from metagpt.team import Team @@ -45,19 +44,22 @@ def generate_repo( company = Team(context=ctx) company.hire( [ + TeamLeader(), ProductManager(), Architect(), - ProjectManager(), + Engineer2(), + # ProjectManager(), + DataAnalyst(), ] ) - if implement or code_review: - company.hire([Engineer(n_borg=5, use_code_review=code_review)]) - - if run_tests: - company.hire([QaEngineer()]) - if n_round < 8: - n_round = 8 # If `--run-tests` is enabled, at least 8 rounds are required to run all QA actions. + # if implement or code_review: + # company.hire([Engineer(n_borg=5, use_code_review=code_review)]) + # + # if run_tests: + # company.hire([QaEngineer()]) + # if n_round < 8: + # n_round = 8 # If `--run-tests` is enabled, at least 8 rounds are required to run all QA actions. else: stg_path = Path(recover_path) if not stg_path.exists() or not str(stg_path).endswith("team"): @@ -67,8 +69,7 @@ def generate_repo( idea = company.idea company.invest(investment) - company.run_project(idea, send_to=any_to_str(ProductManager)) - asyncio.run(company.run(n_round=n_round)) + asyncio.run(company.run(n_round=n_round, idea=idea)) return ctx.kwargs.get("project_path") diff --git a/metagpt/team.py b/metagpt/team.py index 180ecdb06..5a9838885 100644 --- a/metagpt/team.py +++ b/metagpt/team.py @@ -14,13 +14,13 @@ from typing import Any, Optional from pydantic import BaseModel, ConfigDict, Field -from metagpt.actions import UserRequirement -from metagpt.const import MESSAGE_ROUTE_TO_ALL, SERDESER_PATH +from metagpt.const import SERDESER_PATH from metagpt.context import Context from metagpt.environment import Environment +from metagpt.environment.mgx.mgx_env import MGXEnv from metagpt.logs import logger from metagpt.roles import Role -from metagpt.schema import UserMessage +from metagpt.schema import Message from metagpt.utils.common import ( NoMoneyException, read_json_file, @@ -40,12 +40,15 @@ class Team(BaseModel): env: Optional[Environment] = None investment: float = Field(default=10.0) idea: str = Field(default="") + use_mgx: bool = Field(default=True) def __init__(self, context: Context = None, **data: Any): super(Team, self).__init__(**data) ctx = context or Context() - if not self.env: + if not self.env and not self.use_mgx: self.env = Environment(context=ctx) + elif not self.env and self.use_mgx: + self.env = MGXEnv(context=ctx) else: self.env.context = ctx # The `env` object is allocated by deserialization if "roles" in data: @@ -101,10 +104,7 @@ class Team(BaseModel): self.idea = idea # Human requirement. - self.env.publish_message( - UserMessage(content=idea, cause_by=UserRequirement, send_to=send_to or MESSAGE_ROUTE_TO_ALL), - peekable=False, - ) + self.env.publish_message(Message(content=idea)) def start_project(self, idea, send_to: str = ""): """ diff --git a/metagpt/tools/tool_recommend.py b/metagpt/tools/tool_recommend.py index 25f403c77..06184b244 100644 --- a/metagpt/tools/tool_recommend.py +++ b/metagpt/tools/tool_recommend.py @@ -150,7 +150,7 @@ class ToolRecommender(BaseModel): repair_llm_raw_output(output=ranked_tools, req_keys=[None], repair_type=RepairType.JSON) ) except json.JSONDecodeError: - ranked_tools = await self.llm.aask(msg=JSON_REPAIR_PROMPT.format(json_data=rsp)) + ranked_tools = await LLM().aask(msg=JSON_REPAIR_PROMPT.format(json_data=rsp)) ranked_tools = json.loads(CodeParser.parse_code(block=None, lang="json", text=ranked_tools)) except Exception: tb = traceback.format_exc()