@axiom-lattice/ pg- stores (英语)
PostgreSQL 为Axiom Lattice框架存储执行.
快速启动
import { configureStores } from "@axiom-lattice/core";
import { createPgStoreConfig } from "@axiom-lattice/pg-stores";
import { PostgresSaver } from "@langchain/langgraph-checkpoint-postgres";
// One connection string creates all PG stores
const stores = createPgStoreConfig(process.env.DATABASE_URL);
// Register all stores in one call
await configureStores({
...stores,
checkpoint: PostgresSaver.fromConnString(process.env.DATABASE_URL),
});
createPgStoreConfig
从单一连接字符串创建所有 PG 存储实例的工厂函数 。 返回一个可扩展到 configureStores()。 。 。 .
function createPgStoreConfig(connectionString: string): {
workspace: PostgreSQLWorkspaceStore;
project: PostgreSQLProjectStore;
eval: PostgreSQLEvalStore;
user: PostgreSQLUserStore;
tenant: PostgreSQLTenantStore;
userTenantLink: PostgreSQLUserTenantLinkStore;
channelBinding: ChannelBindingStore;
channelInstallation: PostgreSQLChannelInstallationStore;
thread: PostgreSQLThreadStore;
database: PostgreSQLDatabaseConfigStore;
metrics: PostgreSQLMetricsServerConfigStore;
mcp: PostgreSQLMcpServerConfigStore;
assistant: PostgreSQLAssistantStore;
workflowTracking: PostgreSQLWorkflowTrackingStore;
threadMessageQueue: ThreadMessageQueueStore;
schedule: PostgreSQLScheduleStorage;
}
存储于 autoMigrate: true: eval, 频道Binding, 频道安装, 工作流程跟踪, 线程MessageQuue.
其他人都会用 autoMigrate: false (手语: initialize() 通过 configureStores) (中文(简体) ).
个人存储使用
如果您只需要特定的商店, 请直接构建它们 :
import { configureStores } from "@axiom-lattice/core";
import { PostgreSQLThreadStore, PostgreSQLAssistantStore } from "@axiom-lattice/pg-stores";
await configureStores({
thread: new PostgreSQLThreadStore({ poolConfig: process.env.DATABASE_URL }),
assistant: new PostgreSQLAssistantStore({ poolConfig: process.env.DATABASE_URL }),
});
可用存储
| 存储 | 类 | 说明 |
|---|---|---|
| 线程 | PostgreSQLThreadStore | 线索 CRUD |
| 助理人员 | PostgreSQLAssistantStore | 助理CRUD |
| 技能 | PostgreSQLSkillStore | 技能存储 |
| 工作空间 | PostgreSQLWorkspaceStore | 工作空间管理 |
| 项目 | PostgreSQLProjectStore | 项目管理 |
| 数据库 | PostgreSQLDatabaseConfigStore | DB 连接配置 |
| 计量 | PostgreSQLMetricsServerConfigStore | 计量服务器配置 |
| 微调 | PostgreSQLMcpServerConfigStore | MCP 服务器配置 |
| 用户 | PostgreSQLUserStore | 用户存储 |
| 租户 | PostgreSQLTenantStore | 租户存储 |
| 用户 TenantLink | PostgreSQLUserTenantLinkStore | 用户租户链接 |
| 线程信息队列 | ThreadMessageQueueStore | 信件队列持续性 |
| 工作流程跟踪 | PostgreSQLWorkflowTrackingStore | 工作流程运行跟踪 |
| eval (中文) | PostgreSQLEvalStore | 评价存储 |
| 频道安装 | PostgreSQLChannelInstallationStore | 频道装置 |
| 频道编辑 | ChannelBindingStore | 发件人对代理绑定 |
| 时间表 | PostgreSQLScheduleStorage | 排定的任务持久性 |
构造选项
所有商店都接受相同的选项模式 :
interface StoreOptions {
poolConfig: string | PoolConfig; // Connection string or PoolConfig object
autoMigrate?: boolean; // Run migrations automatically (default: true)
}
移徙系统
每个商店管理自己的计划迁移 MigrationManager. 期间的移徙 initialize()。 。 。 .
// Manual control
const store = new PostgreSQLThreadStore({
poolConfig: process.env.DATABASE_URL,
autoMigrate: false,
});
await store.initialize(); // Migrations applied here