Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update breakpoint_recovery due to serialize using one single file #61

Merged
merged 2 commits into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
234 changes: 108 additions & 126 deletions src/en/guide/in_depth_guides/breakpoint_recovery.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,144 +18,126 @@ In order to support breakpoint recovery operations, the output of different modu

### Serialized storage structure

In order to clarify the structural information of the overall serialized project, a hierarchical approach is used to serialize and store the content.
In order to reduce the impact of subsequent new functions on the storage structure, an "integrated" single json file is used for storage.

When the program is interrupted, the file structure corresponding to different modules in the storage directory is as follows:

Structure summary
When the program is interrupted or terminated, the file structure in the storage directory is as follows:

```bash
./workspace
storage
team
team_info.json # team idea and investment
environment # environment
roles.json # role basic info of the team
history.json # 历史信息
roles # 团队内角色
RoleA_Alice # 具体一个角色
memory.json # 角色记忆
role_info.json # 包括角色身份、执行动作、监听动作等信息
team.json # Contains information such as team, environment, roles, actions, etc.
```

Under each `xxx.json` is a data summary example of the corresponding content.

```bash
./workspace
storage
team
team_info.json # investment and so on
{
"investment": 10.0,
"idea": "write a snake game"
}
environment
roles.json # roles' meta info
[
{
"role_class": "RoleA",
"module_name": "tests.metagpt.serialize_deserialize.test_serdeser_base",
"role_name": "RoleA"
Example of data summary corresponding to `team.json`.

```json
{
"env": {
"desc": "",
"roles": {
"Role A": {},
"Role B": {
"name": "RoleB",
"profile": "Role B",
"goal": "RoleB's goal",
"constraints": "RoleB's constraints",
"desc": "",
"is_human": false,
"role_id": "",
"states": [
"0. <class 'tests.metagpt.serialize_deserialize.test_serdeser_base.ActionOK'>",
"1. <class 'tests.metagpt.serialize_deserialize.test_serdeser_base.ActionRaise'>"
],
"actions": [
{
"name": "ActionOK",
"context": "",
"prefix": "You are a Role B, named RoleB, your goal is RoleB's goal. the constraint is RoleB's constraints. ",
"desc": "",
"__module_class_name": "tests.metagpt.serialize_deserialize.test_serdeser_base.ActionOK"
},
{
"name": "ActionRaise",
"context": "",
"prefix": "You are a Role B, named RoleB, your goal is RoleB's goal. the constraint is RoleB's constraints. ",
"desc": "",
"__module_class_name": "tests.metagpt.serialize_deserialize.test_serdeser_base.ActionRaise"
}
],
"rc": {
"memory": {
"storage": [
{
"id": "7cc01798c3324c6c8b676d282ea9e92c",
"content": "ActionPass run passed",
"instruct_content": {
"class": "pass",
"mapping": {
"result": "(<class 'str'>, Ellipsis)"
},
"value": {
"result": "pass result"
}
},
"role": "RoleA(Role A)",
"cause_by": "tests.metagpt.serialize_deserialize.test_serdeser_base.ActionPass",
"sent_from": "tests.metagpt.serialize_deserialize.test_serdeser_base.RoleA",
"send_to": ["<all>"]
}
],
"index": {
"tests.metagpt.serialize_deserialize.test_serdeser_base.ActionOK": [
{
"role_class": "RoleB",
"module_name": "tests.metagpt.serialize_deserialize.test_serdeser_base",
"role_name": "RoleB"
"id": "018bde1d4bdb4e9387c1053da0dc0cb3",
"content": "ok",
"instruct_content": null,
"role": "Role B",
"cause_by": "tests.metagpt.serialize_deserialize.test_serdeser_base.ActionOK",
"sent_from": "tests.metagpt.serialize_deserialize.test_serdeser_base.RoleB",
"send_to": ["<all>"]
}
]
history.json
{
"content": "\nHuman: write a snake game\nRole A: ActionPass run passed\nHuman: write a snake game"
]
},
"ignore_id": false
},
"state": 1,
"watch": [
"tests.metagpt.serialize_deserialize.test_serdeser_base.ActionPass"
],
"react_mode": "by_order",
"max_react_loop": 1
},
"addresses": [
"RoleB",
"tests.metagpt.serialize_deserialize.test_serdeser_base.RoleB"
],
"recovered": true,
"latest_observed_msg": {
"id": "7cc01798c3324c6c8b676d282ea9e92c",
"content": "ActionPass run passed",
"instruct_content": {
"class": "pass",
"mapping": {
"result": "(<class 'str'>, Ellipsis)"
},
"value": {
"result": "pass result"
}
roles
ProductManager_Alice
memory.json
{
"storage": [
{
"id": "70a3450d0d5c4900afefe7e8d60f3c65",
"content": "ActionPass run passed",
"instruct_content": {
"class": "pass",
"mapping": {
"result": "(<class 'str'>, Ellipsis)"
},
"value": {
"result": "pass result"
}
},
"role": "Role A",
"cause_by": "tests.metagpt.serialize_deserialize.test_serdeser_base.ActionPass",
"sent_from": "tests.metagpt.serialize_deserialize.test_serdeser_base.RoleA",
"send_to": [
"<all>"
]
}
],
"index": {
"tests.metagpt.serialize_deserialize.test_serdeser_base.ActionPass": [
{
"id": "70a3450d0d5c4900afefe7e8d60f3c65",
"content": "ActionPass run passed",
"instruct_content": {
"class": "pass",
"mapping": {
"result": "(<class 'str'>, Ellipsis)"
},
"value": {
"result": "pass result"
}
},
"role": "Role A",
"cause_by": "tests.metagpt.serialize_deserialize.test_serdeser_base.ActionPass",
"sent_from": "tests.metagpt.serialize_deserialize.test_serdeser_base.RoleA",
"send_to": [
"<all>"
]
}
]
}
}
role_info.json # RoleSetting _actions _states
{
"name": "RoleA",
"profile": "Role A",
"goal": "RoleA's goal",
"constraints": "RoleA's constraints",
"desc": "",
"is_human": false,
"recovered": true,
"builtin_class_name": "RoleA",
"_role_id": "RoleA(Role A)",
"_states": [
"0. <class 'tests.metagpt.serialize_deserialize.test_serdeser_base.ActionPass'>"
],
"_actions": [
{
"name": "",
"builtin_class_name": "ActionPass",
"context": "",
"prefix": "You are a Role A, named RoleA, your goal is RoleA's goal, and the constraint is RoleA's constraints. ",
"profile": "Role A",
"desc": "",
"nodes": []
}
],
"_rc": {
"state": -1,
"watch": [
"metagpt.actions.add_requirement.UserRequirement"
],
"react_mode": "react",
"max_react_loop": 1
},
"_subscription": [
"tests.metagpt.serialize_deserialize.test_serdeser_base.RoleA",
"RoleA"
],
"role_class": "RoleA",
"module_name": "tests.metagpt.serialize_deserialize.test_serdeser_base"
}
},
"role": "RoleA(Role A)",
"cause_by": "tests.metagpt.serialize_deserialize.test_serdeser_base.ActionPass",
"sent_from": "tests.metagpt.serialize_deserialize.test_serdeser_base.RoleA",
"send_to": ["<all>"]
},
"__module_class_name": "tests.metagpt.serialize_deserialize.test_serdeser_base.RoleB"
}
},
"history": "\nHuman: write a snake game\nRoleA(Role A): {'result': 'pass result'}\nHuman: write a snake game"
},
"investment": 10.0,
"idea": "write a snake game"
}
```

### Execution order during recovery
Expand Down
Loading