@convex-dev/rag 0.1.7
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/LICENSE +201 -0
- package/README.md +371 -0
- package/dist/client/_generated/_ignore.d.ts +1 -0
- package/dist/client/_generated/_ignore.d.ts.map +1 -0
- package/dist/client/_generated/_ignore.js +3 -0
- package/dist/client/_generated/_ignore.js.map +1 -0
- package/dist/client/defaultChunker.d.ts +15 -0
- package/dist/client/defaultChunker.d.ts.map +1 -0
- package/dist/client/defaultChunker.js +148 -0
- package/dist/client/defaultChunker.js.map +1 -0
- package/dist/client/fileUtils.d.ts +24 -0
- package/dist/client/fileUtils.d.ts.map +1 -0
- package/dist/client/fileUtils.js +179 -0
- package/dist/client/fileUtils.js.map +1 -0
- package/dist/client/index.d.ts +442 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +597 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/types.d.ts +29 -0
- package/dist/client/types.d.ts.map +1 -0
- package/dist/client/types.js +2 -0
- package/dist/client/types.js.map +1 -0
- package/dist/component/_generated/api.d.ts +439 -0
- package/dist/component/_generated/api.d.ts.map +1 -0
- package/dist/component/_generated/api.js +22 -0
- package/dist/component/_generated/api.js.map +1 -0
- package/dist/component/_generated/dataModel.d.ts +60 -0
- package/dist/component/_generated/server.d.ts +149 -0
- package/dist/component/_generated/server.d.ts.map +1 -0
- package/dist/component/_generated/server.js +74 -0
- package/dist/component/_generated/server.js.map +1 -0
- package/dist/component/chunks.d.ts +139 -0
- package/dist/component/chunks.d.ts.map +1 -0
- package/dist/component/chunks.js +413 -0
- package/dist/component/chunks.js.map +1 -0
- package/dist/component/convex.config.d.ts +3 -0
- package/dist/component/convex.config.d.ts.map +1 -0
- package/dist/component/convex.config.js +6 -0
- package/dist/component/convex.config.js.map +1 -0
- package/dist/component/embeddings/importance.d.ts +21 -0
- package/dist/component/embeddings/importance.d.ts.map +1 -0
- package/dist/component/embeddings/importance.js +67 -0
- package/dist/component/embeddings/importance.js.map +1 -0
- package/dist/component/embeddings/index.d.ts +23 -0
- package/dist/component/embeddings/index.d.ts.map +1 -0
- package/dist/component/embeddings/index.js +54 -0
- package/dist/component/embeddings/index.js.map +1 -0
- package/dist/component/embeddings/tables.d.ts +39 -0
- package/dist/component/embeddings/tables.d.ts.map +1 -0
- package/dist/component/embeddings/tables.js +53 -0
- package/dist/component/embeddings/tables.js.map +1 -0
- package/dist/component/entries.d.ts +167 -0
- package/dist/component/entries.d.ts.map +1 -0
- package/dist/component/entries.js +409 -0
- package/dist/component/entries.js.map +1 -0
- package/dist/component/filters.d.ts +46 -0
- package/dist/component/filters.d.ts.map +1 -0
- package/dist/component/filters.js +72 -0
- package/dist/component/filters.js.map +1 -0
- package/dist/component/namespaces.d.ts +131 -0
- package/dist/component/namespaces.d.ts.map +1 -0
- package/dist/component/namespaces.js +222 -0
- package/dist/component/namespaces.js.map +1 -0
- package/dist/component/schema.d.ts +1697 -0
- package/dist/component/schema.d.ts.map +1 -0
- package/dist/component/schema.js +88 -0
- package/dist/component/schema.js.map +1 -0
- package/dist/component/search.d.ts +20 -0
- package/dist/component/search.d.ts.map +1 -0
- package/dist/component/search.js +69 -0
- package/dist/component/search.js.map +1 -0
- package/dist/package.json +3 -0
- package/dist/react/index.d.ts +2 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.js +6 -0
- package/dist/react/index.js.map +1 -0
- package/dist/shared.d.ts +479 -0
- package/dist/shared.d.ts.map +1 -0
- package/dist/shared.js +98 -0
- package/dist/shared.js.map +1 -0
- package/package.json +97 -0
- package/src/client/_generated/_ignore.ts +1 -0
- package/src/client/defaultChunker.test.ts +243 -0
- package/src/client/defaultChunker.ts +183 -0
- package/src/client/fileUtils.ts +179 -0
- package/src/client/index.test.ts +475 -0
- package/src/client/index.ts +1125 -0
- package/src/client/setup.test.ts +28 -0
- package/src/client/types.ts +69 -0
- package/src/component/_generated/api.d.ts +439 -0
- package/src/component/_generated/api.js +23 -0
- package/src/component/_generated/dataModel.d.ts +60 -0
- package/src/component/_generated/server.d.ts +149 -0
- package/src/component/_generated/server.js +90 -0
- package/src/component/chunks.test.ts +915 -0
- package/src/component/chunks.ts +555 -0
- package/src/component/convex.config.ts +7 -0
- package/src/component/embeddings/importance.test.ts +249 -0
- package/src/component/embeddings/importance.ts +75 -0
- package/src/component/embeddings/index.test.ts +482 -0
- package/src/component/embeddings/index.ts +99 -0
- package/src/component/embeddings/tables.ts +114 -0
- package/src/component/entries.test.ts +341 -0
- package/src/component/entries.ts +546 -0
- package/src/component/filters.ts +119 -0
- package/src/component/namespaces.ts +299 -0
- package/src/component/schema.ts +106 -0
- package/src/component/search.test.ts +445 -0
- package/src/component/search.ts +97 -0
- package/src/component/setup.test.ts +5 -0
- package/src/react/index.ts +7 -0
- package/src/shared.ts +247 -0
- package/src/vitest.config.ts +7 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convex.config.d.ts","sourceRoot":"","sources":["../../src/component/convex.config.ts"],"names":[],"mappings":"AAGA,QAAA,MAAM,SAAS,kDAAyB,CAAC;AAGzC,eAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convex.config.js","sourceRoot":"","sources":["../../src/component/convex.config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,QAAQ,MAAM,oCAAoC,CAAC;AAE1D,MAAM,SAAS,GAAG,eAAe,CAAC,KAAK,CAAC,CAAC;AACzC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AAExB,eAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file contains functions for modifying embeddings to include importance.
|
|
3
|
+
* Terminology is roughly: a "vector" is an "embedding" + importance.
|
|
4
|
+
* Users pass in embeddings, the tables and vector search deal with vectors.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* For a search, we need to add a 0 to the end of the embedding so we ignore
|
|
8
|
+
* the weight value.
|
|
9
|
+
*/
|
|
10
|
+
export declare function searchVector(embedding: number[]): number[];
|
|
11
|
+
/**
|
|
12
|
+
* For an importance of x (0 to 1):
|
|
13
|
+
* @param embedding - The vector to modify with an importance weight.
|
|
14
|
+
* @param importance - 0 - 1, where 0 is no importance and 1 is full importance.
|
|
15
|
+
* @returns The vector with the importance added.
|
|
16
|
+
*/
|
|
17
|
+
export declare function vectorWithImportance(embedding: number[], importance: number): number[];
|
|
18
|
+
export declare function modifyImportance(vector: number[], importance: number): number[];
|
|
19
|
+
export declare function getImportance(vector: number[]): number;
|
|
20
|
+
export declare function vectorWithImportanceDimension(dimensions: number): number;
|
|
21
|
+
//# sourceMappingURL=importance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"importance.d.ts","sourceRoot":"","sources":["../../../src/component/embeddings/importance.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;GAGG;AACH,wBAAgB,YAAY,CAAC,SAAS,EAAE,MAAM,EAAE,YAK/C;AACD;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,UAAU,EAAE,MAAM,YAwB3E;AAcD,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,UAAU,EAAE,MAAM,YAKpE;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,UAE7C;AAED,wBAAgB,6BAA6B,CAAC,UAAU,EAAE,MAAM,UAG/D"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file contains functions for modifying embeddings to include importance.
|
|
3
|
+
* Terminology is roughly: a "vector" is an "embedding" + importance.
|
|
4
|
+
* Users pass in embeddings, the tables and vector search deal with vectors.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* For a search, we need to add a 0 to the end of the embedding so we ignore
|
|
8
|
+
* the weight value.
|
|
9
|
+
*/
|
|
10
|
+
export function searchVector(embedding) {
|
|
11
|
+
if (embedding.length === 4096) {
|
|
12
|
+
return [...embedding.slice(0, 4095), 0];
|
|
13
|
+
}
|
|
14
|
+
return [...embedding, 0];
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* For an importance of x (0 to 1):
|
|
18
|
+
* @param embedding - The vector to modify with an importance weight.
|
|
19
|
+
* @param importance - 0 - 1, where 0 is no importance and 1 is full importance.
|
|
20
|
+
* @returns The vector with the importance added.
|
|
21
|
+
*/
|
|
22
|
+
export function vectorWithImportance(embedding, importance) {
|
|
23
|
+
/*
|
|
24
|
+
* Goal: add a weighting that reduces the magnitude of the target vector after
|
|
25
|
+
* normalization.
|
|
26
|
+
* 1. Scale the existing vector by importance and add a weight so |v| = 1.
|
|
27
|
+
* 2. Search with [...embedding, 0].
|
|
28
|
+
* e.g.:
|
|
29
|
+
* Say we have an embedding of 2 numbers [.6, .8]
|
|
30
|
+
* For 50% importance: [.6 * i, .8 * i, sqrt(1 - i^2)] -> [.3, .4, .866]
|
|
31
|
+
* For [.6, .8] we used to get 1.0.
|
|
32
|
+
* Now we get .6*.3 + .8*.4 + 0*.866 = 0.5
|
|
33
|
+
*/
|
|
34
|
+
// We drop the final dimension if it'd make it larger than 4096.
|
|
35
|
+
// Unfortunate current limitation of Convex vector search.
|
|
36
|
+
const vectorToModify = normalizeVector(embedding.length === 4096 ? embedding.slice(0, 4095) : embedding);
|
|
37
|
+
const scaled = scaleVector(vectorToModify, importance);
|
|
38
|
+
// |embedding| == 1
|
|
39
|
+
// weight^2 + importance^2(|embedding|^2) == 1
|
|
40
|
+
// weight = sqrt(1 - importance^2)
|
|
41
|
+
const weight = Math.sqrt(1 - importance ** 2);
|
|
42
|
+
return [...scaled, weight];
|
|
43
|
+
}
|
|
44
|
+
function normalizeVector(vector) {
|
|
45
|
+
const sumOfSquares = vector.reduce((acc, v) => acc + v * v, 0);
|
|
46
|
+
const magnitude = Math.sqrt(sumOfSquares);
|
|
47
|
+
return magnitude === 0
|
|
48
|
+
? vector.map(() => 0)
|
|
49
|
+
: vector.map((v) => v / magnitude);
|
|
50
|
+
}
|
|
51
|
+
function scaleVector(vector, scale) {
|
|
52
|
+
return vector.map((v) => v * scale);
|
|
53
|
+
}
|
|
54
|
+
export function modifyImportance(vector, importance) {
|
|
55
|
+
// Note: we don't need to handle 4096 explicitly here
|
|
56
|
+
// vectorWithImportance will turn it from 4095 to 4096.
|
|
57
|
+
const vectorToModify = vector.slice(0, vector.length - 1);
|
|
58
|
+
return vectorWithImportance(vectorToModify, importance);
|
|
59
|
+
}
|
|
60
|
+
export function getImportance(vector) {
|
|
61
|
+
return Math.sqrt(1 - vector[vector.length - 1] ** 2);
|
|
62
|
+
}
|
|
63
|
+
export function vectorWithImportanceDimension(dimensions) {
|
|
64
|
+
// +1 for the importance weighting, but respect global limit
|
|
65
|
+
return dimensions === 4096 ? 4096 : dimensions + 1;
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=importance.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"importance.js","sourceRoot":"","sources":["../../../src/component/embeddings/importance.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,SAAmB;IAC9C,IAAI,SAAS,CAAC,MAAM,KAAK,IAAI,EAAE,CAAC;QAC9B,OAAO,CAAC,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;IAC1C,CAAC;IACD,OAAO,CAAC,GAAG,SAAS,EAAE,CAAC,CAAC,CAAC;AAC3B,CAAC;AACD;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAAC,SAAmB,EAAE,UAAkB;IAC1E;;;;;;;;;;OAUG;IACH,gEAAgE;IAChE,0DAA0D;IAC1D,MAAM,cAAc,GAAG,eAAe,C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,EAAE,UAAU,CAAC,CAAC;AAC1D,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,MAAgB;IAC5C,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;AACvD,CAAC;AAED,MAAM,UAAU,6BAA6B,CAAC,UAAkB;IAC9D,4DAA4D;IAC5D,OAAO,UAAU,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,UAAU,GAAG,CAAC,CAAC;AACrD,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is the interface for interacting with vectors.
|
|
3
|
+
* It translates from embeddings to the underlying vector storage and search.
|
|
4
|
+
* It modifies embeddings to include importance.
|
|
5
|
+
* The outer world deals with filters with user names.
|
|
6
|
+
* The underlying vector storage has its own names.
|
|
7
|
+
* This file takes in numbered filters (0-3) to translate without knowing about
|
|
8
|
+
* user names.
|
|
9
|
+
*/
|
|
10
|
+
import type { Id } from "../_generated/dataModel.js";
|
|
11
|
+
import { type ActionCtx, type MutationCtx } from "../_generated/server.js";
|
|
12
|
+
import { type NumberedFilter } from "../filters.js";
|
|
13
|
+
export declare function insertEmbedding(ctx: MutationCtx, embedding: number[], namespaceId: Id<"namespaces">, importance: number | undefined, filters: NumberedFilter | undefined): Promise<import("convex/values").GenericId<"vectors_4096" | "vectors_128" | "vectors_256" | "vectors_512" | "vectors_768" | "vectors_1024" | "vectors_1408" | "vectors_1536" | "vectors_2048" | "vectors_3072">>;
|
|
14
|
+
export declare function searchEmbeddings(ctx: ActionCtx, { embedding, namespaceId, filters, limit, }: {
|
|
15
|
+
embedding: number[];
|
|
16
|
+
namespaceId: Id<"namespaces">;
|
|
17
|
+
filters: Array<NumberedFilter>;
|
|
18
|
+
limit: number;
|
|
19
|
+
}): Promise<{
|
|
20
|
+
_id: import("convex/values").GenericId<"vectors_4096" | "vectors_128" | "vectors_256" | "vectors_512" | "vectors_768" | "vectors_1024" | "vectors_1408" | "vectors_1536" | "vectors_2048" | "vectors_3072">;
|
|
21
|
+
_score: number;
|
|
22
|
+
}[]>;
|
|
23
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/component/embeddings/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,4BAA4B,CAAC;AACrD,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE3E,OAAO,EAA2B,KAAK,cAAc,EAAE,MAAM,eAAe,CAAC;AAiC7E,wBAAsB,eAAe,CACnC,GAAG,EAAE,WAAW,EAChB,SAAS,EAAE,MAAM,EAAE,EACnB,WAAW,EAAE,EAAE,CAAC,YAAY,CAAC,EAC7B,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,OAAO,EAAE,cAAc,GAAG,SAAS,mNASpC;AAED,wBAAsB,gBAAgB,CACpC,GAAG,EAAE,SAAS,EACd,EACE,SAAS,EACT,WAAW,EACX,OAAO,EACP,KAAK,GACN,EAAE;IACD,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,WAAW,EAAE,EAAE,CAAC,YAAY,CAAC,CAAC;IAK9B,OAAO,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC;IAC/B,KAAK,EAAE,MAAM,CAAC;CACf;;;KAqBF"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import {} from "../_generated/server.js";
|
|
2
|
+
import { getVectorTableName, validateVectorDimension } from "./tables.js";
|
|
3
|
+
import { filterFieldsFromNumbers } from "../filters.js";
|
|
4
|
+
import { searchVector, vectorWithImportance } from "./importance.js";
|
|
5
|
+
// TODO: wait to see if this is needed.
|
|
6
|
+
// export const insertBatch = mutation({
|
|
7
|
+
// args: {
|
|
8
|
+
// vectorDimension: vVectorDimension,
|
|
9
|
+
// vectors: v.array(
|
|
10
|
+
// v.object({
|
|
11
|
+
// vector: v.array(v.number()),
|
|
12
|
+
// namespace: v.id("namespaces"),
|
|
13
|
+
// importance: v.optional(v.number()),
|
|
14
|
+
// filters: v.optional(v.any()),
|
|
15
|
+
// })
|
|
16
|
+
// ),
|
|
17
|
+
// },
|
|
18
|
+
// returns: v.array(vVectorId),
|
|
19
|
+
// handler: async (ctx, args) => {
|
|
20
|
+
// return Promise.all(
|
|
21
|
+
// args.vectors.map(async (vector) =>
|
|
22
|
+
// insertEmbedding(
|
|
23
|
+
// ctx,
|
|
24
|
+
// vector.vector,
|
|
25
|
+
// vector.namespace,
|
|
26
|
+
// vector.importance,
|
|
27
|
+
// vector.filters
|
|
28
|
+
// )
|
|
29
|
+
// )
|
|
30
|
+
// );
|
|
31
|
+
// },
|
|
32
|
+
// });
|
|
33
|
+
export async function insertEmbedding(ctx, embedding, namespaceId, importance, filters) {
|
|
34
|
+
const filterFields = filterFieldsFromNumbers(namespaceId, filters);
|
|
35
|
+
const dimension = validateVectorDimension(embedding.length);
|
|
36
|
+
return ctx.db.insert(getVectorTableName(dimension), {
|
|
37
|
+
namespaceId,
|
|
38
|
+
vector: vectorWithImportance(embedding, importance ?? 1),
|
|
39
|
+
...filterFields,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
export async function searchEmbeddings(ctx, { embedding, namespaceId, filters, limit, }) {
|
|
43
|
+
const dimension = validateVectorDimension(embedding.length);
|
|
44
|
+
const tableName = getVectorTableName(dimension);
|
|
45
|
+
const orFilters = filters.flatMap((filter) => filterFieldsFromNumbers(namespaceId, filter));
|
|
46
|
+
return ctx.vectorSearch(tableName, "vector", {
|
|
47
|
+
vector: searchVector(embedding),
|
|
48
|
+
filter: (q) => orFilters.length === 0
|
|
49
|
+
? q.eq("namespaceId", namespaceId)
|
|
50
|
+
: q.or(...orFilters.flatMap((namedFilter) => Object.entries(namedFilter).map(([filterField, filter]) => q.eq(filterField, filter)))),
|
|
51
|
+
limit,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/component/embeddings/index.ts"],"names":[],"mappings":"AAUA,OAAO,EAAoC,MAAM,yBAAyB,CAAC;AAC3E,OAAO,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAC1E,OAAO,EAAE,uBAAuB,EAAuB,MAAM,eAAe,CAAC;AAC7E,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAErE,uCAAuC;AACvC,wCAAwC;AACxC,YAAY;AACZ,yCAAyC;AACzC,wBAAwB;AACxB,mBAAmB;AACnB,uCAAuC;AACvC,yCAAyC;AACzC,8CAA8C;AAC9C,wCAAwC;AACxC,WAAW;AACX,SAAS;AACT,OAAO;AACP,iCAAiC;AACjC,oCAAoC;AACpC,0BAA0B;AAC1B,2CAA2C;AAC3C,2BAA2B;AAC3B,iBAAiB;AACjB,2BAA2B;AAC3B,8BAA8B;AAC9B,+BAA+B;AAC/B,2BAA2B;AAC3B,YAAY;AACZ,UAAU;AACV,SAAS;AACT,OAAO;AACP,MAAM;AAGN,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,GAAgB,EAChB,SAAmB,EACnB,WAA6B,EAC7B,UAA8B,EAC9B,OAAmC;IAEnC,MAAM,YAAY,GAAG,uBAAuB,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IACnE,MAAM,SAAS,GAAG,uBAAuB,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAC5D,OAAO,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,kBAAkB,CAAC,SAAS,CAAC,EAAE;QAClD,WAAW;QACX,MAAM,EAAE,oBAAoB,CAAC,SAAS,EAAE,UAAU,IAAI,CAAC,CAAC;QACxD,GAAG,YAAY;KAChB,CAAC,CAAC;AACL,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,GAAc,EACd,EACE,SAAS,EACT,WAAW,EACX,OAAO,EACP,KAAK,GAUN;IAED,MAAM,SAAS,GAAG,uBAAuB,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAC5D,MAAM,SAAS,GAAG,kBAAkB,CAAC,SAAS,CAAC,CAAC;IAChD,MAAM,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE,CAC3C,uBAAuB,CAAC,WAAW,EAAE,MAAM,CAAC,CAC7C,CAAC;IACF,OAAO,GAAG,CAAC,YAAY,CAAC,SAAS,EAAE,QAAQ,EAAE;QAC3C,MAAM,EAAE,YAAY,CAAC,SAAS,CAAC;QAC/B,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE,CACZ,SAAS,CAAC,MAAM,KAAK,CAAC;YACpB,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,aAAa,EAAE,WAAW,CAAC;YAClC,CAAC,CAAC,CAAC,CAAC,EAAE,CACF,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,EAAE,CACnC,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,WAAW,EAAE,MAAM,CAAC,EAAE,EAAE,CACxD,CAAC,CAAC,EAAE,CAAC,WAA+C,EAAE,MAAM,CAAC,CAC9D,CACF,CACF;QACP,KAAK;KACN,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { type GenericTableSearchIndexes, type SchemaDefinition, type TableDefinition } from "convex/server";
|
|
2
|
+
import { type GenericId, type ObjectType, type VId, type VObject, type VUnion } from "convex/values";
|
|
3
|
+
declare const embeddingsFields: {
|
|
4
|
+
namespaceId: VId<GenericId<"namespaces">, "required">;
|
|
5
|
+
filter0: import("convex/values").VArray<[GenericId<"namespaces">, import("convex/values").Value] | undefined, VId<"namespaces", "required"> | import("convex/values").VAny<any, "required", string>, "optional">;
|
|
6
|
+
filter1: import("convex/values").VArray<[GenericId<"namespaces">, import("convex/values").Value] | undefined, VId<"namespaces", "required"> | import("convex/values").VAny<any, "required", string>, "optional">;
|
|
7
|
+
filter2: import("convex/values").VArray<[GenericId<"namespaces">, import("convex/values").Value] | undefined, VId<"namespaces", "required"> | import("convex/values").VAny<any, "required", string>, "optional">;
|
|
8
|
+
filter3: import("convex/values").VArray<[GenericId<"namespaces">, import("convex/values").Value] | undefined, VId<"namespaces", "required"> | import("convex/values").VAny<any, "required", string>, "optional">;
|
|
9
|
+
vector: import("convex/values").VArray<number[], import("convex/values").VFloat64<number, "required">, "required">;
|
|
10
|
+
};
|
|
11
|
+
type Table = TableDefinition<VObject<ObjectType<typeof embeddingsFields>, typeof embeddingsFields>, {
|
|
12
|
+
model_table_threadId: ["model", "table", "threadId", "_creationTime"];
|
|
13
|
+
}, GenericTableSearchIndexes, VectorIndex>;
|
|
14
|
+
type VectorIndex = {
|
|
15
|
+
vector: {
|
|
16
|
+
vectorField: "vector";
|
|
17
|
+
dimensions: number;
|
|
18
|
+
filterFields: string;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
export type VectorSchema = SchemaDefinition<{
|
|
22
|
+
[key in VectorTableName]: Table;
|
|
23
|
+
}, true>;
|
|
24
|
+
export declare const VectorDimensions: readonly [128, 256, 512, 768, 1024, 1408, 1536, 2048, 3072, 4096];
|
|
25
|
+
export declare function assertVectorDimension(dimension: number): asserts dimension is VectorDimension;
|
|
26
|
+
export declare function validateVectorDimension(dimension: number): VectorDimension;
|
|
27
|
+
export type VectorDimension = (typeof VectorDimensions)[number];
|
|
28
|
+
export declare const VectorTableNames: `vectors_${(typeof VectorDimensions)[number]}`[];
|
|
29
|
+
export type VectorTableName = (typeof VectorTableNames)[number];
|
|
30
|
+
export type VectorTableId = GenericId<(typeof VectorTableNames)[number]>;
|
|
31
|
+
export declare const vVectorDimension: VUnion<4096 | 128 | 256 | 512 | 768 | 1024 | 1408 | 1536 | 2048 | 3072, any, "required", any>;
|
|
32
|
+
export declare const vVectorTableName: VUnion<"vectors_4096" | "vectors_128" | "vectors_256" | "vectors_512" | "vectors_768" | "vectors_1024" | "vectors_1408" | "vectors_1536" | "vectors_2048" | "vectors_3072", any, "required", any>;
|
|
33
|
+
export declare const vVectorId: VUnion<GenericId<(typeof VectorTableNames)[number]>, VId<(typeof VectorTableNames)[number]>[]>;
|
|
34
|
+
export declare function getVectorTableName(dimension: VectorDimension): VectorTableName;
|
|
35
|
+
declare const tables: {
|
|
36
|
+
[K in keyof typeof VectorDimensions & number as `vectors_${(typeof VectorDimensions)[K]}`]: Table;
|
|
37
|
+
};
|
|
38
|
+
export default tables;
|
|
39
|
+
//# sourceMappingURL=tables.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tables.d.ts","sourceRoot":"","sources":["../../../src/component/embeddings/tables.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,yBAAyB,EAC9B,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACrB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,KAAK,SAAS,EACd,KAAK,UAAU,EAEf,KAAK,GAAG,EACR,KAAK,OAAO,EACZ,KAAK,MAAM,EACZ,MAAM,eAAe,CAAC;AAKvB,QAAA,MAAM,gBAAgB;;;;;;;CAGrB,CAAC;AAUF,KAAK,KAAK,GAAG,eAAe,CAC1B,OAAO,CAAC,UAAU,CAAC,OAAO,gBAAgB,CAAC,EAAE,OAAO,gBAAgB,CAAC,EACrE;IAAE,oBAAoB,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,eAAe,CAAC,CAAA;CAAE,EACzE,yBAAyB,EACzB,WAAW,CACZ,CAAC;AAEF,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE;QACN,WAAW,EAAE,QAAQ,CAAC;QACtB,UAAU,EAAE,MAA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MAAM,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { literals } from "convex-helpers/validators";
|
|
2
|
+
import { defineTable, } from "convex/server";
|
|
3
|
+
import { v, } from "convex/values";
|
|
4
|
+
import { vectorWithImportanceDimension } from "./importance.js";
|
|
5
|
+
import { allFilterFieldNames, vAllFilterFields } from "../filters.js";
|
|
6
|
+
// We only generate embeddings for non-tool, non-system messages
|
|
7
|
+
const embeddingsFields = {
|
|
8
|
+
vector: v.array(v.number()),
|
|
9
|
+
...vAllFilterFields,
|
|
10
|
+
};
|
|
11
|
+
function table(dimensions) {
|
|
12
|
+
return defineTable(embeddingsFields).vectorIndex("vector", {
|
|
13
|
+
vectorField: "vector",
|
|
14
|
+
dimensions: vectorWithImportanceDimension(dimensions),
|
|
15
|
+
filterFields: allFilterFieldNames,
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
export const VectorDimensions = [
|
|
19
|
+
128, 256, 512, 768, 1024, 1408, 1536, 2048, 3072, 4096,
|
|
20
|
+
];
|
|
21
|
+
export function assertVectorDimension(dimension) {
|
|
22
|
+
if (!VectorDimensions.includes(dimension)) {
|
|
23
|
+
throw new Error(`Unsupported vector dimension${dimension}. Supported: ${VectorDimensions.join(", ")}`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export function validateVectorDimension(dimension) {
|
|
27
|
+
if (!VectorDimensions.includes(dimension)) {
|
|
28
|
+
throw new Error(`Unsupported vector dimension${dimension}. Supported: ${VectorDimensions.join(", ")}`);
|
|
29
|
+
}
|
|
30
|
+
return dimension;
|
|
31
|
+
}
|
|
32
|
+
export const VectorTableNames = VectorDimensions.map((d) => `vectors_${d}`);
|
|
33
|
+
export const vVectorDimension = literals(...VectorDimensions);
|
|
34
|
+
export const vVectorTableName = literals(...VectorTableNames);
|
|
35
|
+
export const vVectorId = v.union(...VectorTableNames.map((name) => v.id(name)));
|
|
36
|
+
export function getVectorTableName(dimension) {
|
|
37
|
+
return `vectors_${dimension}`;
|
|
38
|
+
}
|
|
39
|
+
// export function getVectorIdInfo(ctx: QueryCtx, id: VectorTableId) {
|
|
40
|
+
// for (const dimension of VectorDimensions) {
|
|
41
|
+
// const tableName = getVectorTableName(dimension);
|
|
42
|
+
// if (ctx.db.normalizeId(tableName, id)) {
|
|
43
|
+
// return { tableName, dimension };
|
|
44
|
+
// }
|
|
45
|
+
// }
|
|
46
|
+
// throw new Error(`Unknown vector table id: ${id}`);
|
|
47
|
+
// }
|
|
48
|
+
const tables = Object.fromEntries(VectorDimensions.map((dimensions) => [
|
|
49
|
+
`vectors_${dimensions}`,
|
|
50
|
+
table(dimensions),
|
|
51
|
+
]));
|
|
52
|
+
export default tables;
|
|
53
|
+
//# sourceMappingURL=tables.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tables.js","sourceRoot":"","sources":["../../../src/component/embeddings/tables.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACrD,OAAO,EACL,WAAW,GAIZ,MAAM,eAAe,CAAC;AACvB,OAAO,EAGL,CAAC,GAIF,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,6BAA6B,EAAE,MAAM,iBAAiB,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEtE,gEAAgE;AAChE,MAAM,gBAAgB,GAAG;IACvB,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IAC3B,GAAG,gBAAgB;CACpB,CAAC;AAEF,SAAS,KAAK,CAAC,UAA2B;IACxC,OAAO,WAAW,CAAC,gBAAgB,CAAC,CAAC,WAAW,CAAC,QAAQ,EAAE;QACzD,WAAW,EAAE,QAAQ;QACrB,UAAU,EAAE,6BAA6B,CAAC,UAAU,CAAC;QACrD,YAAY,EAAE,mBAAmB;KAClC,CAAC,CAAC;AACL,CAAC;AAsBD,MAAM,CAAC,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;AACtE,gDAAgD;AAChD,uDAAuD;AACvD,+CAA+C;AAC/C,yCAAyC;AACzC,QAAQ;AACR,MAAM;AACN,uDAAuD;AACvD,IAAI;AAEJ,MAAM,MAAM,GAGR,MAAM,CAAC,WAAW,CACpB,gBAAgB,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC;IACnC,WAAW,UAAU,EAAE;IACvB,KAAK,CAAC,UAAU,CAAC;CAClB,CAAC,CAC8D,CAAC;AAEnE,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { type Value } from "convex/values";
|
|
2
|
+
import type { EntryFilterValues } from "../shared.js";
|
|
3
|
+
import { type Entry } from "../shared.js";
|
|
4
|
+
import type { Doc, Id } from "./_generated/dataModel.js";
|
|
5
|
+
import { type QueryCtx } from "./_generated/server.js";
|
|
6
|
+
import { type StatusWithOnComplete } from "./schema.js";
|
|
7
|
+
export declare const addAsync: import("convex/server").RegisteredMutation<"public", {
|
|
8
|
+
onComplete?: string | undefined;
|
|
9
|
+
entry: {
|
|
10
|
+
metadata?: Record<string, any> | undefined;
|
|
11
|
+
key?: string | undefined;
|
|
12
|
+
title?: string | undefined;
|
|
13
|
+
contentHash?: string | undefined;
|
|
14
|
+
namespaceId: import("convex/values").GenericId<"namespaces">;
|
|
15
|
+
importance: number;
|
|
16
|
+
filterValues: {
|
|
17
|
+
name: string;
|
|
18
|
+
value: any;
|
|
19
|
+
}[];
|
|
20
|
+
};
|
|
21
|
+
chunker: string;
|
|
22
|
+
}, Promise<{
|
|
23
|
+
entryId: import("convex/values").GenericId<"entries">;
|
|
24
|
+
status: "ready";
|
|
25
|
+
created: boolean;
|
|
26
|
+
} | {
|
|
27
|
+
entryId: import("convex/values").GenericId<"entries">;
|
|
28
|
+
status: "pending";
|
|
29
|
+
created: boolean;
|
|
30
|
+
}>>;
|
|
31
|
+
export declare const addAsyncOnComplete: import("convex/server").RegisteredMutation<"internal", {
|
|
32
|
+
workId: import("@convex-dev/workpool").WorkId;
|
|
33
|
+
result: {
|
|
34
|
+
kind: "success";
|
|
35
|
+
returnValue: any;
|
|
36
|
+
} | {
|
|
37
|
+
kind: "failed";
|
|
38
|
+
error: string;
|
|
39
|
+
} | {
|
|
40
|
+
kind: "canceled";
|
|
41
|
+
};
|
|
42
|
+
context: import("convex/values").GenericId<"entries">;
|
|
43
|
+
}, Promise<void>>;
|
|
44
|
+
export declare const add: import("convex/server").RegisteredMutation<"public", {
|
|
45
|
+
onComplete?: string | undefined;
|
|
46
|
+
allChunks?: {
|
|
47
|
+
searchableText?: string | undefined;
|
|
48
|
+
content: {
|
|
49
|
+
metadata?: Record<string, any> | undefined;
|
|
50
|
+
text: string;
|
|
51
|
+
};
|
|
52
|
+
embedding: number[];
|
|
53
|
+
}[] | undefined;
|
|
54
|
+
entry: {
|
|
55
|
+
metadata?: Record<string, any> | undefined;
|
|
56
|
+
key?: string | undefined;
|
|
57
|
+
title?: string | undefined;
|
|
58
|
+
contentHash?: string | undefined;
|
|
59
|
+
namespaceId: import("convex/values").GenericId<"namespaces">;
|
|
60
|
+
importance: number;
|
|
61
|
+
filterValues: {
|
|
62
|
+
name: string;
|
|
63
|
+
value: any;
|
|
64
|
+
}[];
|
|
65
|
+
};
|
|
66
|
+
}, Promise<{
|
|
67
|
+
entryId: import("convex/values").GenericId<"entries">;
|
|
68
|
+
status: "ready";
|
|
69
|
+
created: boolean;
|
|
70
|
+
replacedVersion: Entry | null;
|
|
71
|
+
} | {
|
|
72
|
+
entryId: import("convex/values").GenericId<"entries">;
|
|
73
|
+
status: "pending";
|
|
74
|
+
created: boolean;
|
|
75
|
+
replacedVersion: null;
|
|
76
|
+
}>>;
|
|
77
|
+
/**
|
|
78
|
+
* Lists entries in order of their most recent change
|
|
79
|
+
*/
|
|
80
|
+
export declare const list: import("convex/server").RegisteredQuery<"public", {
|
|
81
|
+
order?: "asc" | "desc" | undefined;
|
|
82
|
+
namespaceId: import("convex/values").GenericId<"namespaces">;
|
|
83
|
+
status: "pending" | "ready" | "replaced";
|
|
84
|
+
paginationOpts: {
|
|
85
|
+
id?: number | undefined;
|
|
86
|
+
endCursor?: string | null | undefined;
|
|
87
|
+
maximumRowsRead?: number | undefined;
|
|
88
|
+
maximumBytesRead?: number | undefined;
|
|
89
|
+
numItems: number;
|
|
90
|
+
cursor: string | null;
|
|
91
|
+
};
|
|
92
|
+
}, Promise<{
|
|
93
|
+
page: Entry[];
|
|
94
|
+
isDone: boolean;
|
|
95
|
+
continueCursor: import("convex/server").Cursor;
|
|
96
|
+
splitCursor?: import("convex/server").Cursor | null;
|
|
97
|
+
pageStatus?: "SplitRecommended" | "SplitRequired" | null;
|
|
98
|
+
}>>;
|
|
99
|
+
/**
|
|
100
|
+
* Gets a entry by its id.
|
|
101
|
+
*/
|
|
102
|
+
export declare const get: import("convex/server").RegisteredQuery<"public", {
|
|
103
|
+
entryId: import("convex/values").GenericId<"entries">;
|
|
104
|
+
}, Promise<Entry | null>>;
|
|
105
|
+
/**
|
|
106
|
+
* Finds a entry by its key and content hash.
|
|
107
|
+
*/
|
|
108
|
+
export declare const findByContentHash: import("convex/server").RegisteredQuery<"public", {
|
|
109
|
+
namespace: string;
|
|
110
|
+
filterNames: string[];
|
|
111
|
+
dimension: number;
|
|
112
|
+
modelId: string;
|
|
113
|
+
key: string;
|
|
114
|
+
contentHash: string;
|
|
115
|
+
}, Promise<Entry | null>>;
|
|
116
|
+
/**
|
|
117
|
+
* Promotes a entry to ready, replacing any existing ready entry by key.
|
|
118
|
+
* It will also call the associated onComplete function if it was pending.
|
|
119
|
+
* Note: this will not replace the chunks automatically, so you should first
|
|
120
|
+
* call `replaceChunksPage` on all its chunks.
|
|
121
|
+
* Edge case: if the entry has already been replaced, it will return the
|
|
122
|
+
* same entry (replacedVersion.entryId === args.entryId).
|
|
123
|
+
*/
|
|
124
|
+
export declare const promoteToReady: import("convex/server").RegisteredMutation<"public", {
|
|
125
|
+
entryId: Id<"entries">;
|
|
126
|
+
}, Promise<{
|
|
127
|
+
replacedVersion: Entry | null;
|
|
128
|
+
}>>;
|
|
129
|
+
export declare function getPreviousEntry(ctx: QueryCtx, entry: Doc<"entries">): Promise<{
|
|
130
|
+
_id: import("convex/values").GenericId<"entries">;
|
|
131
|
+
_creationTime: number;
|
|
132
|
+
metadata?: Record<string, any> | undefined;
|
|
133
|
+
key?: string | undefined;
|
|
134
|
+
title?: string | undefined;
|
|
135
|
+
contentHash?: string | undefined;
|
|
136
|
+
namespaceId: import("convex/values").GenericId<"namespaces">;
|
|
137
|
+
status: {
|
|
138
|
+
onComplete?: string | undefined;
|
|
139
|
+
kind: "pending";
|
|
140
|
+
} | {
|
|
141
|
+
kind: "ready";
|
|
142
|
+
} | {
|
|
143
|
+
kind: "replaced";
|
|
144
|
+
replacedAt: number;
|
|
145
|
+
};
|
|
146
|
+
version: number;
|
|
147
|
+
importance: number;
|
|
148
|
+
filterValues: {
|
|
149
|
+
name: string;
|
|
150
|
+
value: any;
|
|
151
|
+
}[];
|
|
152
|
+
} | null>;
|
|
153
|
+
export declare function publicEntry(entry: {
|
|
154
|
+
_id: Id<"entries">;
|
|
155
|
+
key?: string | undefined;
|
|
156
|
+
importance: number;
|
|
157
|
+
filterValues: EntryFilterValues[];
|
|
158
|
+
contentHash?: string | undefined;
|
|
159
|
+
title?: string | undefined;
|
|
160
|
+
metadata?: Record<string, Value> | undefined;
|
|
161
|
+
status: StatusWithOnComplete;
|
|
162
|
+
}): Entry;
|
|
163
|
+
export declare const deleteAsync: import("convex/server").RegisteredMutation<"public", {
|
|
164
|
+
entryId: Id<"entries">;
|
|
165
|
+
startOrder: number;
|
|
166
|
+
}, Promise<void>>;
|
|
167
|
+
//# sourceMappingURL=entries.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entries.d.ts","sourceRoot":"","sources":["../../src/component/entries.ts"],"names":[],"mappings":"AAEA,OAAO,EAAK,KAAK,KAAK,EAAE,MAAM,eAAe,CAAC;AAC9C,O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