diff --git a/README.md b/README.md index b3473a12c..b0faf85c7 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,8 @@ # MetaGPT: The Multi-Agent Framework
Software Company Multi-Role Schematic (Gradually Implementing)
- +## News +- Dec 15: v0.5.0 is released! We introduce **incremental development**, facilitating agents to build up larger projects on top of their previous efforts or exisiting human codebase. We also launch a whole collection of important features, including multilingual support (experimental), multiple programming languages support (experimental), incremental development (experimental), CLI support, pip support, enhanced code review, documentation mechanism, and optimized messaging mechanism! ## Install diff --git a/config/config.yaml b/config/config.yaml index 496167e13..d38240ae6 100644 --- a/config/config.yaml +++ b/config/config.yaml @@ -1,6 +1,9 @@ # DO NOT MODIFY THIS FILE, create a new key.yaml, define OPENAI_API_KEY. # The configuration of key.yaml has a higher priority and will not enter git +#### Project Path Setting +# WORKSPACE_PATH: "Path for placing output files" + #### if OpenAI ## The official OPENAI_API_BASE is https://api.openai.com/v1 ## If the official OPENAI_API_BASE is not available, we recommend using the [openai-forward](https://github.com/beidongjiedeguang/openai-forward). diff --git a/metagpt/actions/role_run.py b/metagpt/actions/role_run.py new file mode 100644 index 000000000..9f0c626b8 --- /dev/null +++ b/metagpt/actions/role_run.py @@ -0,0 +1,16 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +""" +@Time : 2023/12/18 +@Author : mashenquan +@File : role_run.py +@Desc : Message type caused by `Role.run()` invocation. +""" +from metagpt.actions import Action + + +class RoleRun(Action): + """Message type caused by `Role.run` invocation""" + + async def run(self, *args, **kwargs): + raise NotImplementedError diff --git a/metagpt/const.py b/metagpt/const.py index 03f3d8fe3..fcb3a2b3e 100644 --- a/metagpt/const.py +++ b/metagpt/const.py @@ -17,12 +17,18 @@ from loguru import logger import metagpt -OPTIONS = contextvars.ContextVar("OPTIONS") +OPTIONS = contextvars.ContextVar("OPTIONS", default={}) def get_metagpt_package_root(): """Get the root directory of the installed package.""" package_root = Path(metagpt.__file__).parent.parent + for i in (".git", ".project_root", ".gitignore"): + if (package_root / i).exists(): + break + else: + package_root = Path.cwd() + logger.info(f"Package root set to {str(package_root)}") return package_root diff --git a/metagpt/roles/role.py b/metagpt/roles/role.py index 06c00a670..ad5ee89c0 100644 --- a/metagpt/roles/role.py +++ b/metagpt/roles/role.py @@ -28,6 +28,7 @@ from pydantic import BaseModel, Field from metagpt.actions import Action, ActionOutput from metagpt.actions.action_node import ActionNode +from metagpt.actions.role_run import RoleRun from metagpt.llm import LLM, HumanProvider from metagpt.logs import logger from metagpt.memory import Memory @@ -317,7 +318,9 @@ class Role: old_messages = [] if ignore_memory else self._rc.memory.get() self._rc.memory.add_batch(news) # Filter out messages of interest. - self._rc.news = [n for n in news if n.cause_by in self._rc.watch and n not in old_messages] + watch = self._rc.watch or set() + watch.add(any_to_str(RoleRun)) + self._rc.news = [n for n in news if n.cause_by in watch and n not in old_messages] # Design Rules: # If you need to further categorize Message objects, you can do so using the Message.set_meta function. @@ -397,6 +400,8 @@ class Role: msg = with_message elif isinstance(with_message, list): msg = Message("\n".join(with_message)) + if not msg.cause_by: + msg.cause_by = RoleRun self.put_message(msg) if not await self._observe(): diff --git a/metagpt/team.py b/metagpt/team.py index ed406ee4c..d613a04ef 100644 --- a/metagpt/team.py +++ b/metagpt/team.py @@ -3,10 +3,12 @@ """ @Time : 2023/5/12 00:30 @Author : alexanderwu -@File : software_company.py +@File : team.py @Modified By: mashenquan, 2023/11/27. Add an archiving operation after completing the project, as specified in Section 2.2.3.3 of RFC 135. """ +import warnings + from pydantic import BaseModel, Field from metagpt.actions import UserRequirement @@ -50,7 +52,7 @@ class Team(BaseModel): ) def run_project(self, idea, send_to: str = ""): - """Start a project from publishing user requirement.""" + """Run a project from publishing user requirement.""" self.idea = idea # Human requirement. @@ -59,6 +61,19 @@ class Team(BaseModel): peekable=False, ) + def start_project(self, idea, send_to: str = ""): + """ + Deprecated: This method will be removed in the future. + Please use the `run_project` method instead. + """ + warnings.warn( + "The 'start_project' method is deprecated and will be removed in the future. " + "Please use the 'run_project' method instead.", + DeprecationWarning, + stacklevel=2, + ) + return self.run_project(idea=idea, send_to=send_to) + def _save(self): logger.info(self.json(ensure_ascii=False)) diff --git a/setup.py b/setup.py index 4dd453b3d..73a05eeae 100644 --- a/setup.py +++ b/setup.py @@ -30,7 +30,7 @@ with open(path.join(here, "requirements.txt"), encoding="utf-8") as f: setup( name="metagpt", - version="0.4.0", + version="0.5.1", description="The Multi-Role Meta Programming Framework", long_description=long_description, long_description_content_type="text/markdown",