Skip to content

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

add `enable_longterm_memory` config

seehi99e5a73fbb91
diff --git a/config/config2.example.yaml b/config/config2.example.yaml
index 1c0934567..e4dfff1eb 100644
--- a/config/config2.example.yaml
+++ b/config/config2.example.yaml
@@ -84,7 +84,7 @@ exp_pool:
collection_name: experience_pool # When `retrieval_type` is `chroma`, `collection_name` is the collection name in chromadb.
role_zero:
- enable_longterm_memory: false # Whether to use long-term memory.
+ enable_longterm_memory: false # Whether to use long-term memory. Default is `false`.
azure_tts_subscription_key: "YOUR_SUBSCRIPTION_KEY"
azure_tts_region: "eastus"
diff --git a/metagpt/config2.py b/metagpt/config2.py
index c328713c5..fd0cb0948 100644
--- a/metagpt/config2.py
+++ b/metagpt/config2.py
@@ -91,7 +91,7 @@ class Config(CLIParams, YamlModel):
roles: Optional[List[RoleCustomConfig]] = None
# RoleZero's configuration
- role_zero: Optional[RoleZeroConfig] = None
+ role_zero: RoleZeroConfig = Field(default_factory=RoleZeroConfig)
omniparse: Optional[OmniParseConfig] = None
diff --git a/metagpt/roles/di/role_zero.py b/metagpt/roles/di/role_zero.py
index 9b68378cb..f77471a2a 100644
--- a/metagpt/roles/di/role_zero.py
+++ b/metagpt/roles/di/role_zero.py
@@ -173,7 +173,7 @@ class RoleZero(Role):
The role name will be used as the collection name.
"""
- if self.config.role_zero and self.config.role_zero.enable_longterm_memory:
+ if self.config.role_zero.enable_longterm_memory:
self.rc.memory = RoleZeroLongTermMemory(collection_name=self.name.replace(" ", ""), memory_k=self.memory_k)
logger.info(f"Long-term memory set for role '{self.name}'")