refactor: @cause_by.setter

This commit is contained in:
莘权 马 2023-11-04 16:52:21 +08:00
parent 56f544a675
commit 8ea52d8a83
2 changed files with 2 additions and 4 deletions

View file

@ -2,8 +2,6 @@
Filename: MetaGPT/examples/build_customized_agent.py
Created Date: Tuesday, September 19th 2023, 6:52:25 pm
Author: garylin2099
@Modified By: mashenquan, 2023-11-1. According to Chapter 2.2.1 and 2.2.2 of RFC 116, change the data type of
the `cause_by` value in the `Message` to a string to support the new message distribution feature.
"""
import asyncio
import re
@ -83,7 +81,7 @@ class SimpleCoder(Role):
instruction = msg.content
code_text = await SimpleWriteCode().run(instruction)
msg = Message(content=code_text, role=self.profile, cause_by=get_object_name(todo))
msg = Message(content=code_text, role=self.profile, cause_by=todo)
return msg

View file

@ -135,7 +135,7 @@ class Message(BaseModel):
self.set_cause_by(v)
continue
if k == MESSAGE_ROUTE_TO:
self.add_to(v)
self.add_to(any_to_str(v))
continue
self.meta_info[k] = v