@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
package/dist/shared.d.ts
ADDED
|
@@ -0,0 +1,479 @@
|
|
|
1
|
+
import type { Infer, Validator, Value, VObject } from "convex/values";
|
|
2
|
+
import { type NamedFilter } from "./component/filters.js";
|
|
3
|
+
import type { FunctionReference } from "convex/server";
|
|
4
|
+
export declare const CHUNK_BATCH_SIZE = 100;
|
|
5
|
+
export declare const vNamespaceId: import("convex/values").VString<string & {
|
|
6
|
+
_: "NamespaceId";
|
|
7
|
+
}, "required">;
|
|
8
|
+
export declare const vEntryId: import("convex/values").VString<string & {
|
|
9
|
+
_: "EntryId";
|
|
10
|
+
}, "required">;
|
|
11
|
+
export type NamespaceId = Infer<typeof vNamespaceId>;
|
|
12
|
+
export type EntryId = Infer<typeof vEntryId>;
|
|
13
|
+
export declare const vSearchResult: VObject<{
|
|
14
|
+
entryId: string & {
|
|
15
|
+
_: "EntryId";
|
|
16
|
+
};
|
|
17
|
+
order: number;
|
|
18
|
+
content: {
|
|
19
|
+
metadata?: Record<string, any> | undefined;
|
|
20
|
+
text: string;
|
|
21
|
+
}[];
|
|
22
|
+
startOrder: number;
|
|
23
|
+
score: number;
|
|
24
|
+
}, {
|
|
25
|
+
entryId: import("convex/values").VString<string & {
|
|
26
|
+
_: "EntryId";
|
|
27
|
+
}, "required">;
|
|
28
|
+
order: import("convex/values").VFloat64<number, "required">;
|
|
29
|
+
content: import("convex/values").VArray<{
|
|
30
|
+
metadata?: Record<string, any> | undefined;
|
|
31
|
+
text: string;
|
|
32
|
+
}[], VObject<{
|
|
33
|
+
metadata?: Record<string, any> | undefined;
|
|
34
|
+
text: string;
|
|
35
|
+
}, {
|
|
36
|
+
text: import("convex/values").VString<string, "required">;
|
|
37
|
+
metadata: import("convex/values").VRecord<Record<string, any> | undefined, import("convex/values").VString<string, "required">, import("convex/values").VAny<any, "required", string>, "optional", string>;
|
|
38
|
+
}, "required", "text" | "metadata" | `metadata.${string}`>, "required">;
|
|
39
|
+
startOrder: import("convex/values").VFloat64<number, "required">;
|
|
40
|
+
score: import("convex/values").VFloat64<number, "required">;
|
|
41
|
+
}, "required", "entryId" | "order" | "content" | "startOrder" | "score">;
|
|
42
|
+
export type SearchResult = Infer<typeof vSearchResult>;
|
|
43
|
+
export declare const vStatus: 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>;
|
|
44
|
+
export declare const vActiveStatus: import("convex/values").VUnion<"pending" | "ready", [import("convex/values").VLiteral<"pending", "required">, import("convex/values").VLiteral<"ready", "required">], "required", never>;
|
|
45
|
+
export type Status = Infer<typeof vStatus>;
|
|
46
|
+
export declare const statuses: ("pending" | "ready" | "replaced")[];
|
|
47
|
+
export declare const vNamespace: VObject<{
|
|
48
|
+
namespaceId: string & {
|
|
49
|
+
_: "NamespaceId";
|
|
50
|
+
};
|
|
51
|
+
createdAt: number;
|
|
52
|
+
namespace: string;
|
|
53
|
+
status: "pending" | "ready" | "replaced";
|
|
54
|
+
filterNames: string[];
|
|
55
|
+
dimension: number;
|
|
56
|
+
modelId: string;
|
|
57
|
+
version: number;
|
|
58
|
+
}, {
|
|
59
|
+
namespaceId: import("convex/values").VString<string & {
|
|
60
|
+
_: "NamespaceId";
|
|
61
|
+
}, "required">;
|
|
62
|
+
createdAt: import("convex/values").VFloat64<number, "required">;
|
|
63
|
+
namespace: import("convex/values").VString<string, "required">;
|
|
64
|
+
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>;
|
|
65
|
+
filterNames: import("convex/values").VArray<string[], import("convex/values").VString<string, "required">, "required">;
|
|
66
|
+
dimension: import("convex/values").VFloat64<number, "required">;
|
|
67
|
+
modelId: import("convex/values").VString<string, "required">;
|
|
68
|
+
version: import("convex/values").VFloat64<number, "required">;
|
|
69
|
+
}, "required", "namespaceId" | "createdAt" | "namespace" | "status" | "filterNames" | "dimension" | "modelId" | "version">;
|
|
70
|
+
export type Namespace = Infer<typeof vNamespace>;
|
|
71
|
+
export declare const vEntry: VObject<{
|
|
72
|
+
metadata?: Record<string, any> | undefined;
|
|
73
|
+
key?: string | undefined;
|
|
74
|
+
title?: string | undefined;
|
|
75
|
+
contentHash?: string | undefined;
|
|
76
|
+
entryId: string & {
|
|
77
|
+
_: "EntryId";
|
|
78
|
+
};
|
|
79
|
+
status: "pending" | "ready" | "replaced";
|
|
80
|
+
importance: number;
|
|
81
|
+
filterValues: {
|
|
82
|
+
name: string;
|
|
83
|
+
value: any;
|
|
84
|
+
}[];
|
|
85
|
+
}, {
|
|
86
|
+
key: import("convex/values").VString<string | undefined, "optional">;
|
|
87
|
+
title: import("convex/values").VString<string | undefined, "optional">;
|
|
88
|
+
metadata: import("convex/values").VRecord<Record<string, any> | undefined, import("convex/values").VString<string, "required">, import("convex/values").VAny<any, "required", string>, "optional", string>;
|
|
89
|
+
entryId: import("convex/values").VString<string & {
|
|
90
|
+
_: "EntryId";
|
|
91
|
+
}, "required">;
|
|
92
|
+
importance: import("convex/values").VFloat64<number, "required">;
|
|
93
|
+
filterValues: import("convex/values").VArray<{
|
|
94
|
+
name: string;
|
|
95
|
+
value: any;
|
|
96
|
+
}[], VObject<{
|
|
97
|
+
name: string;
|
|
98
|
+
value: any;
|
|
99
|
+
}, {
|
|
100
|
+
name: import("convex/values").VString<string, "required">;
|
|
101
|
+
value: import("convex/values").VAny<any, "required", string>;
|
|
102
|
+
}, "required", "name" | "value" | `value.${string}`>, "required">;
|
|
103
|
+
contentHash: import("convex/values").VString<string | undefined, "optional">;
|
|
104
|
+
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
|
+
}, "required", "entryId" | "metadata" | `metadata.${string}` | "status" | "key" | "title" | "importance" | "filterValues" | "contentHash">;
|
|
106
|
+
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
|
+
export declare const vSearchEntry: VObject<{
|
|
108
|
+
metadata?: Record<string, any> | undefined;
|
|
109
|
+
key?: string | undefined;
|
|
110
|
+
title?: string | undefined;
|
|
111
|
+
contentHash?: string | undefined;
|
|
112
|
+
entryId: string & {
|
|
113
|
+
_: "EntryId";
|
|
114
|
+
};
|
|
115
|
+
text: string;
|
|
116
|
+
status: "pending" | "ready" | "replaced";
|
|
117
|
+
importance: number;
|
|
118
|
+
filterValues: {
|
|
119
|
+
name: string;
|
|
120
|
+
value: any;
|
|
121
|
+
}[];
|
|
122
|
+
}, {
|
|
123
|
+
text: import("convex/values").VString<string, "required">;
|
|
124
|
+
key: import("convex/values").VString<string | undefined, "optional">;
|
|
125
|
+
title: import("convex/values").VString<string | undefined, "optional">;
|
|
126
|
+
metadata: import("convex/values").VRecord<Record<string, any> | undefined, import("convex/values").VString<string, "required">, import("convex/values").VAny<any, "required", string>, "optional", string>;
|
|
127
|
+
entryId: import("convex/values").VString<string & {
|
|
128
|
+
_: "EntryId";
|
|
129
|
+
}, "required">;
|
|
130
|
+
importance: import("convex/values").VFloat64<number, "required">;
|
|
131
|
+
filterValues: import("convex/values").VArray<{
|
|
132
|
+
name: string;
|
|
133
|
+
value: any;
|
|
134
|
+
}[], VObject<{
|
|
135
|
+
name: string;
|
|
136
|
+
value: any;
|
|
137
|
+
}, {
|
|
138
|
+
name: import("convex/values").VString<string, "required">;
|
|
139
|
+
value: import("convex/values").VAny<any, "required", string>;
|
|
140
|
+
}, "required", "name" | "value" | `value.${string}`>, "required">;
|
|
141
|
+
contentHash: import("convex/values").VString<string | undefined, "optional">;
|
|
142
|
+
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
|
+
}, "required", "entryId" | "text" | "metadata" | `metadata.${string}` | "status" | "key" | "title" | "importance" | "filterValues" | "contentHash">;
|
|
144
|
+
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
|
+
export type SearchEntry<Filters extends Record<string, Value>, Metadata extends Record<string, Value>> = Entry<Filters, Metadata> & {
|
|
146
|
+
text: string;
|
|
147
|
+
};
|
|
148
|
+
export type EntryFilterValues<Filters extends Record<string, Value> = Record<string, Value>> = {
|
|
149
|
+
[K in keyof Filters & string]: NamedFilter<K, Filters[K]>;
|
|
150
|
+
}[keyof Filters & string];
|
|
151
|
+
export type Entry<Filters extends Record<string, Value> = any, Metadata extends Record<string, Value> = any> = {
|
|
152
|
+
/** The entry's id, uniquely identifying the key + contents + namespace etc. */
|
|
153
|
+
entryId: EntryId;
|
|
154
|
+
/** User-defined key. You can re-use a key to replace it with new contents. */
|
|
155
|
+
key?: string | undefined;
|
|
156
|
+
/** User-defined title. */
|
|
157
|
+
title?: string | undefined;
|
|
158
|
+
/** User-defined metadata. */
|
|
159
|
+
metadata?: Metadata | undefined;
|
|
160
|
+
/** How important this entry is. Defaults to 1.
|
|
161
|
+
* Think of it as multiplying by the vector search score.
|
|
162
|
+
*/
|
|
163
|
+
importance: number;
|
|
164
|
+
/** Filters that can be used to search for this entry.
|
|
165
|
+
* Up to 4 filters are supported, of any type.
|
|
166
|
+
*/
|
|
167
|
+
filterValues: EntryFilterValues<Filters>[];
|
|
168
|
+
/** Hash of the entry contents.
|
|
169
|
+
* If supplied, it will avoid adding if the hash is the same.
|
|
170
|
+
*/
|
|
171
|
+
contentHash?: string | undefined;
|
|
172
|
+
/** Whether this entry's contents have all been inserted and indexed. */
|
|
173
|
+
status: Status;
|
|
174
|
+
};
|
|
175
|
+
export declare const vChunk: VObject<{
|
|
176
|
+
metadata?: Record<string, any> | undefined;
|
|
177
|
+
order: number;
|
|
178
|
+
text: string;
|
|
179
|
+
state: "pending" | "ready" | "replaced";
|
|
180
|
+
}, {
|
|
181
|
+
order: import("convex/values").VFloat64<number, "required">;
|
|
182
|
+
state: 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>;
|
|
183
|
+
text: import("convex/values").VString<string, "required">;
|
|
184
|
+
metadata: import("convex/values").VRecord<Record<string, any> | undefined, import("convex/values").VString<string, "required">, import("convex/values").VAny<any, "required", string>, "optional", string>;
|
|
185
|
+
}, "required", "order" | "text" | "metadata" | `metadata.${string}` | "state">;
|
|
186
|
+
export type Chunk = Infer<typeof vChunk>;
|
|
187
|
+
export declare const vCreateChunkArgs: VObject<{
|
|
188
|
+
searchableText?: string | undefined;
|
|
189
|
+
content: {
|
|
190
|
+
metadata?: Record<string, any> | undefined;
|
|
191
|
+
text: string;
|
|
192
|
+
};
|
|
193
|
+
embedding: number[];
|
|
194
|
+
}, {
|
|
195
|
+
content: VObject<{
|
|
196
|
+
metadata?: Record<string, any> | undefined;
|
|
197
|
+
text: string;
|
|
198
|
+
}, {
|
|
199
|
+
text: import("convex/values").VString<string, "required">;
|
|
200
|
+
metadata: import("convex/values").VRecord<Record<string, any> | undefined, import("convex/values").VString<string, "required">, import("convex/values").VAny<any, "required", string>, "optional", string>;
|
|
201
|
+
}, "required", "text" | "metadata" | `metadata.${string}`>;
|
|
202
|
+
embedding: import("convex/values").VArray<number[], import("convex/values").VFloat64<number, "required">, "required">;
|
|
203
|
+
searchableText: import("convex/values").VString<string | undefined, "optional">;
|
|
204
|
+
}, "required", "content" | "embedding" | "searchableText" | "content.text" | "content.metadata" | `content.metadata.${string}`>;
|
|
205
|
+
export type CreateChunkArgs = Infer<typeof vCreateChunkArgs>;
|
|
206
|
+
export declare function vPaginationResult<T extends Validator<Value, "required", string>>(itemValidator: T): VObject<{
|
|
207
|
+
splitCursor?: string | null | undefined;
|
|
208
|
+
pageStatus?: "SplitRecommended" | "SplitRequired" | null | undefined;
|
|
209
|
+
page: T["type"][];
|
|
210
|
+
continueCursor: string;
|
|
211
|
+
isDone: boolean;
|
|
212
|
+
}, {
|
|
213
|
+
page: import("convex/values").VArray<T["type"][], T, "required">;
|
|
214
|
+
continueCursor: import("convex/values").VString<string, "required">;
|
|
215
|
+
isDone: import("convex/values").VBoolean<boolean, "required">;
|
|
216
|
+
splitCursor: import("convex/values").VUnion<string | null | undefined, [import("convex/values").VString<string, "required">, import("convex/values").VNull<null, "required">], "optional", never>;
|
|
217
|
+
pageStatus: import("convex/values").VUnion<"SplitRecommended" | "SplitRequired" | null | undefined, [import("convex/values").VLiteral<"SplitRecommended", "required">, import("convex/values").VLiteral<"SplitRequired", "required">, import("convex/values").VNull<null, "required">], "optional", never>;
|
|
218
|
+
}, "required", "page" | "continueCursor" | "isDone" | "splitCursor" | "pageStatus">;
|
|
219
|
+
export type OnCompleteNamespace = FunctionReference<"mutation", "internal", {
|
|
220
|
+
namespace: Namespace;
|
|
221
|
+
replacedNamespace: Namespace | null;
|
|
222
|
+
}, null, string>;
|
|
223
|
+
export declare const vOnCompleteArgs: VObject<{
|
|
224
|
+
replacedEntry?: {
|
|
225
|
+
metadata?: Record<string, any> | undefined;
|
|
226
|
+
key?: string | undefined;
|
|
227
|
+
title?: string | undefined;
|
|
228
|
+
contentHash?: string | undefined;
|
|
229
|
+
entryId: string & {
|
|
230
|
+
_: "EntryId";
|
|
231
|
+
};
|
|
232
|
+
status: "pending" | "ready" | "replaced";
|
|
233
|
+
importance: number;
|
|
234
|
+
filterValues: {
|
|
235
|
+
name: string;
|
|
236
|
+
value: any;
|
|
237
|
+
}[];
|
|
238
|
+
} | undefined;
|
|
239
|
+
error?: string | undefined;
|
|
240
|
+
namespace: {
|
|
241
|
+
namespaceId: string & {
|
|
242
|
+
_: "NamespaceId";
|
|
243
|
+
};
|
|
244
|
+
createdAt: number;
|
|
245
|
+
namespace: string;
|
|
246
|
+
status: "pending" | "ready" | "replaced";
|
|
247
|
+
filterNames: string[];
|
|
248
|
+
dimension: number;
|
|
249
|
+
modelId: string;
|
|
250
|
+
version: number;
|
|
251
|
+
};
|
|
252
|
+
entry: {
|
|
253
|
+
metadata?: Record<string, any> | undefined;
|
|
254
|
+
key?: string | undefined;
|
|
255
|
+
title?: string | undefined;
|
|
256
|
+
contentHash?: string | undefined;
|
|
257
|
+
entryId: string & {
|
|
258
|
+
_: "EntryId";
|
|
259
|
+
};
|
|
260
|
+
status: "pending" | "ready" | "replaced";
|
|
261
|
+
importance: number;
|
|
262
|
+
filterValues: {
|
|
263
|
+
name: string;
|
|
264
|
+
value: any;
|
|
265
|
+
}[];
|
|
266
|
+
};
|
|
267
|
+
}, {
|
|
268
|
+
namespace: VObject<{
|
|
269
|
+
namespaceId: string & {
|
|
270
|
+
_: "NamespaceId";
|
|
271
|
+
};
|
|
272
|
+
createdAt: number;
|
|
273
|
+
namespace: string;
|
|
274
|
+
status: "pending" | "ready" | "replaced";
|
|
275
|
+
filterNames: string[];
|
|
276
|
+
dimension: number;
|
|
277
|
+
modelId: string;
|
|
278
|
+
version: number;
|
|
279
|
+
}, {
|
|
280
|
+
namespaceId: import("convex/values").VString<string & {
|
|
281
|
+
_: "NamespaceId";
|
|
282
|
+
}, "required">;
|
|
283
|
+
createdAt: import("convex/values").VFloat64<number, "required">;
|
|
284
|
+
namespace: import("convex/values").VString<string, "required">;
|
|
285
|
+
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>;
|
|
286
|
+
filterNames: import("convex/values").VArray<string[], import("convex/values").VString<string, "required">, "required">;
|
|
287
|
+
dimension: import("convex/values").VFloat64<number, "required">;
|
|
288
|
+
modelId: import("convex/values").VString<string, "required">;
|
|
289
|
+
version: import("convex/values").VFloat64<number, "required">;
|
|
290
|
+
}, "required", "namespaceId" | "createdAt" | "namespace" | "status" | "filterNames" | "dimension" | "modelId" | "version">;
|
|
291
|
+
entry: VObject<{
|
|
292
|
+
metadata?: Record<string, any> | undefined;
|
|
293
|
+
key?: string | undefined;
|
|
294
|
+
title?: string | undefined;
|
|
295
|
+
contentHash?: string | undefined;
|
|
296
|
+
entryId: string & {
|
|
297
|
+
_: "EntryId";
|
|
298
|
+
};
|
|
299
|
+
status: "pending" | "ready" | "replaced";
|
|
300
|
+
importance: number;
|
|
301
|
+
filterValues: {
|
|
302
|
+
name: string;
|
|
303
|
+
value: any;
|
|
304
|
+
}[];
|
|
305
|
+
}, {
|
|
306
|
+
key: import("convex/values").VString<string | undefined, "optional">;
|
|
307
|
+
title: import("convex/values").VString<string | undefined, "optional">;
|
|
308
|
+
metadata: import("convex/values").VRecord<Record<string, any> | undefined, import("convex/values").VString<string, "required">, import("convex/values").VAny<any, "required", string>, "optional", string>;
|
|
309
|
+
entryId: import("convex/values").VString<string & {
|
|
310
|
+
_: "EntryId";
|
|
311
|
+
}, "required">;
|
|
312
|
+
importance: import("convex/values").VFloat64<number, "required">;
|
|
313
|
+
filterValues: import("convex/values").VArray<{
|
|
314
|
+
name: string;
|
|
315
|
+
value: any;
|
|
316
|
+
}[], VObject<{
|
|
317
|
+
name: string;
|
|
318
|
+
value: any;
|
|
319
|
+
}, {
|
|
320
|
+
name: import("convex/values").VString<string, "required">;
|
|
321
|
+
value: import("convex/values").VAny<any, "required", string>;
|
|
322
|
+
}, "required", "name" | "value" | `value.${string}`>, "required">;
|
|
323
|
+
contentHash: import("convex/values").VString<string | undefined, "optional">;
|
|
324
|
+
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
|
+
}, "required", "entryId" | "metadata" | `metadata.${string}` | "status" | "key" | "title" | "importance" | "filterValues" | "contentHash">;
|
|
326
|
+
replacedEntry: VObject<{
|
|
327
|
+
metadata?: Record<string, any> | undefined;
|
|
328
|
+
key?: string | undefined;
|
|
329
|
+
title?: string | undefined;
|
|
330
|
+
contentHash?: string | undefined;
|
|
331
|
+
entryId: string & {
|
|
332
|
+
_: "EntryId";
|
|
333
|
+
};
|
|
334
|
+
status: "pending" | "ready" | "replaced";
|
|
335
|
+
importance: number;
|
|
336
|
+
filterValues: {
|
|
337
|
+
name: string;
|
|
338
|
+
value: any;
|
|
339
|
+
}[];
|
|
340
|
+
} | undefined, {
|
|
341
|
+
key: import("convex/values").VString<string | undefined, "optional">;
|
|
342
|
+
title: import("convex/values").VString<string | undefined, "optional">;
|
|
343
|
+
metadata: import("convex/values").VRecord<Record<string, any> | undefined, import("convex/values").VString<string, "required">, import("convex/values").VAny<any, "required", string>, "optional", string>;
|
|
344
|
+
entryId: import("convex/values").VString<string & {
|
|
345
|
+
_: "EntryId";
|
|
346
|
+
}, "required">;
|
|
347
|
+
importance: import("convex/values").VFloat64<number, "required">;
|
|
348
|
+
filterValues: import("convex/values").VArray<{
|
|
349
|
+
name: string;
|
|
350
|
+
value: any;
|
|
351
|
+
}[], VObject<{
|
|
352
|
+
name: string;
|
|
353
|
+
value: any;
|
|
354
|
+
}, {
|
|
355
|
+
name: import("convex/values").VString<string, "required">;
|
|
356
|
+
value: import("convex/values").VAny<any, "required", string>;
|
|
357
|
+
}, "required", "name" | "value" | `value.${string}`>, "required">;
|
|
358
|
+
contentHash: import("convex/values").VString<string | undefined, "optional">;
|
|
359
|
+
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
|
+
}, "optional", "entryId" | "metadata" | `metadata.${string}` | "status" | "key" | "title" | "importance" | "filterValues" | "contentHash">;
|
|
361
|
+
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">;
|
|
363
|
+
export type OnComplete<Filters extends Record<string, Value> = any, EntryMetadata extends Record<string, Value> = any> = FunctionReference<"mutation", "internal", {
|
|
364
|
+
/**
|
|
365
|
+
* The namespace that the entry belongs to.
|
|
366
|
+
*/
|
|
367
|
+
namespace: Namespace;
|
|
368
|
+
/**
|
|
369
|
+
* The entry that was added.
|
|
370
|
+
*/
|
|
371
|
+
entry: Entry<Filters, EntryMetadata>;
|
|
372
|
+
/**
|
|
373
|
+
* The previous "ready" entry with the same key that was replaced.
|
|
374
|
+
*/
|
|
375
|
+
replacedEntry: Entry<Filters, EntryMetadata> | undefined;
|
|
376
|
+
/**
|
|
377
|
+
* If async generation failed, this is the error.
|
|
378
|
+
*/
|
|
379
|
+
error: string | undefined;
|
|
380
|
+
}, null>;
|
|
381
|
+
export declare const vChunkerArgs: VObject<{
|
|
382
|
+
namespace: {
|
|
383
|
+
namespaceId: string & {
|
|
384
|
+
_: "NamespaceId";
|
|
385
|
+
};
|
|
386
|
+
createdAt: number;
|
|
387
|
+
namespace: string;
|
|
388
|
+
status: "pending" | "ready" | "replaced";
|
|
389
|
+
filterNames: string[];
|
|
390
|
+
dimension: number;
|
|
391
|
+
modelId: string;
|
|
392
|
+
version: number;
|
|
393
|
+
};
|
|
394
|
+
entry: {
|
|
395
|
+
metadata?: Record<string, any> | undefined;
|
|
396
|
+
key?: string | undefined;
|
|
397
|
+
title?: string | undefined;
|
|
398
|
+
contentHash?: string | undefined;
|
|
399
|
+
entryId: string & {
|
|
400
|
+
_: "EntryId";
|
|
401
|
+
};
|
|
402
|
+
status: "pending" | "ready" | "replaced";
|
|
403
|
+
importance: number;
|
|
404
|
+
filterValues: {
|
|
405
|
+
name: string;
|
|
406
|
+
value: any;
|
|
407
|
+
}[];
|
|
408
|
+
};
|
|
409
|
+
insertChunks: string;
|
|
410
|
+
}, {
|
|
411
|
+
namespace: VObject<{
|
|
412
|
+
namespaceId: string & {
|
|
413
|
+
_: "NamespaceId";
|
|
414
|
+
};
|
|
415
|
+
createdAt: number;
|
|
416
|
+
namespace: string;
|
|
417
|
+
status: "pending" | "ready" | "replaced";
|
|
418
|
+
filterNames: string[];
|
|
419
|
+
dimension: number;
|
|
420
|
+
modelId: string;
|
|
421
|
+
version: number;
|
|
422
|
+
}, {
|
|
423
|
+
namespaceId: import("convex/values").VString<string & {
|
|
424
|
+
_: "NamespaceId";
|
|
425
|
+
}, "required">;
|
|
426
|
+
createdAt: import("convex/values").VFloat64<number, "required">;
|
|
427
|
+
namespace: import("convex/values").VString<string, "required">;
|
|
428
|
+
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>;
|
|
429
|
+
filterNames: import("convex/values").VArray<string[], import("convex/values").VString<string, "required">, "required">;
|
|
430
|
+
dimension: import("convex/values").VFloat64<number, "required">;
|
|
431
|
+
modelId: import("convex/values").VString<string, "required">;
|
|
432
|
+
version: import("convex/values").VFloat64<number, "required">;
|
|
433
|
+
}, "required", "namespaceId" | "createdAt" | "namespace" | "status" | "filterNames" | "dimension" | "modelId" | "version">;
|
|
434
|
+
entry: VObject<{
|
|
435
|
+
metadata?: Record<string, any> | undefined;
|
|
436
|
+
key?: string | undefined;
|
|
437
|
+
title?: string | undefined;
|
|
438
|
+
contentHash?: string | undefined;
|
|
439
|
+
entryId: string & {
|
|
440
|
+
_: "EntryId";
|
|
441
|
+
};
|
|
442
|
+
status: "pending" | "ready" | "replaced";
|
|
443
|
+
importance: number;
|
|
444
|
+
filterValues: {
|
|
445
|
+
name: string;
|
|
446
|
+
value: any;
|
|
447
|
+
}[];
|
|
448
|
+
}, {
|
|
449
|
+
key: import("convex/values").VString<string | undefined, "optional">;
|
|
450
|
+
title: import("convex/values").VString<string | undefined, "optional">;
|
|
451
|
+
metadata: import("convex/values").VRecord<Record<string, any> | undefined, import("convex/values").VString<string, "required">, import("convex/values").VAny<any, "required", string>, "optional", string>;
|
|
452
|
+
entryId: import("convex/values").VString<string & {
|
|
453
|
+
_: "EntryId";
|
|
454
|
+
}, "required">;
|
|
455
|
+
importance: import("convex/values").VFloat64<number, "required">;
|
|
456
|
+
filterValues: import("convex/values").VArray<{
|
|
457
|
+
name: string;
|
|
458
|
+
value: any;
|
|
459
|
+
}[], VObject<{
|
|
460
|
+
name: string;
|
|
461
|
+
value: any;
|
|
462
|
+
}, {
|
|
463
|
+
name: import("convex/values").VString<string, "required">;
|
|
464
|
+
value: import("convex/values").VAny<any, "required", string>;
|
|
465
|
+
}, "required", "name" | "value" | `value.${string}`>, "required">;
|
|
466
|
+
contentHash: import("convex/values").VString<string | undefined, "optional">;
|
|
467
|
+
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
|
+
}, "required", "entryId" | "metadata" | `metadata.${string}` | "status" | "key" | "title" | "importance" | "filterValues" | "contentHash">;
|
|
469
|
+
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">;
|
|
471
|
+
export type ChunkerAction = FunctionReference<"action", "internal", Infer<typeof vChunkerArgs>, null>;
|
|
472
|
+
/**
|
|
473
|
+
* Check if the args filter names are compatible with the existing filter names.
|
|
474
|
+
* @param existing The existing filter names.
|
|
475
|
+
* @param args The filter names to check. Can be a prefix
|
|
476
|
+
* @returns True if the filter names are the same, in the same order.
|
|
477
|
+
*/
|
|
478
|
+
export declare function filterNamesContain(existing: string[], args: string[]): boolean;
|
|
479
|
+
//# sourceMappingURL=shared.d.ts.map
|
|
@@ -0,0 +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,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AAa,CAAC,GAAG,SAAS,CAAC;IACzD;;OAEG;IACH,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;CAC3B,EACD,IAAI,CACL,CAAC;AAEF,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;saAIvB,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
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { v } from "convex/values";
|
|
2
|
+
import { vNamedFilter } from "./component/filters.js";
|
|
3
|
+
import { brandedString } from "convex-helpers/validators";
|
|
4
|
+
// A good middle-ground that has up to ~3MB if embeddings are 4096 (max).
|
|
5
|
+
// Also a reasonable number of writes to the DB.
|
|
6
|
+
export const CHUNK_BATCH_SIZE = 100;
|
|
7
|
+
// Branded types for IDs, as components don't expose the internal ID types.
|
|
8
|
+
export const vNamespaceId = brandedString("NamespaceId");
|
|
9
|
+
export const vEntryId = brandedString("EntryId");
|
|
10
|
+
export const vSearchResult = v.object({
|
|
11
|
+
entryId: vEntryId,
|
|
12
|
+
order: v.number(),
|
|
13
|
+
content: v.array(v.object({
|
|
14
|
+
text: v.string(),
|
|
15
|
+
metadata: v.optional(v.record(v.string(), v.any())),
|
|
16
|
+
})),
|
|
17
|
+
startOrder: v.number(),
|
|
18
|
+
score: v.number(),
|
|
19
|
+
});
|
|
20
|
+
export const vStatus = v.union(v.literal("pending"), v.literal("ready"), v.literal("replaced"));
|
|
21
|
+
export const vActiveStatus = v.union(v.literal("pending"), v.literal("ready"));
|
|
22
|
+
export const statuses = vStatus.members.map((s) => s.value);
|
|
23
|
+
export const vNamespace = v.object({
|
|
24
|
+
namespaceId: vNamespaceId,
|
|
25
|
+
createdAt: v.number(),
|
|
26
|
+
namespace: v.string(),
|
|
27
|
+
status: vStatus,
|
|
28
|
+
filterNames: v.array(v.string()),
|
|
29
|
+
dimension: v.number(),
|
|
30
|
+
modelId: v.string(),
|
|
31
|
+
version: v.number(),
|
|
32
|
+
});
|
|
33
|
+
export const vEntry = v.object({
|
|
34
|
+
key: v.optional(v.string()),
|
|
35
|
+
title: v.optional(v.string()),
|
|
36
|
+
metadata: v.optional(v.record(v.string(), v.any())),
|
|
37
|
+
entryId: vEntryId,
|
|
38
|
+
importance: v.number(),
|
|
39
|
+
filterValues: v.array(vNamedFilter),
|
|
40
|
+
contentHash: v.optional(v.string()),
|
|
41
|
+
status: vStatus,
|
|
42
|
+
});
|
|
43
|
+
// Type assertion to keep us honest
|
|
44
|
+
const _1 = {};
|
|
45
|
+
const _2 = {};
|
|
46
|
+
export const vSearchEntry = v.object({
|
|
47
|
+
...vEntry.fields,
|
|
48
|
+
text: v.string(),
|
|
49
|
+
});
|
|
50
|
+
export const vChunk = v.object({
|
|
51
|
+
order: v.number(),
|
|
52
|
+
state: vStatus,
|
|
53
|
+
text: v.string(),
|
|
54
|
+
metadata: v.optional(v.record(v.string(), v.any())),
|
|
55
|
+
});
|
|
56
|
+
export const vCreateChunkArgs = v.object({
|
|
57
|
+
content: v.object({
|
|
58
|
+
text: v.string(),
|
|
59
|
+
metadata: v.optional(v.record(v.string(), v.any())),
|
|
60
|
+
}),
|
|
61
|
+
embedding: v.array(v.number()),
|
|
62
|
+
searchableText: v.optional(v.string()),
|
|
63
|
+
});
|
|
64
|
+
export function vPaginationResult(itemValidator) {
|
|
65
|
+
return v.object({
|
|
66
|
+
page: v.array(itemValidator),
|
|
67
|
+
continueCursor: v.string(),
|
|
68
|
+
isDone: v.boolean(),
|
|
69
|
+
splitCursor: v.optional(v.union(v.string(), v.null())),
|
|
70
|
+
pageStatus: v.optional(v.union(v.literal("SplitRecommended"), v.literal("SplitRequired"), v.null())),
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
export const vOnCompleteArgs = v.object({
|
|
74
|
+
namespace: vNamespace,
|
|
75
|
+
entry: vEntry,
|
|
76
|
+
replacedEntry: v.optional(vEntry),
|
|
77
|
+
error: v.optional(v.string()),
|
|
78
|
+
});
|
|
79
|
+
export const vChunkerArgs = v.object({
|
|
80
|
+
namespace: vNamespace,
|
|
81
|
+
entry: vEntry,
|
|
82
|
+
insertChunks: v.string(),
|
|
83
|
+
});
|
|
84
|
+
/**
|
|
85
|
+
* Check if the args filter names are compatible with the existing filter names.
|
|
86
|
+
* @param existing The existing filter names.
|
|
87
|
+
* @param args The filter names to check. Can be a prefix
|
|
88
|
+
* @returns True if the filter names are the same, in the same order.
|
|
89
|
+
*/
|
|
90
|
+
export function filterNamesContain(existing, args) {
|
|
91
|
+
for (const name of args) {
|
|
92
|
+
if (!existing.includes(name)) {
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return true;
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=shared.js.map
|
|
@@ -0,0 +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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