Skip to content

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

update use Field with uniform rule: define default_factory or exclude, use Field

better62924060ea8a65d
diff --git a/metagpt/environment.py b/metagpt/environment.py
index a3cbe6978..ab296557f 100644
--- a/metagpt/environment.py
+++ b/metagpt/environment.py
@@ -30,7 +30,7 @@ class Environment(BaseModel):
roles: dict[str, Role] = Field(default_factory=dict)
members: dict[Role, Set] = Field(default_factory=dict)
- history: str = Field(default="") # For debug
+ history: str = "" # For debug
class Config:
arbitrary_types_allowed = True
diff --git a/metagpt/memory/memory.py b/metagpt/memory/memory.py
index 66ab5d4e9..076db832a 100644
--- a/metagpt/memory/memory.py
+++ b/metagpt/memory/memory.py
@@ -19,7 +19,7 @@ from metagpt.utils.common import any_to_str, any_to_str_set, read_json_file, wri
class Memory(BaseModel):
"""The most basic memory: super-memory"""
- storage: list[Message] = Field(default=[])
+ storage: list[Message] = []
index: dict[str, list[Message]] = Field(default_factory=defaultdict(list))
def __init__(self, **kwargs):
diff --git a/metagpt/roles/architect.py b/metagpt/roles/architect.py
index a36cd6e93..bd6cd110b 100644
--- a/metagpt/roles/architect.py
+++ b/metagpt/roles/architect.py
@@ -22,11 +22,11 @@ class Architect(Role):
goal (str): Primary goal or responsibility of the architect.
constraints (str): Constraints or guidelines for the architect.
"""
- name: str = Field(default="Bob")
- profile: str = Field(default="Architect")
- goal: str = Field(default="design a concise, usable, complete software system")
- constraints: str = Field(default="make sure the architecture is simple enough and use appropriate open source "
- "libraries. Use same language as user requirement")
+ name: str = "Bob"
+ profile: str = "Architect"
+ goal: str = "design a concise, usable, complete software system"
+ constraints: str = "make sure the architecture is simple enough and use appropriate open source " \
+ "libraries. Use same language as user requirement"
def __init__(self, **kwargs) -> None:
super().__init__(**kwargs)
diff --git a/metagpt/roles/customer_service.py b/metagpt/roles/customer_service.py
index 62792696f..b2033ac0b 100644
--- a/metagpt/roles/customer_service.py
+++ b/metagpt/roles/customer_service.py
@@ -28,9 +28,9 @@ DESC = """
class CustomerService(Sales):
- name: str = Field(default="Xiaomei")
- profile: str = Field(default="Human customer service")
- desc: str = DESC,
+ name: str = "Xiaomei"
+ profile: str = "Human customer service"
+ desc: str = DESC
store: Optional[str] = None
diff --git a/metagpt/roles/engineer.py b/metagpt/roles/engineer.py
index 206afb38c..337184068 100644
--- a/metagpt/roles/engineer.py
+++ b/metagpt/roles/engineer.py
@@ -70,7 +70,7 @@ class Engineer(Role):
use_code_review (bool): Whether to use code review.
"""
name: str = "Alex"
- profile: str = Field(default="Engineer")
+ profile: str = "Engineer"
goal: str = "write elegant, readable, extensible, efficient code"
constraints: str = "the code should conform to standards like google-style and be modular and maintainable. " \
"Use same language as user requirement"
diff --git a/metagpt/roles/product_manager.py b/metagpt/roles/product_manager.py
index 72e5a9be5..6369688a5 100644
--- a/metagpt/roles/product_manager.py
+++ b/metagpt/roles/product_manager.py
@@ -20,13 +20,13 @@ class ProductManager(Role):
Represents a Product Manager role responsible for product development and management.
Attributes:
- name (str): Name of the project manager.
- profile (str): Role profile, default is 'Project Manager'.
- goal (str): Goal of the project manager.
- constraints (str): Constraints or limitations for the project manager.
+ name (str): Name of the product manager.
+ profile (str): Role profile, default is 'Product Manager'.
+ goal (str): Goal of the product manager.
+ constraints (str): Constraints or limitations for the product manager.
"""
name: str = "Alice"
- profile: str = Field(default="Product Manager")
+ profile: str = "Product Manager"
goal: str = "efficiently create a successful product that meets market demands and user expectations"
constraints: str = "utilize the same language as the user requirements for seamless communication"
diff --git a/metagpt/roles/project_manager.py b/metagpt/roles/project_manager.py
index 42564cd70..bf572d1f8 100644
--- a/metagpt/roles/project_manager.py
+++ b/metagpt/roles/project_manager.py
@@ -22,8 +22,8 @@ class ProjectManager(Role):
goal (str): Goal of the project manager.
constraints (str): Constraints or limitations for the project manager.
"""
- name: str = Field(default="Eve")
- profile: str = Field(default="Project Manager")
+ name: str = "Eve"
+ profile: str = "Project Manager"
goal: str = "break down tasks according to PRD/technical design, generate a task list, and analyze task " \
"dependencies to start with the prerequisite modules"
constraints: str = "use same language as user requirement"
diff --git a/metagpt/roles/qa_engineer.py b/metagpt/roles/qa_engineer.py
index 893faa9dd..369e3dc63 100644
--- a/metagpt/roles/qa_engineer.py
+++ b/metagpt/roles/qa_engineer.py
@@ -37,8 +37,8 @@ from metagpt.utils.file_repository import FileRepository
class QaEngineer(Role):
- name: str = Field(default="Edward")
- profile: str = Field(default="QaEngineer")
+ name: str = "Edward"
+ profile: str = "QaEngineer"
goal: str = "Write comprehensive and robust tests to ensure codes will work as expected without bugs"
constraints: str = "The test code you write should conform to code standard like PEP8, be modular, " \
"easy to read and maintain"
diff --git a/metagpt/roles/role.py b/metagpt/roles/role.py
index 4bce64245..f87c4e250 100644
--- a/metagpt/roles/role.py
+++ b/metagpt/roles/role.py
@@ -129,9 +129,9 @@ class Role(BaseModel):
_llm: BaseGPTAPI = Field(default_factory=LLM)
_role_id: str = ""
- _states: list[str] = Field(default=[])
- _actions: list[Action] = Field(default=[])
- _rc: RoleContext = Field(default=RoleContext)
+ _states: list[str] = []
+ _actions: list[Action] = []
+ _rc: RoleContext = Field(default_factory=RoleContext)
_subscription: tuple[str] = set()
# builtin variables
diff --git a/metagpt/roles/sales.py b/metagpt/roles/sales.py
index 826413dc8..fd5a42915 100644
--- a/metagpt/roles/sales.py
+++ b/metagpt/roles/sales.py
@@ -16,14 +16,14 @@ from metagpt.tools import SearchEngineType
class Sales(Role):
- name: str = Field(default="Xiaomei")
- profile: str = Field(default="Retail sales guide")
+ name: str = "Xiaomei"
+ profile: str = "Retail sales guide"
desc: str = "I am a sales guide in retail. My name is Xiaomei. I will answer some customer questions next, and I "
"will answer questions only based on the information in the knowledge base."
"If I feel that you can't get the answer from the reference material, then I will directly reply that"
" I don't know, and I won't tell you that this is from the knowledge base,"
"but pretend to be what I know. Note that each of my replies will be replied in the tone of a "
- "professional guide",
+ "professional guide"
store: Optional[str] = None
diff --git a/metagpt/schema.py b/metagpt/schema.py
index 1bb07aa95..5103a4f20 100644
--- a/metagpt/schema.py
+++ b/metagpt/schema.py
@@ -101,7 +101,7 @@ class Message(BaseModel):
id: str # According to Section 2.2.3.1.1 of RFC 135
content: str
- instruct_content: BaseModel = Field(default=None)
+ instruct_content: BaseModel = None
role: str = "user" # system / user / assistant
cause_by: str = ""
sent_from: str = ""