🌟 The Multi-Agent Framework: First AI Software Company, Towards Natural Language Programming
refactor: get_class_name
莘权 马3c38c5c41678
diff --git a/metagpt/actions/write_code.py b/metagpt/actions/write_code.pyindex be8690314..aeaa10aec 100644--- a/metagpt/actions/write_code.py+++ b/metagpt/actions/write_code.py@@ -14,7 +14,7 @@ from metagpt.actions.action import Actionfrom metagpt.const import WORKSPACE_ROOTfrom metagpt.logs import loggerfrom metagpt.schema import Message-from metagpt.utils.common import CodeParser, get_class_name+from metagpt.utils.common import CodeParser, any_to_strPROMPT_TEMPLATE = """NOTICE@@ -58,7 +58,7 @@ class WriteCode(Action):if self._is_invalid(filename):return- design = [i for i in context if i.cause_by == get_class_name(WriteDesign)][0]+ design = [i for i in context if i.cause_by == any_to_str(WriteDesign)][0]ws_name = CodeParser.parse_str(block="Python package name", text=design.content)ws_path = WORKSPACE_ROOT / ws_namediff --git a/metagpt/memory/memory.py b/metagpt/memory/memory.pyindex 84289091f..9d526420f 100644--- a/metagpt/memory/memory.py+++ b/metagpt/memory/memory.py@@ -10,6 +10,7 @@ from collections import defaultdictfrom typing import Iterable, Setfrom metagpt.schema import Message+from metagpt.utils.common import any_to_str, any_to_str_setclass Memory:@@ -73,14 +74,16 @@ class Memory:news.append(i)return news- def get_by_action(self, action: str) -> list[Message]:+ def get_by_action(self, action) -> list[Message]:"""Return all messages triggered by a specified Action"""- return self.index[action]+ idx = any_to_str(action)+ return self.index[idx]- def get_by_actions(self, actions: Set[str]) -> list[Message]:+ def get_by_actions(self, actions: Set) -> list[Message]:"""Return all messages triggered by specified Actions"""+ idxs = any_to_str_set(actions)rsp = []- for action in actions:+ for action in idxs:if action not in self.index:continuersp += self.index[action]