agents.memory_v2.conversation_memory_agent¶
Conversation Memory Agent using BaseRAGAgent.
This module provides conversation memory storage and retrieval using BaseRAGAgent with semantic search over conversation history and optional time-weighting.
Classes¶
Memory agent for conversation history using BaseRAGAgent. |
|
Configuration for ConversationMemoryAgent. |
|
Convert messages to documents for RAG storage. |
Functions¶
Demo conversation memory agent functionality. |
Module Contents¶
- class agents.memory_v2.conversation_memory_agent.ConversationMemoryAgent(config=None, name='conversation_memory', user_id=None)¶
Memory agent for conversation history using BaseRAGAgent.
This agent provides: - Semantic search over conversation history - Automatic message-to-document conversion - Real BaseRAGAgent integration with vector stores - Incremental conversation updates - Time-weighted retrieval (optional)
Examples
Basic usage:
agent = ConversationMemoryAgent("user_123") await agent.initialize() # Add conversation messages = [HumanMessage("I work at Google")] await agent.add_conversation(messages) # Retrieve context docs = await agent.retrieve_context("Where do I work?")
Initialize conversation memory agent.
- Parameters:
config (ConversationMemoryConfig)
name (str)
user_id (str | None)
- async add_conversation(messages)¶
Add conversation messages to memory.
- Parameters:
messages (list[langchain_core.messages.BaseMessage])
- Return type:
None
- classmethod create(user_id=None, vector_store_provider=VectorStoreProvider.FAISS, embedding_model='sentence-transformers/all-mpnet-base-v2', name='conversation_memory')¶
Factory method to create ConversationMemoryAgent.
- Parameters:
- Return type:
- async initialize()¶
Initialize the underlying RAG agent.
- Return type:
None
- class agents.memory_v2.conversation_memory_agent.ConversationMemoryConfig(/, **data)¶
Bases:
pydantic.BaseModel
Configuration for ConversationMemoryAgent.
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.conversation_memory_agent.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
- async agents.memory_v2.conversation_memory_agent.demo_conversation_memory()¶
Demo conversation memory agent functionality.