@axiom-lattice/pg-stores 4.0.0 → 4.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +8 -8
- package/CHANGELOG.md +7 -0
- package/dist/index.js +59 -23
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +46 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/PGVectorStoreProvider.ts +16 -5
- package/src/__tests__/AgentRunRetention.migrations.test.ts +3 -1
- package/src/createPgStoreConfig.ts +2 -0
- package/src/migrations/model_provider_migrations.ts +38 -0
- package/src/stores/PostgreSQLModelProviderStore.ts +28 -14
package/dist/index.mjs
CHANGED
|
@@ -9559,6 +9559,9 @@ import { Pool as Pool25 } from "pg";
|
|
|
9559
9559
|
import { PGVectorStore } from "@langchain/community/vectorstores/pgvector";
|
|
9560
9560
|
import { Document } from "@langchain/core/documents";
|
|
9561
9561
|
import { embeddingsLatticeManager } from "@axiom-lattice/core";
|
|
9562
|
+
import {
|
|
9563
|
+
EMBEDDING_DEFAULT_KEY
|
|
9564
|
+
} from "@axiom-lattice/protocols";
|
|
9562
9565
|
function safeTableName(name) {
|
|
9563
9566
|
if (!/^[a-z][a-z0-9_-]*$/.test(name)) {
|
|
9564
9567
|
throw new Error(`Invalid table name: ${name}`);
|
|
@@ -9573,16 +9576,20 @@ var PGVectorStoreProvider = class {
|
|
|
9573
9576
|
async create(params) {
|
|
9574
9577
|
const { tableName, embeddingKey } = params;
|
|
9575
9578
|
const tenantId = params.tenantId ?? "default";
|
|
9579
|
+
const requestedKey = embeddingKey || EMBEDDING_DEFAULT_KEY;
|
|
9576
9580
|
const embeddings = await embeddingsLatticeManager.getEmbeddingsClientWithTenant(
|
|
9577
9581
|
tenantId,
|
|
9578
|
-
|
|
9579
|
-
) ?? await embeddingsLatticeManager.getEmbeddingsClientWithTenant(
|
|
9582
|
+
requestedKey
|
|
9583
|
+
) ?? (requestedKey === EMBEDDING_DEFAULT_KEY ? void 0 : await embeddingsLatticeManager.getEmbeddingsClientWithTenant(
|
|
9584
|
+
tenantId,
|
|
9585
|
+
EMBEDDING_DEFAULT_KEY
|
|
9586
|
+
)) ?? await embeddingsLatticeManager.getEmbeddingsClientWithTenant(
|
|
9580
9587
|
tenantId,
|
|
9581
9588
|
"default"
|
|
9582
9589
|
);
|
|
9583
9590
|
if (!embeddings) {
|
|
9584
9591
|
throw new Error(
|
|
9585
|
-
`No embedding model "${embeddingKey}" registered for tenant "${tenantId}", and no deployment default. Configure one in the model
|
|
9592
|
+
`No embedding model "${embeddingKey}" registered for tenant "${tenantId}", and no tenant or deployment default. Configure one in the model service panel.`
|
|
9586
9593
|
);
|
|
9587
9594
|
}
|
|
9588
9595
|
return PGVectorStore.initialize(embeddings, {
|
|
@@ -10751,6 +10758,28 @@ var addModelProviderModelKind = {
|
|
|
10751
10758
|
`);
|
|
10752
10759
|
}
|
|
10753
10760
|
};
|
|
10761
|
+
var addModelProviderKindDefault = {
|
|
10762
|
+
version: 207,
|
|
10763
|
+
name: "add_model_provider_kind_default",
|
|
10764
|
+
up: async (client) => {
|
|
10765
|
+
await client.query(`
|
|
10766
|
+
DROP INDEX IF EXISTS uk_lattice_model_provider_models_tenant_default
|
|
10767
|
+
`);
|
|
10768
|
+
await client.query(`
|
|
10769
|
+
CREATE UNIQUE INDEX IF NOT EXISTS uk_lattice_model_provider_models_tenant_kind_default
|
|
10770
|
+
ON lattice_model_provider_models (tenant_id, kind) WHERE is_default
|
|
10771
|
+
`);
|
|
10772
|
+
},
|
|
10773
|
+
down: async (client) => {
|
|
10774
|
+
await client.query(`
|
|
10775
|
+
DROP INDEX IF EXISTS uk_lattice_model_provider_models_tenant_kind_default
|
|
10776
|
+
`);
|
|
10777
|
+
await client.query(`
|
|
10778
|
+
CREATE UNIQUE INDEX IF NOT EXISTS uk_lattice_model_provider_models_tenant_default
|
|
10779
|
+
ON lattice_model_provider_models (tenant_id) WHERE is_default
|
|
10780
|
+
`);
|
|
10781
|
+
}
|
|
10782
|
+
};
|
|
10754
10783
|
|
|
10755
10784
|
// src/stores/PostgreSQLCapabilityBundleStore.ts
|
|
10756
10785
|
import { randomUUID as randomUUID3 } from "crypto";
|
|
@@ -11745,6 +11774,7 @@ var PostgreSQLModelProviderStore = class {
|
|
|
11745
11774
|
this.migrationManager.register(addModelProviderModelExtra);
|
|
11746
11775
|
this.migrationManager.register(addModelProviderModelDefault);
|
|
11747
11776
|
this.migrationManager.register(addModelProviderModelKind);
|
|
11777
|
+
this.migrationManager.register(addModelProviderKindDefault);
|
|
11748
11778
|
if (options.autoMigrate !== false) {
|
|
11749
11779
|
this.initialize().catch((error) => {
|
|
11750
11780
|
console.error("Failed to initialize PostgreSQLModelProviderStore:", error);
|
|
@@ -12083,15 +12113,22 @@ var PostgreSQLModelProviderStore = class {
|
|
|
12083
12113
|
const effectiveKind = rows.map(
|
|
12084
12114
|
(model) => model.kind ?? currentKind.get(model.id) ?? "chat"
|
|
12085
12115
|
);
|
|
12086
|
-
const
|
|
12087
|
-
|
|
12116
|
+
const namedDefaultKinds = /* @__PURE__ */ new Set();
|
|
12117
|
+
rows.forEach((model, index) => {
|
|
12118
|
+
if (model.isDefault === true) {
|
|
12119
|
+
namedDefaultKinds.add(effectiveKind[index]);
|
|
12120
|
+
}
|
|
12121
|
+
});
|
|
12122
|
+
for (const kind of namedDefaultKinds) {
|
|
12088
12123
|
await client.query(
|
|
12089
|
-
`UPDATE lattice_model_provider_models
|
|
12090
|
-
|
|
12124
|
+
`UPDATE lattice_model_provider_models
|
|
12125
|
+
SET is_default = FALSE
|
|
12126
|
+
WHERE tenant_id = $1 AND kind = $2 AND is_default`,
|
|
12127
|
+
[tenantId, kind]
|
|
12091
12128
|
);
|
|
12092
12129
|
}
|
|
12093
12130
|
const effectiveIsDefault = rows.map(
|
|
12094
|
-
(model) => model.isDefault ?? (
|
|
12131
|
+
(model, index) => model.isDefault ?? (namedDefaultKinds.has(effectiveKind[index]) ? false : currentIsDefault.get(model.id)) ?? false
|
|
12095
12132
|
);
|
|
12096
12133
|
await client.query(
|
|
12097
12134
|
`
|
|
@@ -14560,6 +14597,7 @@ async function createPgStoreConfig(connectionString) {
|
|
|
14560
14597
|
mm.register(createAgentRunRetentionMigration);
|
|
14561
14598
|
mm.register(createAgentRunProjectTaskMigration);
|
|
14562
14599
|
mm.register(agentRunProjectTaskRunningIndexMigration);
|
|
14600
|
+
mm.register(addModelProviderKindDefault);
|
|
14563
14601
|
await mm.migrate();
|
|
14564
14602
|
const checkpoint = PostgresSaver.fromConnString(connectionString);
|
|
14565
14603
|
checkpoint.setup().catch((err) => {
|