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

This commit is contained in:
better629 2023-12-21 00:18:09 +08:00
parent 0543c0f76b
commit 24060ea8a6
11 changed files with 27 additions and 27 deletions

View file

@ -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

View file

@ -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):

View file

@ -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)

View file

@ -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

View file

@ -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"

View file

@ -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"

View file

@ -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"

View file

@ -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"

View file

@ -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

View file

@ -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

View file

@ -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 = ""