agents.memory_v2.standalone_rag_memoryΒΆ
Standalone RAG-based Memory Agent using BaseRAGAgent with retrievers.
This module provides memory-capable agents built on BaseRAGAgent without dependencies on the broken memory module. All models are defined here.
Key features: 1. ConversationMemoryAgent - conversation history with time-weighting 2. FactualMemoryAgent - factual information storage and retrieval 3. PreferencesMemoryAgent - user preferences with generation 4. UnifiedMemoryRAGAgent - coordinates all memory types 5. Real BaseRAGAgent integration with different retrievers 6. Vector store persistence across different backends
NO MOCKS - All components use real BaseRAGAgent with real retrievers.
ClassesΒΆ
Memory agent for conversation history using BaseRAGAgent. |
|
Memory agent for factual information using BaseRAGAgent. |
|
Importance levels for memories. |
|
Configuration for RAG-based memory agents. |
|
Types of memories that can be stored. |
|
Convert messages to documents for RAG storage. |
|
Memory agent for user preferences using SimpleRAGAgent for generation. |
|
Standalone memory item for RAG-based storage. |
|
Unified memory agent coordinating multiple specialized memory agents. |
FunctionsΒΆ
Factory function to create conversation memory agent. |
|
|
Factory function to create unified memory agent. |
|
Demo. |
Module ContentsΒΆ
- class agents.memory_v2.standalone_rag_memory.ConversationMemoryAgent(config, name='conversation_memory')ΒΆ
Memory agent for conversation history using BaseRAGAgent.
Initialize conversation memory agent.
- Parameters:
config (MemoryRAGConfig)
name (str)
- async add_conversation(messages)ΒΆ
Add conversation messages to memory.
- Parameters:
messages (list[langchain_core.messages.BaseMessage])
- Return type:
None
- async initialize()ΒΆ
Initialize the underlying RAG agent.
- Return type:
None
- class agents.memory_v2.standalone_rag_memory.FactualMemoryAgent(config, name='factual_memory')ΒΆ
Memory agent for factual information using BaseRAGAgent.
Initialize factual memory agent.
- Parameters:
config (MemoryRAGConfig)
name (str)
- async add_memories(memories)ΒΆ
Add multiple factual memories.
- Parameters:
memories (list[StandaloneMemoryItem])
- Return type:
None
- async add_memory(memory)ΒΆ
Add a factual memory.
- Parameters:
memory (StandaloneMemoryItem)
- Return type:
None
- async initialize()ΒΆ
Initialize the underlying RAG agent.
- Return type:
None
- class agents.memory_v2.standalone_rag_memory.ImportanceLevelΒΆ
-
Importance levels for memories.
Initialize self. See help(type(self)) for accurate signature.
- class agents.memory_v2.standalone_rag_memory.MemoryRAGConfig(/, **data)ΒΆ
Bases:
pydantic.BaseModel
Configuration for RAG-based memory agents.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- Parameters:
data (Any)
- model_configΒΆ
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class agents.memory_v2.standalone_rag_memory.MemoryTypeΒΆ
-
Types of memories that can be stored.
Initialize self. See help(type(self)) for accurate signature.
- class agents.memory_v2.standalone_rag_memory.MessageDocumentConverter(user_id=None, conversation_id=None)ΒΆ
Convert messages to documents for RAG storage.
Initialize converter.
- convert_message(message)ΒΆ
Convert single message to document.
- Parameters:
message (langchain_core.messages.BaseMessage)
- Return type:
langchain_core.documents.Document
- class agents.memory_v2.standalone_rag_memory.PreferencesMemoryAgent(config, name='preferences_memory')ΒΆ
Memory agent for user preferences using SimpleRAGAgent for generation.
Initialize preferences memory agent.
- Parameters:
config (MemoryRAGConfig)
name (str)
- async add_preference(preference)ΒΆ
Add a user preference.
- Parameters:
preference (StandaloneMemoryItem)
- Return type:
None
- async get_preferences_for(context)ΒΆ
Get relevant preferences and generate summary.
- async initialize()ΒΆ
Initialize the underlying RAG agent.
- Return type:
None
- class agents.memory_v2.standalone_rag_memory.StandaloneMemoryItem(/, **data)ΒΆ
Bases:
pydantic.BaseModel
Standalone memory item for RAG-based storage.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- Parameters:
data (Any)
- mark_accessed()ΒΆ
Mark memory as accessed.
- model_configΒΆ
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class agents.memory_v2.standalone_rag_memory.UnifiedMemoryRAGAgent(config, user_id=None)ΒΆ
Unified memory agent coordinating multiple specialized memory agents.
Initialize unified memory agent.
- Parameters:
config (MemoryRAGConfig)
user_id (str | None)
- classmethod as_tool(name=None, description=None, **config_kwargs)ΒΆ
Convert this agent to a tool for use in other agents.
- async initialize()ΒΆ
Initialize all memory agents.
- Return type:
None
- async process_conversation(messages)ΒΆ
Process conversation and extract memories.
- agents.memory_v2.standalone_rag_memory.create_conversation_memory_agent(vector_store_provider=VectorStoreProvider.FAISS, embedding_model='sentence-transformers/all-mpnet-base-v2', enable_time_weighting=True, name='conversation_memory')ΒΆ
Factory function to create conversation memory agent.
- Parameters:
- Return type:
- agents.memory_v2.standalone_rag_memory.create_unified_memory_agent(user_id=None, llm_config=None, vector_store_provider=VectorStoreProvider.FAISS, embedding_model='sentence-transformers/all-mpnet-base-v2')ΒΆ
Factory function to create unified memory agent.
- Parameters:
- Return type:
- async agents.memory_v2.standalone_rag_memory.demo()ΒΆ
Demo.