@convex-dev/rag 0.1.7 → 0.3.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/README.md +200 -85
- package/dist/client/index.d.ts +2 -2
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +5 -5
- package/dist/client/index.js.map +1 -1
- package/dist/component/_generated/api.d.ts +10 -4
- package/dist/component/entries.d.ts +6 -6
- package/dist/component/entries.d.ts.map +1 -1
- package/dist/component/entries.js +29 -16
- package/dist/component/entries.js.map +1 -1
- package/dist/component/namespaces.d.ts +3 -3
- package/dist/component/namespaces.js +4 -4
- package/dist/component/namespaces.js.map +1 -1
- package/dist/component/schema.d.ts +31 -31
- package/dist/shared.d.ts +26 -9
- package/dist/shared.d.ts.map +1 -1
- package/dist/shared.js +2 -1
- package/dist/shared.js.map +1 -1
- package/package.json +1 -6
- package/src/client/index.test.ts +19 -19
- package/src/client/index.ts +7 -7
- package/src/component/_generated/api.d.ts +10 -4
- package/src/component/entries.test.ts +16 -16
- package/src/component/entries.ts +28 -16
- package/src/component/namespaces.ts +4 -4
- package/src/shared.ts +13 -5
package/dist/shared.d.ts
CHANGED
|
@@ -73,6 +73,7 @@ export declare const vEntry: VObject<{
|
|
|
73
73
|
key?: string | undefined;
|
|
74
74
|
title?: string | undefined;
|
|
75
75
|
contentHash?: string | undefined;
|
|
76
|
+
replacedAt?: number | undefined;
|
|
76
77
|
entryId: string & {
|
|
77
78
|
_: "EntryId";
|
|
78
79
|
};
|
|
@@ -102,13 +103,15 @@ export declare const vEntry: VObject<{
|
|
|
102
103
|
}, "required", "name" | "value" | `value.${string}`>, "required">;
|
|
103
104
|
contentHash: import("convex/values").VString<string | undefined, "optional">;
|
|
104
105
|
status: import("convex/values").VUnion<"pending" | "ready" | "replaced", [import("convex/values").VLiteral<"pending", "required">, import("convex/values").VLiteral<"ready", "required">, import("convex/values").VLiteral<"replaced", "required">], "required", never>;
|
|
105
|
-
|
|
106
|
+
replacedAt: import("convex/values").VFloat64<number | undefined, "optional">;
|
|
107
|
+
}, "required", "entryId" | "metadata" | `metadata.${string}` | "status" | "key" | "title" | "importance" | "filterValues" | "contentHash" | "replacedAt">;
|
|
106
108
|
export type VEntry<Filters extends Record<string, Value>, Metadata extends Record<string, Value>> = VObject<Entry<Filters, Metadata>, typeof vEntry.fields, "required", typeof vEntry.fieldPaths>;
|
|
107
109
|
export declare const vSearchEntry: VObject<{
|
|
108
110
|
metadata?: Record<string, any> | undefined;
|
|
109
111
|
key?: string | undefined;
|
|
110
112
|
title?: string | undefined;
|
|
111
113
|
contentHash?: string | undefined;
|
|
114
|
+
replacedAt?: number | undefined;
|
|
112
115
|
entryId: string & {
|
|
113
116
|
_: "EntryId";
|
|
114
117
|
};
|
|
@@ -140,7 +143,8 @@ export declare const vSearchEntry: VObject<{
|
|
|
140
143
|
}, "required", "name" | "value" | `value.${string}`>, "required">;
|
|
141
144
|
contentHash: import("convex/values").VString<string | undefined, "optional">;
|
|
142
145
|
status: import("convex/values").VUnion<"pending" | "ready" | "replaced", [import("convex/values").VLiteral<"pending", "required">, import("convex/values").VLiteral<"ready", "required">, import("convex/values").VLiteral<"replaced", "required">], "required", never>;
|
|
143
|
-
|
|
146
|
+
replacedAt: import("convex/values").VFloat64<number | undefined, "optional">;
|
|
147
|
+
}, "required", "entryId" | "text" | "metadata" | `metadata.${string}` | "status" | "key" | "title" | "importance" | "filterValues" | "contentHash" | "replacedAt">;
|
|
144
148
|
export type VSearchEntry<Filters extends Record<string, Value>, Metadata extends Record<string, Value>> = VObject<SearchEntry<Filters, Metadata>, typeof vSearchEntry.fields, "required", typeof vSearchEntry.fieldPaths>;
|
|
145
149
|
export type SearchEntry<Filters extends Record<string, Value>, Metadata extends Record<string, Value>> = Entry<Filters, Metadata> & {
|
|
146
150
|
text: string;
|
|
@@ -169,9 +173,13 @@ export type Entry<Filters extends Record<string, Value> = any, Metadata extends
|
|
|
169
173
|
* If supplied, it will avoid adding if the hash is the same.
|
|
170
174
|
*/
|
|
171
175
|
contentHash?: string | undefined;
|
|
176
|
+
} & ({
|
|
172
177
|
/** Whether this entry's contents have all been inserted and indexed. */
|
|
173
|
-
status:
|
|
174
|
-
}
|
|
178
|
+
status: "pending" | "ready";
|
|
179
|
+
} | {
|
|
180
|
+
status: "replaced";
|
|
181
|
+
replacedAt: number;
|
|
182
|
+
});
|
|
175
183
|
export declare const vChunk: VObject<{
|
|
176
184
|
metadata?: Record<string, any> | undefined;
|
|
177
185
|
order: number;
|
|
@@ -226,6 +234,7 @@ export declare const vOnCompleteArgs: VObject<{
|
|
|
226
234
|
key?: string | undefined;
|
|
227
235
|
title?: string | undefined;
|
|
228
236
|
contentHash?: string | undefined;
|
|
237
|
+
replacedAt?: number | undefined;
|
|
229
238
|
entryId: string & {
|
|
230
239
|
_: "EntryId";
|
|
231
240
|
};
|
|
@@ -254,6 +263,7 @@ export declare const vOnCompleteArgs: VObject<{
|
|
|
254
263
|
key?: string | undefined;
|
|
255
264
|
title?: string | undefined;
|
|
256
265
|
contentHash?: string | undefined;
|
|
266
|
+
replacedAt?: number | undefined;
|
|
257
267
|
entryId: string & {
|
|
258
268
|
_: "EntryId";
|
|
259
269
|
};
|
|
@@ -293,6 +303,7 @@ export declare const vOnCompleteArgs: VObject<{
|
|
|
293
303
|
key?: string | undefined;
|
|
294
304
|
title?: string | undefined;
|
|
295
305
|
contentHash?: string | undefined;
|
|
306
|
+
replacedAt?: number | undefined;
|
|
296
307
|
entryId: string & {
|
|
297
308
|
_: "EntryId";
|
|
298
309
|
};
|
|
@@ -322,12 +333,14 @@ export declare const vOnCompleteArgs: VObject<{
|
|
|
322
333
|
}, "required", "name" | "value" | `value.${string}`>, "required">;
|
|
323
334
|
contentHash: import("convex/values").VString<string | undefined, "optional">;
|
|
324
335
|
status: import("convex/values").VUnion<"pending" | "ready" | "replaced", [import("convex/values").VLiteral<"pending", "required">, import("convex/values").VLiteral<"ready", "required">, import("convex/values").VLiteral<"replaced", "required">], "required", never>;
|
|
325
|
-
|
|
336
|
+
replacedAt: import("convex/values").VFloat64<number | undefined, "optional">;
|
|
337
|
+
}, "required", "entryId" | "metadata" | `metadata.${string}` | "status" | "key" | "title" | "importance" | "filterValues" | "contentHash" | "replacedAt">;
|
|
326
338
|
replacedEntry: VObject<{
|
|
327
339
|
metadata?: Record<string, any> | undefined;
|
|
328
340
|
key?: string | undefined;
|
|
329
341
|
title?: string | undefined;
|
|
330
342
|
contentHash?: string | undefined;
|
|
343
|
+
replacedAt?: number | undefined;
|
|
331
344
|
entryId: string & {
|
|
332
345
|
_: "EntryId";
|
|
333
346
|
};
|
|
@@ -357,9 +370,10 @@ export declare const vOnCompleteArgs: VObject<{
|
|
|
357
370
|
}, "required", "name" | "value" | `value.${string}`>, "required">;
|
|
358
371
|
contentHash: import("convex/values").VString<string | undefined, "optional">;
|
|
359
372
|
status: import("convex/values").VUnion<"pending" | "ready" | "replaced", [import("convex/values").VLiteral<"pending", "required">, import("convex/values").VLiteral<"ready", "required">, import("convex/values").VLiteral<"replaced", "required">], "required", never>;
|
|
360
|
-
|
|
373
|
+
replacedAt: import("convex/values").VFloat64<number | undefined, "optional">;
|
|
374
|
+
}, "optional", "entryId" | "metadata" | `metadata.${string}` | "status" | "key" | "title" | "importance" | "filterValues" | "contentHash" | "replacedAt">;
|
|
361
375
|
error: import("convex/values").VString<string | undefined, "optional">;
|
|
362
|
-
}, "required", "namespace" | "entry" | "replacedEntry" | "error" | "namespace.namespaceId" | "namespace.createdAt" | "namespace.namespace" | "namespace.status" | "namespace.filterNames" | "namespace.dimension" | "namespace.modelId" | "namespace.version" | "entry.entryId" | "entry.metadata" | `entry.metadata.${string}` | "entry.status" | "entry.key" | "entry.title" | "entry.importance" | "entry.filterValues" | "entry.contentHash" | "replacedEntry.entryId" | "replacedEntry.metadata" | `replacedEntry.metadata.${string}` | "replacedEntry.status" | "replacedEntry.key" | "replacedEntry.title" | "replacedEntry.importance" | "replacedEntry.filterValues" | "replacedEntry.contentHash">;
|
|
376
|
+
}, "required", "namespace" | "entry" | "replacedEntry" | "error" | "namespace.namespaceId" | "namespace.createdAt" | "namespace.namespace" | "namespace.status" | "namespace.filterNames" | "namespace.dimension" | "namespace.modelId" | "namespace.version" | "entry.entryId" | "entry.metadata" | `entry.metadata.${string}` | "entry.status" | "entry.key" | "entry.title" | "entry.importance" | "entry.filterValues" | "entry.contentHash" | "entry.replacedAt" | "replacedEntry.entryId" | "replacedEntry.metadata" | `replacedEntry.metadata.${string}` | "replacedEntry.status" | "replacedEntry.key" | "replacedEntry.title" | "replacedEntry.importance" | "replacedEntry.filterValues" | "replacedEntry.contentHash" | "replacedEntry.replacedAt">;
|
|
363
377
|
export type OnComplete<Filters extends Record<string, Value> = any, EntryMetadata extends Record<string, Value> = any> = FunctionReference<"mutation", "internal", {
|
|
364
378
|
/**
|
|
365
379
|
* The namespace that the entry belongs to.
|
|
@@ -396,6 +410,7 @@ export declare const vChunkerArgs: VObject<{
|
|
|
396
410
|
key?: string | undefined;
|
|
397
411
|
title?: string | undefined;
|
|
398
412
|
contentHash?: string | undefined;
|
|
413
|
+
replacedAt?: number | undefined;
|
|
399
414
|
entryId: string & {
|
|
400
415
|
_: "EntryId";
|
|
401
416
|
};
|
|
@@ -436,6 +451,7 @@ export declare const vChunkerArgs: VObject<{
|
|
|
436
451
|
key?: string | undefined;
|
|
437
452
|
title?: string | undefined;
|
|
438
453
|
contentHash?: string | undefined;
|
|
454
|
+
replacedAt?: number | undefined;
|
|
439
455
|
entryId: string & {
|
|
440
456
|
_: "EntryId";
|
|
441
457
|
};
|
|
@@ -465,9 +481,10 @@ export declare const vChunkerArgs: VObject<{
|
|
|
465
481
|
}, "required", "name" | "value" | `value.${string}`>, "required">;
|
|
466
482
|
contentHash: import("convex/values").VString<string | undefined, "optional">;
|
|
467
483
|
status: import("convex/values").VUnion<"pending" | "ready" | "replaced", [import("convex/values").VLiteral<"pending", "required">, import("convex/values").VLiteral<"ready", "required">, import("convex/values").VLiteral<"replaced", "required">], "required", never>;
|
|
468
|
-
|
|
484
|
+
replacedAt: import("convex/values").VFloat64<number | undefined, "optional">;
|
|
485
|
+
}, "required", "entryId" | "metadata" | `metadata.${string}` | "status" | "key" | "title" | "importance" | "filterValues" | "contentHash" | "replacedAt">;
|
|
469
486
|
insertChunks: import("convex/values").VString<string, "required">;
|
|
470
|
-
}, "required", "namespace" | "entry" | "namespace.namespaceId" | "namespace.createdAt" | "namespace.namespace" | "namespace.status" | "namespace.filterNames" | "namespace.dimension" | "namespace.modelId" | "namespace.version" | "entry.entryId" | "entry.metadata" | `entry.metadata.${string}` | "entry.status" | "entry.key" | "entry.title" | "entry.importance" | "entry.filterValues" | "entry.contentHash" | "insertChunks">;
|
|
487
|
+
}, "required", "namespace" | "entry" | "namespace.namespaceId" | "namespace.createdAt" | "namespace.namespace" | "namespace.status" | "namespace.filterNames" | "namespace.dimension" | "namespace.modelId" | "namespace.version" | "entry.entryId" | "entry.metadata" | `entry.metadata.${string}` | "entry.status" | "entry.key" | "entry.title" | "entry.importance" | "entry.filterValues" | "entry.contentHash" | "entry.replacedAt" | "insertChunks">;
|
|
471
488
|
export type ChunkerAction = FunctionReference<"action", "internal", Infer<typeof vChunkerArgs>, null>;
|
|
472
489
|
/**
|
|
473
490
|
* Check if the args filter names are compatible with the existing filter names.
|
package/dist/shared.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../src/shared.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACtE,OAAO,EAAgB,KAAK,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAExE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAIvD,eAAO,MAAM,gBAAgB,MAAM,CAAC;AAGpC,eAAO,MAAM,YAAY;;cAA+B,CAAC;AACzD,eAAO,MAA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2bAIvB,CAAC;AAEH,MAAM,MAAM,aAAa,GAAG,iBAAiB,CAC3C,QAAQ,EACR,UAAU,EACV,KAAK,CAAC,OAAO,YAAY,CAAC,EAC1B,IAAI,CACL,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,WAOpE"}
|
package/dist/shared.js
CHANGED
|
@@ -39,8 +39,9 @@ export const vEntry = v.object({
|
|
|
39
39
|
filterValues: v.array(vNamedFilter),
|
|
40
40
|
contentHash: v.optional(v.string()),
|
|
41
41
|
status: vStatus,
|
|
42
|
+
replacedAt: v.optional(v.number()),
|
|
42
43
|
});
|
|
43
|
-
// Type assertion to keep us honest
|
|
44
|
+
// Type assertion to keep us honest (modulo the replacedAt field)
|
|
44
45
|
const _1 = {};
|
|
45
46
|
const _2 = {};
|
|
46
47
|
export const vSearchEntry = v.object({
|
package/dist/shared.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../src/shared.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAElC,OAAO,EAAE,YAAY,EAAoB,MAAM,wBAAwB,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAG1D,yEAAyE;AACzE,gDAAgD;AAChD,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,CAAC;AAEpC,2EAA2E;AAC3E,MAAM,CAAC,MAAM,YAAY,GAAG,aAAa,CAAC,aAAa,CAAC,CAAC;AACzD,MAAM,CAAC,MAAM,QAAQ,GAAG,aAAa,CAAC,SAAS,CAAC,CAAC;AAIjD,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC,MAAM,CAAC;IACpC,OAAO,EAAE,QAAQ;IACjB,KAAK,EAAE,CAAC,CAA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M,CAAC,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,CAAC;IACnC,SAAS,EAAE,UAAU;IACrB,KAAK,EAAE,MAAM;IACb,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE;CACzB,CAAC,CAAC;AASH;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAAC,QAAkB,EAAE,IAAc;IACnE,KAAK,MAAM,IAAI,IAAI,IAAI,EAAE,CAAC;QACxB,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;YAC7B,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/package.json
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
"email": "support@convex.dev",
|
|
8
8
|
"url": "https://github.com/get-convex/rag/issues"
|
|
9
9
|
},
|
|
10
|
-
"version": "0.1
|
|
10
|
+
"version": "0.3.1",
|
|
11
11
|
"license": "Apache-2.0",
|
|
12
12
|
"keywords": [
|
|
13
13
|
"convex",
|
|
@@ -51,11 +51,6 @@
|
|
|
51
51
|
"types": "./dist/client/index.d.ts",
|
|
52
52
|
"default": "./dist/client/index.js"
|
|
53
53
|
},
|
|
54
|
-
"./react": {
|
|
55
|
-
"@convex-dev/component-source": "./src/react/index.ts",
|
|
56
|
-
"types": "./dist/react/index.d.ts",
|
|
57
|
-
"default": "./dist/react/index.js"
|
|
58
|
-
},
|
|
59
54
|
"./convex.config": {
|
|
60
55
|
"@convex-dev/component-source": "./src/component/convex.config.ts",
|
|
61
56
|
"types": "./dist/component/convex.config.d.ts",
|
package/src/client/index.test.ts
CHANGED
|
@@ -200,16 +200,16 @@ describe("RAG thick client", () => {
|
|
|
200
200
|
limit: 10,
|
|
201
201
|
});
|
|
202
202
|
|
|
203
|
-
// Should match README format: "
|
|
204
|
-
expect(text).toContain("
|
|
203
|
+
// Should match README format: "## Title:\n{entry.text}"
|
|
204
|
+
expect(text).toContain("## Test Document:");
|
|
205
205
|
expect(entries).toHaveLength(1);
|
|
206
206
|
expect(entries[0].text).toBe(
|
|
207
207
|
"Chunk 1 content\nChunk 2 content\nChunk 3 content"
|
|
208
208
|
);
|
|
209
209
|
|
|
210
|
-
// Overall text should be: "
|
|
210
|
+
// Overall text should be: "## Test Document:\nChunk 1 content\nChunk 2 content\nChunk 3 content"
|
|
211
211
|
expect(text).toBe(
|
|
212
|
-
"
|
|
212
|
+
"## Test Document:\nChunk 1 content\nChunk 2 content\nChunk 3 content"
|
|
213
213
|
);
|
|
214
214
|
});
|
|
215
215
|
|
|
@@ -235,8 +235,8 @@ describe("RAG thick client", () => {
|
|
|
235
235
|
limit: 10,
|
|
236
236
|
});
|
|
237
237
|
|
|
238
|
-
// Should not have "
|
|
239
|
-
expect(text).not.toContain("
|
|
238
|
+
// Should not have "## " prefix since no title
|
|
239
|
+
expect(text).not.toContain("## ");
|
|
240
240
|
expect(entries).toHaveLength(1);
|
|
241
241
|
expect(entries[0].text).toBe("Content without title");
|
|
242
242
|
expect(text).toBe("Content without title");
|
|
@@ -337,11 +337,11 @@ describe("RAG thick client", () => {
|
|
|
337
337
|
|
|
338
338
|
// Should have entries separated by "\n---\n" as per README
|
|
339
339
|
expect(text).toContain("---");
|
|
340
|
-
expect(text).toMatch(
|
|
340
|
+
expect(text).toMatch(/## .+:\n.+\n---\n## .+:\n.+/);
|
|
341
341
|
|
|
342
|
-
// Should have both titles prefixed with "
|
|
343
|
-
expect(text).toContain("
|
|
344
|
-
expect(text).toContain("
|
|
342
|
+
// Should have both titles prefixed with "## "
|
|
343
|
+
expect(text).toContain("## First Document:");
|
|
344
|
+
expect(text).toContain("## Second Document:");
|
|
345
345
|
|
|
346
346
|
expect(entries).toHaveLength(2);
|
|
347
347
|
});
|
|
@@ -384,14 +384,14 @@ describe("RAG thick client", () => {
|
|
|
384
384
|
|
|
385
385
|
// Should properly handle mixed formatting
|
|
386
386
|
expect(text).toContain("---"); // Entries should be separated
|
|
387
|
-
expect(text).toContain("
|
|
387
|
+
expect(text).toContain("## Titled Document:"); // Titled entry should have prefix
|
|
388
388
|
|
|
389
389
|
// One entry should have title format, one should not
|
|
390
390
|
const parts = text.split("\n---\n");
|
|
391
391
|
expect(parts).toHaveLength(2);
|
|
392
392
|
|
|
393
|
-
const hasTitle = parts.some((part) => part.startsWith("
|
|
394
|
-
const hasNoTitle = parts.some((part) => !part.startsWith("
|
|
393
|
+
const hasTitle = parts.some((part) => part.startsWith("## "));
|
|
394
|
+
const hasNoTitle = parts.some((part) => !part.startsWith("## "));
|
|
395
395
|
expect(hasTitle).toBe(true);
|
|
396
396
|
expect(hasNoTitle).toBe(true);
|
|
397
397
|
|
|
@@ -445,28 +445,28 @@ describe("RAG thick client", () => {
|
|
|
445
445
|
});
|
|
446
446
|
|
|
447
447
|
// Verify basic structure matches README
|
|
448
|
-
expect(text).toContain("
|
|
449
|
-
expect(text).toContain("
|
|
448
|
+
expect(text).toContain("## Title 1:");
|
|
449
|
+
expect(text).toContain("## Title 2:");
|
|
450
450
|
expect(text).toContain("---");
|
|
451
451
|
|
|
452
452
|
// Should have proper entry separation
|
|
453
453
|
const parts = text.split("\n---\n");
|
|
454
454
|
expect(parts).toHaveLength(2);
|
|
455
455
|
|
|
456
|
-
// Each part should start with "
|
|
456
|
+
// Each part should start with "## Title X:"
|
|
457
457
|
parts.forEach((part) => {
|
|
458
|
-
expect(part).toMatch(
|
|
458
|
+
expect(part).toMatch(/^## Title \d+:/);
|
|
459
459
|
});
|
|
460
460
|
|
|
461
461
|
expect(entries).toHaveLength(2);
|
|
462
462
|
|
|
463
463
|
// Individual entry texts should follow the pattern
|
|
464
464
|
expect(text).toBe(
|
|
465
|
-
|
|
465
|
+
`## Title 1:
|
|
466
466
|
Chunk 1 contents
|
|
467
467
|
Chunk 2 contents
|
|
468
468
|
---
|
|
469
|
-
|
|
469
|
+
## Title 2:
|
|
470
470
|
Chunk 3 contents
|
|
471
471
|
Chunk 4 contents`
|
|
472
472
|
);
|
package/src/client/index.ts
CHANGED
|
@@ -155,7 +155,7 @@ export class RAG<
|
|
|
155
155
|
entryId: EntryId;
|
|
156
156
|
status: Status;
|
|
157
157
|
created: boolean;
|
|
158
|
-
|
|
158
|
+
replacedEntry: Entry<FitlerSchemas, EntryMetadata> | null;
|
|
159
159
|
}> {
|
|
160
160
|
let namespaceId: NamespaceId;
|
|
161
161
|
if ("namespaceId" in args) {
|
|
@@ -182,7 +182,7 @@ export class RAG<
|
|
|
182
182
|
const onComplete =
|
|
183
183
|
args.onComplete && (await createFunctionHandle(args.onComplete));
|
|
184
184
|
|
|
185
|
-
const { entryId, status, created,
|
|
185
|
+
const { entryId, status, created, replacedEntry } = await ctx.runMutation(
|
|
186
186
|
this.component.entries.add,
|
|
187
187
|
{
|
|
188
188
|
entry: {
|
|
@@ -203,7 +203,7 @@ export class RAG<
|
|
|
203
203
|
entryId: entryId as EntryId,
|
|
204
204
|
status,
|
|
205
205
|
created,
|
|
206
|
-
|
|
206
|
+
replacedEntry: replacedEntry as Entry<
|
|
207
207
|
FitlerSchemas,
|
|
208
208
|
EntryMetadata
|
|
209
209
|
> | null,
|
|
@@ -243,7 +243,7 @@ export class RAG<
|
|
|
243
243
|
entryId: entryId as EntryId,
|
|
244
244
|
status: "replaced" as const,
|
|
245
245
|
created: false,
|
|
246
|
-
|
|
246
|
+
replacedEntry: null,
|
|
247
247
|
};
|
|
248
248
|
}
|
|
249
249
|
startOrder = nextStartOrder;
|
|
@@ -256,7 +256,7 @@ export class RAG<
|
|
|
256
256
|
return {
|
|
257
257
|
entryId: entryId as EntryId,
|
|
258
258
|
status: "ready" as const,
|
|
259
|
-
|
|
259
|
+
replacedEntry: promoted.replacedEntry as Entry<
|
|
260
260
|
FitlerSchemas,
|
|
261
261
|
EntryMetadata
|
|
262
262
|
> | null,
|
|
@@ -419,7 +419,7 @@ export class RAG<
|
|
|
419
419
|
return {
|
|
420
420
|
results: results as SearchResult[],
|
|
421
421
|
text: entriesWithTexts
|
|
422
|
-
.map((e) => (e.title ?
|
|
422
|
+
.map((e) => (e.title ? `## ${e.title}:\n${e.text}` : e.text))
|
|
423
423
|
.join(`\n---\n`),
|
|
424
424
|
entries: entriesWithTexts,
|
|
425
425
|
};
|
|
@@ -551,7 +551,7 @@ export class RAG<
|
|
|
551
551
|
async list(
|
|
552
552
|
ctx: RunQueryCtx,
|
|
553
553
|
args: {
|
|
554
|
-
namespaceId
|
|
554
|
+
namespaceId?: NamespaceId;
|
|
555
555
|
paginationOpts: PaginationOptions;
|
|
556
556
|
order?: "desc" | "asc";
|
|
557
557
|
status?: Status;
|
|
@@ -115,13 +115,14 @@ export type Mounts = {
|
|
|
115
115
|
{
|
|
116
116
|
created: boolean;
|
|
117
117
|
entryId: string;
|
|
118
|
-
|
|
118
|
+
replacedEntry: {
|
|
119
119
|
contentHash?: string;
|
|
120
120
|
entryId: string;
|
|
121
121
|
filterValues: Array<{ name: string; value: any }>;
|
|
122
122
|
importance: number;
|
|
123
123
|
key?: string;
|
|
124
124
|
metadata?: Record<string, any>;
|
|
125
|
+
replacedAt?: number;
|
|
125
126
|
status: "pending" | "ready" | "replaced";
|
|
126
127
|
title?: string;
|
|
127
128
|
} | null;
|
|
@@ -170,6 +171,7 @@ export type Mounts = {
|
|
|
170
171
|
importance: number;
|
|
171
172
|
key?: string;
|
|
172
173
|
metadata?: Record<string, any>;
|
|
174
|
+
replacedAt?: number;
|
|
173
175
|
status: "pending" | "ready" | "replaced";
|
|
174
176
|
title?: string;
|
|
175
177
|
} | null
|
|
@@ -185,6 +187,7 @@ export type Mounts = {
|
|
|
185
187
|
importance: number;
|
|
186
188
|
key?: string;
|
|
187
189
|
metadata?: Record<string, any>;
|
|
190
|
+
replacedAt?: number;
|
|
188
191
|
status: "pending" | "ready" | "replaced";
|
|
189
192
|
title?: string;
|
|
190
193
|
} | null
|
|
@@ -193,7 +196,7 @@ export type Mounts = {
|
|
|
193
196
|
"query",
|
|
194
197
|
"public",
|
|
195
198
|
{
|
|
196
|
-
namespaceId
|
|
199
|
+
namespaceId?: string;
|
|
197
200
|
order?: "desc" | "asc";
|
|
198
201
|
paginationOpts: {
|
|
199
202
|
cursor: string | null;
|
|
@@ -215,6 +218,7 @@ export type Mounts = {
|
|
|
215
218
|
importance: number;
|
|
216
219
|
key?: string;
|
|
217
220
|
metadata?: Record<string, any>;
|
|
221
|
+
replacedAt?: number;
|
|
218
222
|
status: "pending" | "ready" | "replaced";
|
|
219
223
|
title?: string;
|
|
220
224
|
}>;
|
|
@@ -227,13 +231,14 @@ export type Mounts = {
|
|
|
227
231
|
"public",
|
|
228
232
|
{ entryId: string },
|
|
229
233
|
{
|
|
230
|
-
|
|
234
|
+
replacedEntry: {
|
|
231
235
|
contentHash?: string;
|
|
232
236
|
entryId: string;
|
|
233
237
|
filterValues: Array<{ name: string; value: any }>;
|
|
234
238
|
importance: number;
|
|
235
239
|
key?: string;
|
|
236
240
|
metadata?: Record<string, any>;
|
|
241
|
+
replacedAt?: number;
|
|
237
242
|
status: "pending" | "ready" | "replaced";
|
|
238
243
|
title?: string;
|
|
239
244
|
} | null;
|
|
@@ -321,7 +326,7 @@ export type Mounts = {
|
|
|
321
326
|
"public",
|
|
322
327
|
{ namespaceId: string },
|
|
323
328
|
{
|
|
324
|
-
|
|
329
|
+
replacedNamespace: null | {
|
|
325
330
|
createdAt: number;
|
|
326
331
|
dimension: number;
|
|
327
332
|
filterNames: Array<string>;
|
|
@@ -355,6 +360,7 @@ export type Mounts = {
|
|
|
355
360
|
importance: number;
|
|
356
361
|
key?: string;
|
|
357
362
|
metadata?: Record<string, any>;
|
|
363
|
+
replacedAt?: number;
|
|
358
364
|
status: "pending" | "ready" | "replaced";
|
|
359
365
|
title?: string;
|
|
360
366
|
}>;
|
|
@@ -46,7 +46,7 @@ describe("entries", () => {
|
|
|
46
46
|
expect(result.created).toBe(true);
|
|
47
47
|
expect(result.status).toBe("ready");
|
|
48
48
|
expect(result.entryId).toBeDefined();
|
|
49
|
-
expect(result.
|
|
49
|
+
expect(result.replacedEntry).toBeNull();
|
|
50
50
|
|
|
51
51
|
// Verify the entry was actually created
|
|
52
52
|
const createdDoc = await t.run(async (ctx) => {
|
|
@@ -73,7 +73,7 @@ describe("entries", () => {
|
|
|
73
73
|
|
|
74
74
|
expect(firstResult.created).toBe(true);
|
|
75
75
|
expect(firstResult.status).toBe("ready");
|
|
76
|
-
expect(firstResult.
|
|
76
|
+
expect(firstResult.replacedEntry).toBeNull();
|
|
77
77
|
|
|
78
78
|
// Second add with identical content
|
|
79
79
|
const secondResult = await t.mutation(api.entries.add, {
|
|
@@ -84,7 +84,7 @@ describe("entries", () => {
|
|
|
84
84
|
expect(secondResult.created).toBe(false);
|
|
85
85
|
expect(secondResult.status).toBe("ready");
|
|
86
86
|
expect(secondResult.entryId).toBe(firstResult.entryId);
|
|
87
|
-
expect(secondResult.
|
|
87
|
+
expect(secondResult.replacedEntry).toBeNull();
|
|
88
88
|
|
|
89
89
|
// Verify no new entry was created
|
|
90
90
|
const allDocs = await t.run(async (ctx) => {
|
|
@@ -116,7 +116,7 @@ describe("entries", () => {
|
|
|
116
116
|
});
|
|
117
117
|
|
|
118
118
|
expect(firstResult.created).toBe(true);
|
|
119
|
-
expect(firstResult.
|
|
119
|
+
expect(firstResult.replacedEntry).toBeNull();
|
|
120
120
|
|
|
121
121
|
// Second add with different content hash
|
|
122
122
|
const modifiedEntry = {
|
|
@@ -131,9 +131,9 @@ describe("entries", () => {
|
|
|
131
131
|
|
|
132
132
|
expect(secondResult.created).toBe(true);
|
|
133
133
|
expect(secondResult.entryId).not.toBe(firstResult.entryId);
|
|
134
|
-
// When creating a entry as "ready" initially,
|
|
134
|
+
// When creating a entry as "ready" initially, replacedEntry is null
|
|
135
135
|
// Replacement only happens during pending -> ready transitions
|
|
136
|
-
expect(secondResult.
|
|
136
|
+
expect(secondResult.replacedEntry).toMatchObject({
|
|
137
137
|
entryId: firstResult.entryId,
|
|
138
138
|
});
|
|
139
139
|
|
|
@@ -181,7 +181,7 @@ describe("entries", () => {
|
|
|
181
181
|
|
|
182
182
|
expect(secondResult.created).toBe(true);
|
|
183
183
|
expect(secondResult.entryId).not.toBe(firstResult.entryId);
|
|
184
|
-
expect(secondResult.
|
|
184
|
+
expect(secondResult.replacedEntry).toMatchObject({
|
|
185
185
|
entryId: firstResult.entryId,
|
|
186
186
|
});
|
|
187
187
|
|
|
@@ -219,7 +219,7 @@ describe("entries", () => {
|
|
|
219
219
|
|
|
220
220
|
expect(secondResult.created).toBe(true);
|
|
221
221
|
expect(secondResult.entryId).not.toBe(firstResult.entryId);
|
|
222
|
-
expect(secondResult.
|
|
222
|
+
expect(secondResult.replacedEntry).toMatchObject({
|
|
223
223
|
entryId: firstResult.entryId,
|
|
224
224
|
});
|
|
225
225
|
|
|
@@ -247,7 +247,7 @@ describe("entries", () => {
|
|
|
247
247
|
|
|
248
248
|
expect(result.created).toBe(true);
|
|
249
249
|
expect(result.status).toBe("pending");
|
|
250
|
-
expect(result.
|
|
250
|
+
expect(result.replacedEntry).toBeNull();
|
|
251
251
|
|
|
252
252
|
// Verify the entry was created with pending status
|
|
253
253
|
const createdDoc = await t.run(async (ctx) => {
|
|
@@ -277,8 +277,8 @@ describe("entries", () => {
|
|
|
277
277
|
expect(result1.created).toBe(true);
|
|
278
278
|
expect(result2.created).toBe(true);
|
|
279
279
|
expect(result1.entryId).not.toBe(result2.entryId);
|
|
280
|
-
expect(result1.
|
|
281
|
-
expect(result2.
|
|
280
|
+
expect(result1.replacedEntry).toBeNull();
|
|
281
|
+
expect(result2.replacedEntry).toBeNull();
|
|
282
282
|
|
|
283
283
|
// Verify both entries exist
|
|
284
284
|
const allDocs = await t.run(async (ctx) => {
|
|
@@ -293,7 +293,7 @@ describe("entries", () => {
|
|
|
293
293
|
expect(keys).toEqual(["doc1", "doc2"]);
|
|
294
294
|
});
|
|
295
295
|
|
|
296
|
-
test("pending to ready transition populates
|
|
296
|
+
test("pending to ready transition populates replacedEntry", async () => {
|
|
297
297
|
const t = convexTest(schema, modules);
|
|
298
298
|
const namespaceId = await setupTestNamespace(t);
|
|
299
299
|
|
|
@@ -307,7 +307,7 @@ describe("entries", () => {
|
|
|
307
307
|
|
|
308
308
|
expect(firstResult.created).toBe(true);
|
|
309
309
|
expect(firstResult.status).toBe("ready");
|
|
310
|
-
expect(firstResult.
|
|
310
|
+
expect(firstResult.replacedEntry).toBeNull();
|
|
311
311
|
|
|
312
312
|
// Second add - create as pending (no allChunks)
|
|
313
313
|
const modifiedEntry = {
|
|
@@ -322,15 +322,15 @@ describe("entries", () => {
|
|
|
322
322
|
|
|
323
323
|
expect(pendingResult.created).toBe(true);
|
|
324
324
|
expect(pendingResult.status).toBe("pending");
|
|
325
|
-
expect(pendingResult.
|
|
325
|
+
expect(pendingResult.replacedEntry).toBeNull();
|
|
326
326
|
|
|
327
327
|
// Promote to ready - this should replace the first entry
|
|
328
328
|
const promoteResult = await t.mutation(api.entries.promoteToReady, {
|
|
329
329
|
entryId: pendingResult.entryId,
|
|
330
330
|
});
|
|
331
331
|
|
|
332
|
-
expect(promoteResult.
|
|
333
|
-
expect(promoteResult.
|
|
332
|
+
expect(promoteResult.replacedEntry).not.toBeNull();
|
|
333
|
+
expect(promoteResult.replacedEntry!.entryId).toBe(firstResult.entryId);
|
|
334
334
|
|
|
335
335
|
// Verify the first entry is now replaced
|
|
336
336
|
const firstDoc = await t.run(async (ctx) => {
|