LangSmith 使用 PostgreSQL 数据库作为事务工作负载和操作数据(几乎除运行之外的所有内容)的主要数据存储。默认情况下,LangSmith 自托管将使用内部 PostgreSQL 数据库。但是,您可以配置 LangSmith 使用外部 PostgreSQL 数据库。通过配置外部 PostgreSQL 数据库,您可以更轻松地管理数据库的备份、扩展和其他操作任务。

要求

  • 您的 LangSmith 实例将具有网络访问权限的已配置 PostgreSQL 数据库。我们建议使用托管 PostgreSQL 服务,例如:
  • 注意:我们仅正式支持 PostgreSQL 版本 >= 14。
  • 具有 PostgreSQL 数据库管理员访问权限的用户。此用户将用于创建必要的表、索引和架构。
  • 此用户还需要具有在数据库中创建扩展的能力。我们使用/将尝试安装 btree_gin、btree_gist、pgcrypto、citext、ltree 和 pg_trgm 扩展。
  • 如果使用非 public 的架构,请确保没有启用扩展的任何其他架构,或者必须将其包含在搜索路径中。
  • pgbouncer 和其他连接池器的支持是基于社区的。社区成员报告说 pgbouncer 在 pool_mode = sessionignore_startup_parameters 的合适设置下工作(截至撰写时,需要忽略 search_pathlock_timeout)。需要注意避免污染连接池;建议具有一定的 PostgreSQL 专业知识。LangChain Inc 目前没有正式测试覆盖率或商业支持 pgbouncer 或 amazon rds proxy 或任何其他池器的路线图计划,但欢迎社区通过 GitHub 问题讨论和协作支持。
  • 默认情况下,我们建议至少具有 2 个 vCPU 和 8GB 内存的实例。但是,实际要求将取决于您的工作负载和用户数量。我们建议监控您的 PostgreSQL 实例并根据需要扩展。

Connection String

You will need to provide a connection string to your PostgreSQL database. This connection string should include the following information:
  • Host
  • Port
  • Database
  • Username
  • Password(Make sure to url encode this if there are any special characters)
  • URL params
This will take the form of:
username:password@host:port/database?<url_params>
An example connection string might look like:
myuser:mypassword@myhost:5432/mydatabase?sslmode=disable
Without url parameters, the connection string would look like:
myuser:mypassword@myhost:5432/mydatabase

Configuration

With your connection string in hand, you can configure your LangSmith instance to use an external PostgreSQL database. You can do this by modifying the values file for your LangSmith Helm Chart installation or the .env file for your Docker installation.
postgres:
  external:
    enabled: true
    connectionUrl: "Your connection url"
Once configured, you should be able to reinstall your LangSmith instance. If everything is configured correctly, your LangSmith instance should now be using your external PostgreSQL database.
Connect these docs programmatically to Claude, VSCode, and more via MCP for real-time answers.