diff --git a/config/config2.example.yaml b/config/config2.example.yaml index c5454ec32..f1158775b 100644 --- a/config/config2.example.yaml +++ b/config/config2.example.yaml @@ -13,6 +13,37 @@ llm: # - gpt-4 8k: "gpt-4" # See for more: https://azure.microsoft.com/en-us/pricing/details/cognitive-services/openai-service/ +# Role's custom configuration +roles: + - role: "ProductManager" # role's className or role's role_id + llm: + api_type: "openai" # or azure / ollama / open_llm etc. Check LLMType for more options + base_url: "YOUR_BASE_URL" + api_key: "YOUR_API_KEY" + proxy: "YOUR_PROXY" # for LLM API requests + model: "gpt-4-turbo-1106" + - role: "Architect" + llm: + api_type: "openai" # or azure / ollama / open_llm etc. Check LLMType for more options + base_url: "YOUR_BASE_URL" + api_key: "YOUR_API_KEY" + proxy: "YOUR_PROXY" # for LLM API requests + model: "gpt-35-turbo" + - role: "ProjectManager" + llm: + api_type: "azure" + base_url: "YOUR_BASE_URL" + api_key: "YOUR_API_KEY" + api_version: "YOUR_API_VERSION" + model: "gpt-4-1106" + - role: "Engineer" + llm: + api_type: "azure" + base_url: "YOUR_BASE_URL" + api_key: "YOUR_API_KEY" + api_version: "YOUR_API_VERSION" + model: "gpt-35-turbo-1106" + repair_llm_output: true # when the output is not a valid json, try to repair it proxy: "YOUR_PROXY" # for tools like requests, playwright, selenium, etc. diff --git a/metagpt/config2.py b/metagpt/config2.py index cf5ed0da1..8c61fdbf2 100644 --- a/metagpt/config2.py +++ b/metagpt/config2.py @@ -15,6 +15,7 @@ from metagpt.configs.browser_config import BrowserConfig from metagpt.configs.llm_config import LLMConfig, LLMType from metagpt.configs.mermaid_config import MermaidConfig from metagpt.configs.redis_config import RedisConfig +from metagpt.configs.role_custom_config import RoleCustomConfig from metagpt.configs.s3_config import S3Config from metagpt.configs.search_config import SearchConfig from metagpt.configs.workspace_config import WorkspaceConfig @@ -76,6 +77,9 @@ class Config(CLIParams, YamlModel): azure_tts_subscription_key: str = "" azure_tts_region: str = "" + # Role's custom configuration + roles: Optional[List[RoleCustomConfig]] = None + @classmethod def from_home(cls, path): """Load config from ~/.metagpt/config2.yaml""" diff --git a/metagpt/configs/role_custom_config.py b/metagpt/configs/role_custom_config.py new file mode 100644 index 000000000..414c2a793 --- /dev/null +++ b/metagpt/configs/role_custom_config.py @@ -0,0 +1,19 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +""" +@Time : 2024/4/22 16:33 +@Author : Justin +@File : role_custom_config.py +""" +from metagpt.configs.llm_config import LLMConfig +from metagpt.utils.yaml_model import YamlModel + + +class RoleCustomConfig(YamlModel): + """custom config for roles + role: role's className or role's role_id + To be expanded + """ + role: str = "" + llm: LLMConfig + diff --git a/metagpt/roles/role.py b/metagpt/roles/role.py index e0f8a7ea6..e012b0fe7 100644 --- a/metagpt/roles/role.py +++ b/metagpt/roles/role.py @@ -43,7 +43,6 @@ from metagpt.utils.repair_llm_raw_output import extract_state_value_from_output if TYPE_CHECKING: from metagpt.environment import Environment # noqa: F401 - PREFIX_TEMPLATE = """You are a {profile}, named {name}, your goal is {goal}. """ CONSTRAINT_TEMPLATE = "the constraint is {constraints}. "