mirror of
https://github.com/agentscope-ai/ReMe.git
synced 2026-08-28 05:25:04 +00:00
refactor(memory): update memory target mappings and profile handling
This commit is contained in:
parent
c06fd78763
commit
3989a3c1c4
7 changed files with 16 additions and 21 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -34,7 +34,7 @@ test_compact_storage/*
|
|||
test_working_memory/*
|
||||
*.code-workspace
|
||||
local_vector_store/*
|
||||
reme_local_memory/*
|
||||
reme_profile/*
|
||||
chroma_vector_store/*
|
||||
bench_results/*
|
||||
meta_memory/*
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@ from typing import Any
|
|||
|
||||
from loguru import logger
|
||||
|
||||
from reme.core.schema import MemoryNode, Message
|
||||
from reme.reme import ReMe
|
||||
|
||||
|
||||
|
|
@ -328,7 +327,7 @@ class MemoryProcessor:
|
|||
# Retrieve memories from ReMe using new API
|
||||
result = await self.reme.retrieve_memory(
|
||||
query=query,
|
||||
top_k=top_k,
|
||||
retrieve_top_k=top_k,
|
||||
user_name=user_id,
|
||||
version="default",
|
||||
return_dict=True,
|
||||
|
|
@ -637,7 +636,8 @@ class HaluMemEvaluator:
|
|||
for user_data in all_users
|
||||
]
|
||||
if all_user_names:
|
||||
await self.reme.delete_all_profiles(all_user_names)
|
||||
for user_name in all_user_names:
|
||||
self.reme.get_profile_handler(user_name).delete_all()
|
||||
logger.info(f"Deleted all profiles for {len(all_user_names)} users")
|
||||
|
||||
# Clear existing data
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ class BaseMemoryAgent(BaseReact, metaclass=ABCMeta):
|
|||
@property
|
||||
def memory_target_type_mapping(self) -> dict[str, MemoryType]:
|
||||
"""Get the memory target type mapping from context."""
|
||||
return self.context.memory_target_type_mapping
|
||||
return self.context.service_context.memory_target_type_mapping
|
||||
|
||||
@property
|
||||
def meta_memory_info(self) -> str:
|
||||
|
|
|
|||
|
|
@ -107,15 +107,9 @@ class PersonalSummarizer(BaseMemoryAgent):
|
|||
if tool.memory_nodes:
|
||||
memory_nodes.extend(tool.memory_nodes)
|
||||
|
||||
profile_nodes = []
|
||||
for tool in tools:
|
||||
if tool.profile_nodes:
|
||||
profile_nodes.extend(tool.profile_nodes)
|
||||
|
||||
return {
|
||||
"answer": memory_nodes,
|
||||
"success": success,
|
||||
"messages": messages,
|
||||
"tools": tools,
|
||||
"profile_nodes": profile_nodes,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ class ReMeSummarizer(BaseMemoryAgent):
|
|||
await add_history_tool.call(
|
||||
messages=self.messages,
|
||||
description=self.description,
|
||||
author=self.author,
|
||||
service_context=self.service_context,
|
||||
)
|
||||
self.context.history_node = add_history_tool.context.history_node
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ class BaseMemoryTool(BaseTool, metaclass=ABCMeta):
|
|||
@property
|
||||
def memory_target_type_mapping(self) -> dict[str, MemoryType]:
|
||||
"""Get the memory target type mapping from context."""
|
||||
return self.context.memory_target_type_mapping
|
||||
return self.context.service_context.memory_target_type_mapping
|
||||
|
||||
@property
|
||||
def profile_path(self) -> Path:
|
||||
|
|
|
|||
|
|
@ -31,28 +31,28 @@ class DelegateTask(BaseMemoryTool):
|
|||
"parameters": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"tasks": {
|
||||
"memory_target_tasks": {
|
||||
"type": "array",
|
||||
"description": "tasks to delegate to specific agents, each task is a memory_target",
|
||||
"description": "List of memory_target tasks to delegate to specific memory agents",
|
||||
"items": {
|
||||
"type": "string",
|
||||
"description": "memory_target to delegate to specific agents",
|
||||
"description": "A memory_target identifier to delegate to the corresponding agent",
|
||||
},
|
||||
},
|
||||
},
|
||||
"required": ["tasks"],
|
||||
"required": ["memory_target_tasks"],
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
async def execute(self):
|
||||
# Deduplicate and validate tasks
|
||||
tasks = self.context.get("tasks", [])
|
||||
tasks = sorted(set(tasks))
|
||||
# Deduplicate and validate memory_target_tasks
|
||||
memory_target_tasks = self.context.get("memory_target_tasks", [])
|
||||
memory_target_tasks = sorted(set(memory_target_tasks))
|
||||
|
||||
# Submit tasks to agents
|
||||
# Submit memory_target_tasks to agents
|
||||
agent_list: list[BaseMemoryAgent] = []
|
||||
for i, memory_target in enumerate(tasks):
|
||||
for i, memory_target in enumerate(memory_target_tasks):
|
||||
memory_type = self.memory_target_type_mapping[memory_target]
|
||||
agent = self.memory_agent_dict[memory_type].copy()
|
||||
agent_list.append(agent)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue