diff --git a/metagpt/actions/write_code.py b/metagpt/actions/write_code.py index f2a4744d9..be8690314 100644 --- a/metagpt/actions/write_code.py +++ b/metagpt/actions/write_code.py @@ -4,8 +4,8 @@ @Time : 2023/5/11 17:45 @Author : alexanderwu @File : write_code.py -@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. +@Modified By: mashenquan, 2023-11-1. In accordance with Chapter 2.1.3 of RFC 116, modify the data type of the `cause_by` + value of the `Message` object. """ from tenacity import retry, stop_after_attempt, wait_fixed @@ -14,7 +14,7 @@ from metagpt.actions.action import Action from metagpt.const import WORKSPACE_ROOT from metagpt.logs import logger from metagpt.schema import Message -from metagpt.utils.common import CodeParser +from metagpt.utils.common import CodeParser, get_class_name PROMPT_TEMPLATE = """ NOTICE @@ -58,8 +58,7 @@ class WriteCode(Action): if self._is_invalid(filename): return - message_filter = {WriteDesign} - design = [i for i in context if i.contain_any(message_filter)][0] + design = [i for i in context if i.cause_by == get_class_name(WriteDesign)][0] ws_name = CodeParser.parse_str(block="Python package name", text=design.content) ws_path = WORKSPACE_ROOT / ws_name