Rockset
Rockset 是一种实时分析数据库服务,适用于在大规模环境中以低延迟、高并发性处理分析查询。它在结构化和半结构化数据上构建了 Converged Index™,并具有高效的向量嵌入存储。其支持在无模式数据上运行 SQL 使得它成为运行带有元数据过滤器的向量搜索的理想选择。
该笔记本介绍了如何使用Rockset来存储聊天消息历史。
设置
%pip install --upgrade --quiet rockset langchain-community
首先,请从Rockset 控制台获取您的 API 密钥。在 Rockset API 参考文档中查找您的 API 区域。
示例
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)
API 参考:Rockset聊天消息历史
输出应该类似于:
[
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)
]