From cc89f3b7263e24a445f42fec92282480029a1660 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8E=98=E6=9D=83=20=E9=A9=AC?= Date: Sat, 26 Aug 2023 21:55:34 +0800 Subject: [PATCH] feat: revert --- metagpt/memory/memory.py | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/metagpt/memory/memory.py b/metagpt/memory/memory.py index 1a8003fba..a96aaf1be 100644 --- a/metagpt/memory/memory.py +++ b/metagpt/memory/memory.py @@ -4,8 +4,6 @@ @Time : 2023/5/20 12:15 @Author : alexanderwu @File : memory.py -@Modified By: mashenquan, 2023-8-7. Modified get_by_actions() to support for dynamically generated Action classes - at runtime. """ from collections import defaultdict from typing import Iterable, Type @@ -82,20 +80,8 @@ class Memory: def get_by_actions(self, actions: Iterable[Type[Action]]) -> list[Message]: """Return all messages triggered by specified Actions""" rsp = [] - # Using the `type(obj).__name__` approach to support the runtime creation of requirement classes. - # See `MetaAction.get_action_type()` for more. - class_names = {type(k).__name__: k for k in self.index.keys()} for action in actions: - if type(action).__name__ not in class_names: + if action not in self.index: continue - key = class_names[type(action).__name__] - rsp += self.index[key] + rsp += self.index[action] return rsp - - def get_by_tags(self, tags: list) -> list[Message]: - """Return messages with specified tags""" - result = [] - for m in self.storage: - if m.is_contain_tags(tags): - result.append(m) - return result