memory#

Memory component for user-assistant conversations.

Memory can include data modeling, in-memory data storage, local file data storage, cloud data persistence, data pipeline, data retriever. It is itself an LLM application and different use cases can do it differently.

This component handles the storage and retrieval of conversation history between users and assistants. It provides local memory experience with the ability to format and return conversation history.

current_conversation#

Stores the current active conversation.

Type:

Conversation

turn_db#

Database for storing all conversation turns.

Type:

LocalDB

conver_db#

Database for storing complete conversations.

Type:

LocalDB

Classes

Memory([turn_db])

class Memory(turn_db: LocalDB = None)[source]#

Bases: Component

call() str[source]#

Returns the current conversation history as a formatted string.

Returns:

Formatted conversation history with alternating user and assistant messages.

Returns empty string if no conversation history exists.

Return type:

str

add_dialog_turn(user_query: str, assistant_response: str)[source]#

Add a new dialog turn to the current conversation.

Parameters:
  • user_query (str) – The user’s input message.

  • assistant_response (str) – The assistant’s response message.