mirror of
https://github.com/agentscope-ai/ReMe.git
synced 2026-09-06 08:16:00 +00:00
[dev] rename base memory service params
This commit is contained in:
parent
a082bd67ae
commit
d095e87f3d
3 changed files with 16 additions and 9 deletions
|
|
@ -10,7 +10,7 @@ memory_chat:
|
|||
generation_model: dashscope_generation
|
||||
memory_service:
|
||||
memory_chat_service:
|
||||
class: memory.service.base_memory_service
|
||||
class: memory.service.chat_memory_service
|
||||
history_msg_count: 32
|
||||
contextual_msg_count: 6
|
||||
memory_operations:
|
||||
|
|
|
|||
|
|
@ -8,26 +8,36 @@ from memory_scope.utils.logger import Logger
|
|||
|
||||
|
||||
class BaseMemoryService(metaclass=ABCMeta):
|
||||
def __init__(self, read_memory_key: str = "read_memory", **kwargs):
|
||||
def __init__(self,
|
||||
memory_operations: Dict[str, dict],
|
||||
read_memory_key: str = "read_memory",
|
||||
**kwargs):
|
||||
self.memory_operations: Dict[str, dict] = memory_operations
|
||||
self.read_memory_key: str = read_memory_key
|
||||
|
||||
self._operation_dict: Dict[str, BaseOperation] = {}
|
||||
self._op_description_dict: Dict[str, str] = {}
|
||||
|
||||
self.chat_messages: List[Message] = []
|
||||
self.message_lock = threading.Lock
|
||||
|
||||
self.logger = Logger.get_logger()
|
||||
self.kwargs = kwargs
|
||||
|
||||
self._init_operation(memory_operations)
|
||||
|
||||
@abstractmethod
|
||||
def _init_operation(self, memory_operations: Dict[str, dict]):
|
||||
raise NotImplementedError
|
||||
|
||||
@abstractmethod
|
||||
def add_messages(self, messages: List[Message] | Message):
|
||||
pass
|
||||
raise NotImplementedError
|
||||
|
||||
def prepare_service(self):
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def operate(self, op_name: str):
|
||||
def do_operation(self, op_name: str):
|
||||
raise NotImplementedError
|
||||
|
||||
@property
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ from memory_scope.utils.tool_functions import init_instance_by_config
|
|||
class ChatMemoryService(BaseMemoryService):
|
||||
|
||||
def __init__(self,
|
||||
memory_operations: Dict[str, dict],
|
||||
history_msg_count: int = 32,
|
||||
contextual_msg_count: int = 6,
|
||||
**kwargs):
|
||||
|
|
@ -17,8 +16,6 @@ class ChatMemoryService(BaseMemoryService):
|
|||
self.contextual_msg_count: int = contextual_msg_count
|
||||
assert self.history_msg_count >= self.contextual_msg_count
|
||||
|
||||
self._init_operation(memory_operations)
|
||||
|
||||
def _init_operation(self, memory_operations: Dict[str, dict]):
|
||||
for name, operation_config in memory_operations.items():
|
||||
if name in self._operation_dict:
|
||||
|
|
@ -47,7 +44,7 @@ class ChatMemoryService(BaseMemoryService):
|
|||
if operation.operation_type == "backend":
|
||||
operation.run_operation_backend()
|
||||
|
||||
def operate(self, op_name: str):
|
||||
def do_operation(self, op_name: str):
|
||||
if op_name not in self._operation_dict:
|
||||
self.logger.warning(f"op_name={op_name} is not inited!")
|
||||
return
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue