Skip to content

🌟 The Multi-Agent Framework: First AI Software Company, Towards Natural Language Programming

add: add role's custom config

zhangleib50a6062a170
diff --git a/config/config2.example.yaml b/config/config2.example.yaml
index c65a357b7..f1158775b 100644
--- a/config/config2.example.yaml
+++ b/config/config2.example.yaml
@@ -14,7 +14,6 @@ llm:
# See for more: https://azure.microsoft.com/en-us/pricing/details/cognitive-services/openai-service/
# Role's custom configuration
-# Priority: Role's configuration > Global configuration
roles:
- role: "ProductManager" # role's className or role's role_id
llm:
diff --git a/metagpt/config2.py b/metagpt/config2.py
index 021031df7..8c61fdbf2 100644
--- a/metagpt/config2.py
+++ b/metagpt/config2.py
@@ -77,7 +77,7 @@ class Config(CLIParams, YamlModel):
azure_tts_subscription_key: str = ""
azure_tts_region: str = ""
- # Role's custom configuration, Priority: Role's configuration > Global configuration
+ # Role's custom configuration
roles: Optional[List[RoleCustomConfig]] = None
@classmethod
diff --git a/metagpt/roles/role.py b/metagpt/roles/role.py
index a5256b201..dcaf8032a 100644
--- a/metagpt/roles/role.py
+++ b/metagpt/roles/role.py
@@ -167,12 +167,6 @@ class Role(SerializationMixin, ContextMixin, BaseModel):
if self.is_human:
self.llm = HumanProvider(None)
- if self.context.config.roles:
- _context, _in = self.get_custom_role_config()
- if _in:
- self.context = _context
- self.llm = LLM(llm_config=self.context.config.llm)
-
self._check_actions()
self.llm.system_prompt = self._get_prefix()
self.llm.cost_manager = self.context.cost_manager
@@ -246,29 +240,6 @@ class Role(SerializationMixin, ContextMixin, BaseModel):
def _setting(self):
return f"{self.name}({self.profile})"
- def get_custom_role_config(self):
- """
- check and get current role's custom config
- 1.Check if the custom configurations exist
- 2.Check if the current role exist in custom configurations
- 3.Update corresponding configurations item by item based on custom configurations
- :return:
- _context:replaced the corresponding configuration context with custom config
- _in:current role has custom config
- """
- _context = self.context
- _in = False
- if self and self.context.config.roles:
- for role_config in self.context.config.roles:
- if (not bool(self.role_id) and self.role_id == role_config.role) or type(
- self).__name__ == role_config.role:
- _in = True
- for key, _ in role_config.model_fields.items():
- if key not in ["role", "extra_fields"]:
- setattr(_context.config, key, getattr(role_config, key))
- break
- return _context, _in
-
def _check_actions(self):
"""Check actions and set llm and prefix for each action."""
self.set_actions(self.actions)