Postgres聊天消息历史记录 (Postgres Chat Message History)
本文档介绍如何使用Postgres存储聊天消息历史记录。(This notebook goes over how to use Postgres to store chat message history.)
from langchain.memory import PostgresChatMessageHistory
history = PostgresChatMessageHistory(
connection_string="postgresql://postgres:mypassword@localhost/chat_history",
session_id="foo",
)
history.add_user_message("hi!")
history.add_ai_message("whats up?")
history.messages