# RocksetChatMessageHistory

> **Class** in `langchain_community`

📖 [View in docs](https://reference.langchain.com/python/langchain-community/chat_message_histories/rocksetdb/RocksetChatMessageHistory)

Uses Rockset to store chat messages.

To use, ensure that the `rockset` python package installed.

## Signature

```python
RocksetChatMessageHistory(
    self,
    session_id: str,
    client: Any,
    collection: str,
    workspace: str = 'commons',
    messages_key: str = 'messages',
    sync: bool = False,
    message_uuid_method: Callable[[], Union[str, int]] = lambda: str(uuid4()),
)
```

## Description

**Example:**

.. code-block:: python

from langchain_community.chat_message_histories import (
    RocksetChatMessageHistory
)
from rockset import RocksetClient

history = RocksetChatMessageHistory(
    session_id="MySession",
    client=RocksetClient(),
    collection="langchain_demo",
    sync=True
)

history.add_user_message("hi!")
history.add_ai_message("whats up?")

print(history.messages)  # noqa: T201

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `- session_id` | `unknown` | Yes | The ID of the chat session |
| `- client` | `unknown` | Yes | The RocksetClient object to use to query |
| `- collection` | `unknown` | Yes | The name of the collection to use to store chat           messages. If a collection with the given name           does not exist in the workspace, it is created. |
| `- workspace` | `unknown` | Yes | The workspace containing `collection`. Defaults          to `"commons"` |
| `- messages_key` | `unknown` | Yes | The DB column containing message history.             Defaults to `"messages"` |
| `- sync` | `unknown` | Yes | Whether to wait for messages to be added. Defaults     to `False`. NOTE: setting this to `True` will slow     down performance. |
| `- message_uuid_method` | `unknown` | Yes | The method that generates message IDs.     If set, all messages will have an `id` field within the     `additional_kwargs` property. If this param is not set     and `sync` is `False`, message IDs will not be created.     If this param is not set and `sync` is `True`, the     `uuid.uuid4` method will be used to create message IDs. |

## Extends

- `BaseChatMessageHistory`

## Constructors

```python
__init__(
    self,
    session_id: str,
    client: Any,
    collection: str,
    workspace: str = 'commons',
    messages_key: str = 'messages',
    sync: bool = False,
    message_uuid_method: Callable[[], Union[str, int]] = lambda: str(uuid4()),
) -> None
```

| Name | Type |
|------|------|
| `session_id` | `str` |
| `client` | `Any` |
| `collection` | `str` |
| `workspace` | `str` |
| `messages_key` | `str` |
| `sync` | `bool` |
| `message_uuid_method` | `Callable[[], Union[str, int]]` |


## Properties

- `SLEEP_INTERVAL_MS`
- `ADD_TIMEOUT_MS`
- `CREATE_TIMEOUT_MS`
- `session_id`
- `client`
- `collection`
- `workspace`
- `location`
- `rockset`
- `messages_key`
- `message_uuid_method`
- `sync`
- `messages`

## Methods

- [`add_message()`](https://reference.langchain.com/python/langchain-community/chat_message_histories/rocksetdb/RocksetChatMessageHistory/add_message)
- [`clear()`](https://reference.langchain.com/python/langchain-community/chat_message_histories/rocksetdb/RocksetChatMessageHistory/clear)

---

[View source on GitHub](https://github.com/langchain-ai/langchain-community/blob/a6a6079511ac8a5c1293337f88096b8641562e77/libs/community/langchain_community/chat_message_histories/rocksetdb.py#L14)