Skip to main content

Rockset

Rockset is a real-time analytics database service for serving low latency, high concurrency analytical queries at scale. It builds a Converged Index™ on structured and semi-structured data with an efficient store for vector embeddings. Its support for running SQL on schemaless data makes it a perfect choice for running vector search with metadata filters.

This notebook goes over how to use Rockset to store chat message history.

Setting up

!pip install rockset

To begin, with get your API key from the Rockset console. Find your API region for the Rockset API reference.

Example

from langchain_community.chat_message_histories import RocksetChatMessageHistory
from rockset import Regions, RocksetClient

history = RocksetChatMessageHistory(
session_id="MySession",
client=RocksetClient(
api_key="YOUR API KEY",
host=Regions.usw2a1, # us-west-2 Oregon
),
collection="langchain_demo",
sync=True,
)
history.add_user_message("hi!")
history.add_ai_message("whats up?")
print(history.messages)

The output should be something like:

[
HumanMessage(content='hi!', additional_kwargs={'id': '2e62f1c2-e9f7-465e-b551-49bae07fe9f0'}, example=False),
AIMessage(content='whats up?', additional_kwargs={'id': 'b9be8eda-4c18-4cf8-81c3-e91e876927d0'}, example=False)
]