Skip to main content
Version: 2.20-unstable

ChatMessage Store

Module haystack_experimental.chat_message_stores.in_memory

InMemoryChatMessageStore

Stores chat messages in-memory.

InMemoryChatMessageStore.__init__

python
def __init__()

Initializes the InMemoryChatMessageStore.

InMemoryChatMessageStore.to_dict

python
def to_dict() -> Dict[str, Any]

Serializes the component to a dictionary.

Returns:

Dictionary with serialized data.

InMemoryChatMessageStore.from_dict

python
@classmethod
def from_dict(cls, data: Dict[str, Any]) -> "InMemoryChatMessageStore"

Deserializes the component from a dictionary.

Arguments:

  • data: The dictionary to deserialize from.

Returns:

The deserialized component.

InMemoryChatMessageStore.count_messages

python
def count_messages() -> int

Returns the number of chat messages stored.

Returns:

The number of messages.

InMemoryChatMessageStore.write_messages

python
def write_messages(messages: List[ChatMessage]) -> int

Writes chat messages to the ChatMessageStore.

Arguments:

  • messages: A list of ChatMessages to write.

Raises:

  • ValueError: If messages is not a list of ChatMessages.

Returns:

The number of messages written.

InMemoryChatMessageStore.delete_messages

python
def delete_messages() -> None

Deletes all stored chat messages.

InMemoryChatMessageStore.retrieve

python
def retrieve() -> List[ChatMessage]

Retrieves all stored chat messages.

Returns:

A list of chat messages.