跳到主要內容
Open In ColabOpen on GitHub

Postgres

PostgreSQL 也稱為 Postgres,是一個免費且開源的關聯式資料庫管理系統 (RDBMS),強調可擴展性和 SQL 相容性。

本筆記本說明如何使用 Postgres 儲存聊天訊息歷史記錄。

from langchain_community.chat_message_histories 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?")
API 參考文件:PostgresChatMessageHistory
history.messages

此頁面是否對您有幫助?