跳到主要内容
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?")
history.messages

此页面是否对您有帮助?