From 8ea52d8a83ce9615b56831fdd9c27c82e0c885f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8E=98=E6=9D=83=20=E9=A9=AC?= Date: Sat, 4 Nov 2023 16:52:21 +0800 Subject: [PATCH] refactor: @cause_by.setter --- examples/build_customized_agent.py | 4 +--- metagpt/schema.py | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/examples/build_customized_agent.py b/examples/build_customized_agent.py index af15c90ca..f7f554e53 100644 --- a/examples/build_customized_agent.py +++ b/examples/build_customized_agent.py @@ -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 diff --git a/metagpt/schema.py b/metagpt/schema.py index 1082c5ddb..0be067cfe 100644 --- a/metagpt/schema.py +++ b/metagpt/schema.py @@ -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