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 8fd208c59..dc4c4ea5a 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/config.py b/metagpt/config.py index 19bd02c87..d7f5c1249 100644 --- a/metagpt/config.py +++ b/metagpt/config.py @@ -45,9 +45,11 @@ class Config(metaclass=Singleton): default_yaml_file = METAGPT_ROOT / "config/config.yaml" def __init__(self, yaml_file=default_yaml_file): + golbal_options = OPTIONS.get() self._init_with_config_files_and_env(yaml_file) logger.debug("Config loading done.") self._update() + golbal_options.update(OPTIONS.get()) def _update(self): # logger.info("Config loading done.") diff --git a/metagpt/const.py b/metagpt/const.py index f6f64a27d..10de0ff66 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 b07541b09..1e7ebf711 100644 --- a/metagpt/roles/role.py +++ b/metagpt/roles/role.py @@ -27,6 +27,7 @@ from pydantic import BaseModel, Field from metagpt.actions import Action, ActionOutput from metagpt.actions.action_node import ActionNode +from metagpt.actions.add_requirement import UserRequirement from metagpt.llm import LLM, HumanProvider from metagpt.logs import logger from metagpt.memory import Memory @@ -126,7 +127,17 @@ class RoleContext(BaseModel): return self.memory.get() -class Role: +class _RoleInjector(type): + def __call__(cls, *args, **kwargs): + instance = super().__call__(*args, **kwargs) + + if not instance._rc.watch: + instance._watch([UserRequirement]) + + return instance + + +class Role(metaclass=_RoleInjector): """Role/Agent""" def __init__(self, name="", profile="", goal="", constraints="", desc="", is_human=False): @@ -141,6 +152,7 @@ class Role: self._rc = RoleContext() self._subscription = {any_to_str(self), name} if name else {any_to_str(self)} + def _reset(self): self._states = [] self._actions = [] diff --git a/metagpt/schema.py b/metagpt/schema.py index 758149efa..5aec378e4 100644 --- a/metagpt/schema.py +++ b/metagpt/schema.py @@ -121,6 +121,10 @@ class Message(BaseModel): :param send_to: Specifies the target recipient or consumer for message delivery in the environment. :param role: Message meta info tells who sent this message. """ + if not cause_by: + from metagpt.actions import UserRequirement + cause_by = UserRequirement + super().__init__( id=uuid.uuid4().hex, content=content, diff --git a/setup.py b/setup.py index 4dd453b3d..730fffd35 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.0", description="The Multi-Role Meta Programming Framework", long_description=long_description, long_description_content_type="text/markdown",