mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-05-03 12:52:37 +02:00
add an example
This commit is contained in:
parent
587dd0cc81
commit
31764add8a
1 changed files with 24 additions and 0 deletions
24
examples/serialize_model.py
Normal file
24
examples/serialize_model.py
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
from metagpt.logs import logger
|
||||
from metagpt.roles.product_manager import ProductManager
|
||||
|
||||
|
||||
def main():
|
||||
"""Demonstrates serialization and deserialization using SerializationMixin.
|
||||
|
||||
This example creates an instance of ProductManager, serializes it to a file,
|
||||
and then deserializes it back to an instance.
|
||||
|
||||
If executed correctly, the following log messages will be output:
|
||||
ProductManager serialization successful. File saved at: /data/hjt/gitlab_metagpt/workspace/storage/ProductManager.json
|
||||
ProductManager deserialization successful. Instance created from file: /data/hjt/gitlab_metagpt/workspace/storage/ProductManager.json
|
||||
The role is Product Manager
|
||||
"""
|
||||
role = ProductManager()
|
||||
role.serialize()
|
||||
|
||||
role: ProductManager = ProductManager.deserialize()
|
||||
logger.info(f"The role is {role.profile}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Loading…
Add table
Add a link
Reference in a new issue