MetaGPT
MetaGPT copied to clipboard
pydantic.error_wrappers.ValidationError: 2 validation errors for system_design
trafficstars
After the program ran to Data structures and interface definitions:, an error occurred. May I ask what caused it?
`## Data structures and interface definitions:
classDiagram
class Student{
+id: int
+name: str
+age: int
+grade: int
+attendance: List[Attendance]
+grades: List[Grade]
+behaviors: List[Behavior]
}
class Attendance{
+id: int
+date: datetime
+status: str
+student: Student
}
class Grade{
+id: int
+subject: str
+score: float
+student: Student
}
class Behavior{
+id: int
+description: str
+date: datetime
+student: Student
}
class Report{
+id: int
+title: str
+content: str
+student: Student
}
class User{
+id: int
+username: str
+password: str
+role: str
}
class Teacher{
+id: int
+name: str
+students: List[Student]
}
class Administrator{
+id: int
+name: str
+students: List[Student]
}
class Parent{
+id: int
+name: str
+students: List[Student]
}
class StudentManagementSystem{
+students: List[Student]
+teachers: List[Teacher]
+administrators: List[Administrator]
+parents: List[Parent]
+reports: List[Report]
+users: List[User]
+add_student(student: Student): None
+remove_student(student: Student): None
+add_teacher(teacher: Teacher): None
+remove_teacher(teacher: Teacher): None
+add_administrator(administrator: Administrator): None
+remove_administrator(administrator: Administrator): None
+add_parent(parent: Parent): None
+remove_parent(parent: Parent): None
+add_report(report: Report): None
+remove_report(report: Report): None
+add_user(user: User): None
+remove_user(user: User): None
}
class StudentManagementSystemApp{
+run(): None
}
Student "1" -- "1" Attendance: has
Student "1" -- "1" Grade: has
Student "1" -- "1" Behavior: has
Student "1" -- "1" Report: has
Teacher "1" -- "*" Student: teaches
Administrator "1" -- "*" Student: manages
Parent "1" -- "*" Student: has
User "1" -- "*" StudentManagementSystem: manages
User "1" -- "*" Teacher: manages
User "1" -- "*" Administrator: manages
User "1" -- "*" Parent: manages
Report "1" -- "1" Student: belongs to
StudentManagementSystem "1" -- "*" Student: has
StudentManagementSystem "1" -- "*" Teacher: has
StudentManagementSystem "1" -- "*" Administrator: has
StudentManagementSystem "1" -- "*" Parent: has
StudentManagementSystem "1" -- "*" Report: has
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/tenacity/_asyncio.py", line 50, in __call__
result = await fn(*args, **kwargs)
File "/Users/Panda/Documents/PythonProject/JustForFun/metagpt/metagpt/actions/action.py", line 62, in _aask_v1
instruct_content = output_class(**parsed_data)
File "pydantic/main.py", line 341, in pydantic.main.BaseModel.__init__
pydantic.error_wrappers.ValidationError: 2 validation errors for system_design
Program call flow
field required (type=value_error.missing)
Anything UNCLEAR
field required (type=value_error.missing)
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/Users/Panda/Documents/PythonProject/JustForFun/metagpt/startup.py", line 41, in <module>
fire.Fire(main)
File "/usr/local/lib/python3.9/site-packages/fire/core.py", line 141, in Fire
component_trace = _Fire(component, args, parsed_flag_args, context, name)
File "/usr/local/lib/python3.9/site-packages/fire/core.py", line 466, in _Fire
component, remaining_args = _CallAndUpdateTrace(
File "/usr/local/lib/python3.9/site-packages/fire/core.py", line 681, in _CallAndUpdateTrace
component = fn(*varargs, **kwargs)
File "/Users/Panda/Documents/PythonProject/JustForFun/metagpt/startup.py", line 37, in main
asyncio.run(startup(idea, investment, n_round, code_review, run_tests))
File "/usr/local/Cellar/[email protected]/3.9.7/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/usr/local/Cellar/[email protected]/3.9.7/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
return future.result()
File "/Users/Panda/Documents/PythonProject/JustForFun/metagpt/startup.py", line 25, in startup
await company.run(n_round=n_round)
File "/Users/Panda/Documents/PythonProject/JustForFun/metagpt/metagpt/software_company.py", line 60, in run
await self.environment.run()
File "/Users/Panda/Documents/PythonProject/JustForFun/metagpt/metagpt/environment.py", line 56, in run
await asyncio.gather(*futures)
File "/Users/Panda/Documents/PythonProject/JustForFun/metagpt/metagpt/roles/role.py", line 240, in run
rsp = await self._react()
File "/Users/Panda/Documents/PythonProject/JustForFun/metagpt/metagpt/roles/role.py", line 209, in _react
return await self._act()
File "/Users/Panda/Documents/PythonProject/JustForFun/metagpt/metagpt/roles/role.py", line 168, in _act
response = await self._rc.todo.run(self._rc.important_memory)
File "/Users/Panda/Documents/PythonProject/JustForFun/metagpt/metagpt/actions/design_api.py", line 141, in run
system_design = await self._aask_v1(prompt, "system_design", OUTPUT_MAPPING)
File "/usr/local/lib/python3.9/site-packages/tenacity/_asyncio.py", line 88, in async_wrapped
return await fn(*args, **kwargs)
File "/usr/local/lib/python3.9/site-packages/tenacity/_asyncio.py", line 47, in __call__
do = self.iter(retry_state=retry_state)
File "/usr/local/lib/python3.9/site-packages/tenacity/__init__.py", line 326, in iter
raise retry_exc from fut.exception()
tenacity.RetryError: RetryError[<Future at 0x11da55880 state=finished raised ValidationError>]
`
you need to define the customized OUTPUT_MAPPING or follow the predefined OUTPUT_MAPPING
This problem actually comes from the poor Instruction Following of gpt-3.5-turbo. gpt-4 basically does not have this problem