mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-06-08 15:05:17 +02:00
feat: revert
This commit is contained in:
parent
9ff489b6c6
commit
cc89f3b726
1 changed files with 2 additions and 16 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue