@mastra/rag 0.1.0-alpha.80 → 0.1.0-alpha.83
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/CHANGELOG.md +28 -0
- package/dist/index.d.ts +117 -245
- package/dist/index.js +934 -186
- package/package.json +2 -2
- package/src/{utils/graph-rag → graph-rag}/index.test.ts +9 -5
- package/src/{utils/graph-rag → graph-rag}/index.ts +11 -1
- package/src/index.ts +5 -1
- package/src/tools/document-chunker.ts +30 -0
- package/src/tools/graph-rag.ts +117 -0
- package/src/tools/index.ts +3 -0
- package/src/tools/vector-query.ts +89 -0
- package/src/utils/default-settings.ts +33 -0
- package/src/utils/index.ts +2 -3
- package/src/utils/vector-prompts.ts +729 -0
- package/src/utils/vector-search.ts +36 -0
- package/src/utils/rag-tools.ts +0 -268
- /package/src/{utils/rerank → rerank}/index.test.ts +0 -0
- /package/src/{utils/rerank → rerank}/index.ts +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# @mastra/rag
|
|
2
2
|
|
|
3
|
+
## 0.1.0-alpha.83
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- a10b7a3: Implemented new filtering for vectorQueryTool and updated docs
|
|
8
|
+
- Updated dependencies [d7d465a]
|
|
9
|
+
- Updated dependencies [d7d465a]
|
|
10
|
+
- Updated dependencies [2017553]
|
|
11
|
+
- Updated dependencies [a10b7a3]
|
|
12
|
+
- Updated dependencies [16e5b04]
|
|
13
|
+
- @mastra/core@0.2.0-alpha.91
|
|
14
|
+
|
|
15
|
+
## 0.1.0-alpha.82
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- Updated dependencies [8151f44]
|
|
20
|
+
- Updated dependencies [e897f1c]
|
|
21
|
+
- Updated dependencies [3700be1]
|
|
22
|
+
- @mastra/core@0.2.0-alpha.90
|
|
23
|
+
|
|
24
|
+
## 0.1.0-alpha.81
|
|
25
|
+
|
|
26
|
+
### Patch Changes
|
|
27
|
+
|
|
28
|
+
- Updated dependencies [27275c9]
|
|
29
|
+
- @mastra/core@0.2.0-alpha.89
|
|
30
|
+
|
|
3
31
|
## 0.1.0-alpha.80
|
|
4
32
|
|
|
5
33
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -2,10 +2,10 @@ import { LLM, TitleExtractorPrompt, TitleCombinePrompt, SummaryPrompt, QuestionE
|
|
|
2
2
|
import { TiktokenEncoding, TiktokenModel } from 'js-tiktoken';
|
|
3
3
|
import * as _mastra_core from '@mastra/core';
|
|
4
4
|
import { EmbeddingOptions, EmbedResult, EmbedManyResult, ModelConfig } from '@mastra/core';
|
|
5
|
+
import { QueryResult } from '@mastra/core/vector';
|
|
5
6
|
import * as _mastra_core_tools from '@mastra/core/tools';
|
|
6
|
-
import { EmbeddingOptions as EmbeddingOptions$1 } from '@mastra/core/embeddings';
|
|
7
7
|
import { z } from 'zod';
|
|
8
|
-
import {
|
|
8
|
+
import { EmbeddingOptions as EmbeddingOptions$1 } from '@mastra/core/embeddings';
|
|
9
9
|
|
|
10
10
|
declare enum Language {
|
|
11
11
|
CPP = "cpp",
|
|
@@ -155,247 +155,6 @@ interface RerankConfig {
|
|
|
155
155
|
}
|
|
156
156
|
declare function rerank(results: QueryResult[], query: string, modelConfig: ModelConfig, options: RerankerFunctionOptions): Promise<RerankResult[]>;
|
|
157
157
|
|
|
158
|
-
type VectorFilterType = 'pg' | 'astra' | 'qdrant' | 'upstash' | 'pinecone' | 'chroma' | '';
|
|
159
|
-
declare const createVectorQueryTool: ({ vectorStoreName, indexName, topK, options, vectorFilterType, reranker, }: {
|
|
160
|
-
vectorStoreName: string;
|
|
161
|
-
indexName: string;
|
|
162
|
-
options: EmbeddingOptions$1;
|
|
163
|
-
topK?: number;
|
|
164
|
-
vectorFilterType?: VectorFilterType;
|
|
165
|
-
reranker?: RerankConfig;
|
|
166
|
-
}) => _mastra_core_tools.Tool<`VectorQuery ${string} ${string} Tool`, z.ZodObject<{
|
|
167
|
-
queryText: z.ZodString;
|
|
168
|
-
filter: z.ZodUnion<[z.ZodObject<{
|
|
169
|
-
keyword: z.ZodString;
|
|
170
|
-
operator: z.ZodString;
|
|
171
|
-
value: z.ZodString;
|
|
172
|
-
}, "strip", z.ZodTypeAny, {
|
|
173
|
-
value: string;
|
|
174
|
-
keyword: string;
|
|
175
|
-
operator: string;
|
|
176
|
-
}, {
|
|
177
|
-
value: string;
|
|
178
|
-
keyword: string;
|
|
179
|
-
operator: string;
|
|
180
|
-
}>, z.ZodObject<{
|
|
181
|
-
type: z.ZodEnum<["$and", "$or"]>;
|
|
182
|
-
filters: z.ZodArray<z.ZodObject<{
|
|
183
|
-
keyword: z.ZodString;
|
|
184
|
-
operator: z.ZodString;
|
|
185
|
-
value: z.ZodString;
|
|
186
|
-
}, "strip", z.ZodTypeAny, {
|
|
187
|
-
value: string;
|
|
188
|
-
keyword: string;
|
|
189
|
-
operator: string;
|
|
190
|
-
}, {
|
|
191
|
-
value: string;
|
|
192
|
-
keyword: string;
|
|
193
|
-
operator: string;
|
|
194
|
-
}>, "many">;
|
|
195
|
-
}, "strip", z.ZodTypeAny, {
|
|
196
|
-
type: "$and" | "$or";
|
|
197
|
-
filters: {
|
|
198
|
-
value: string;
|
|
199
|
-
keyword: string;
|
|
200
|
-
operator: string;
|
|
201
|
-
}[];
|
|
202
|
-
}, {
|
|
203
|
-
type: "$and" | "$or";
|
|
204
|
-
filters: {
|
|
205
|
-
value: string;
|
|
206
|
-
keyword: string;
|
|
207
|
-
operator: string;
|
|
208
|
-
}[];
|
|
209
|
-
}>]>;
|
|
210
|
-
}, "strip", z.ZodTypeAny, {
|
|
211
|
-
filter: {
|
|
212
|
-
value: string;
|
|
213
|
-
keyword: string;
|
|
214
|
-
operator: string;
|
|
215
|
-
} | {
|
|
216
|
-
type: "$and" | "$or";
|
|
217
|
-
filters: {
|
|
218
|
-
value: string;
|
|
219
|
-
keyword: string;
|
|
220
|
-
operator: string;
|
|
221
|
-
}[];
|
|
222
|
-
};
|
|
223
|
-
queryText: string;
|
|
224
|
-
}, {
|
|
225
|
-
filter: {
|
|
226
|
-
value: string;
|
|
227
|
-
keyword: string;
|
|
228
|
-
operator: string;
|
|
229
|
-
} | {
|
|
230
|
-
type: "$and" | "$or";
|
|
231
|
-
filters: {
|
|
232
|
-
value: string;
|
|
233
|
-
keyword: string;
|
|
234
|
-
operator: string;
|
|
235
|
-
}[];
|
|
236
|
-
};
|
|
237
|
-
queryText: string;
|
|
238
|
-
}>, z.ZodObject<{
|
|
239
|
-
relevantContext: z.ZodAny;
|
|
240
|
-
}, "strip", z.ZodTypeAny, {
|
|
241
|
-
relevantContext?: any;
|
|
242
|
-
}, {
|
|
243
|
-
relevantContext?: any;
|
|
244
|
-
}>, _mastra_core.ToolExecutionContext<z.ZodObject<{
|
|
245
|
-
queryText: z.ZodString;
|
|
246
|
-
filter: z.ZodUnion<[z.ZodObject<{
|
|
247
|
-
keyword: z.ZodString;
|
|
248
|
-
operator: z.ZodString;
|
|
249
|
-
value: z.ZodString;
|
|
250
|
-
}, "strip", z.ZodTypeAny, {
|
|
251
|
-
value: string;
|
|
252
|
-
keyword: string;
|
|
253
|
-
operator: string;
|
|
254
|
-
}, {
|
|
255
|
-
value: string;
|
|
256
|
-
keyword: string;
|
|
257
|
-
operator: string;
|
|
258
|
-
}>, z.ZodObject<{
|
|
259
|
-
type: z.ZodEnum<["$and", "$or"]>;
|
|
260
|
-
filters: z.ZodArray<z.ZodObject<{
|
|
261
|
-
keyword: z.ZodString;
|
|
262
|
-
operator: z.ZodString;
|
|
263
|
-
value: z.ZodString;
|
|
264
|
-
}, "strip", z.ZodTypeAny, {
|
|
265
|
-
value: string;
|
|
266
|
-
keyword: string;
|
|
267
|
-
operator: string;
|
|
268
|
-
}, {
|
|
269
|
-
value: string;
|
|
270
|
-
keyword: string;
|
|
271
|
-
operator: string;
|
|
272
|
-
}>, "many">;
|
|
273
|
-
}, "strip", z.ZodTypeAny, {
|
|
274
|
-
type: "$and" | "$or";
|
|
275
|
-
filters: {
|
|
276
|
-
value: string;
|
|
277
|
-
keyword: string;
|
|
278
|
-
operator: string;
|
|
279
|
-
}[];
|
|
280
|
-
}, {
|
|
281
|
-
type: "$and" | "$or";
|
|
282
|
-
filters: {
|
|
283
|
-
value: string;
|
|
284
|
-
keyword: string;
|
|
285
|
-
operator: string;
|
|
286
|
-
}[];
|
|
287
|
-
}>]>;
|
|
288
|
-
}, "strip", z.ZodTypeAny, {
|
|
289
|
-
filter: {
|
|
290
|
-
value: string;
|
|
291
|
-
keyword: string;
|
|
292
|
-
operator: string;
|
|
293
|
-
} | {
|
|
294
|
-
type: "$and" | "$or";
|
|
295
|
-
filters: {
|
|
296
|
-
value: string;
|
|
297
|
-
keyword: string;
|
|
298
|
-
operator: string;
|
|
299
|
-
}[];
|
|
300
|
-
};
|
|
301
|
-
queryText: string;
|
|
302
|
-
}, {
|
|
303
|
-
filter: {
|
|
304
|
-
value: string;
|
|
305
|
-
keyword: string;
|
|
306
|
-
operator: string;
|
|
307
|
-
} | {
|
|
308
|
-
type: "$and" | "$or";
|
|
309
|
-
filters: {
|
|
310
|
-
value: string;
|
|
311
|
-
keyword: string;
|
|
312
|
-
operator: string;
|
|
313
|
-
}[];
|
|
314
|
-
};
|
|
315
|
-
queryText: string;
|
|
316
|
-
}>, _mastra_core.WorkflowContext<any>>>;
|
|
317
|
-
declare const createGraphRAGTool: ({ vectorStoreName, indexName, topK, options, vectorFilterType, graphOptions, }: {
|
|
318
|
-
vectorStoreName: string;
|
|
319
|
-
indexName: string;
|
|
320
|
-
options: EmbeddingOptions$1;
|
|
321
|
-
topK?: number;
|
|
322
|
-
vectorFilterType?: VectorFilterType;
|
|
323
|
-
graphOptions?: {
|
|
324
|
-
dimension?: number;
|
|
325
|
-
randomWalkSteps?: number;
|
|
326
|
-
restartProb?: number;
|
|
327
|
-
threshold?: number;
|
|
328
|
-
};
|
|
329
|
-
}) => _mastra_core_tools.Tool<`GraphRAG ${string} ${string} Tool`, z.ZodObject<{
|
|
330
|
-
queryText: z.ZodString;
|
|
331
|
-
filter: z.ZodObject<{
|
|
332
|
-
keyword: z.ZodString;
|
|
333
|
-
operator: z.ZodString;
|
|
334
|
-
value: z.ZodString;
|
|
335
|
-
}, "strip", z.ZodTypeAny, {
|
|
336
|
-
value: string;
|
|
337
|
-
keyword: string;
|
|
338
|
-
operator: string;
|
|
339
|
-
}, {
|
|
340
|
-
value: string;
|
|
341
|
-
keyword: string;
|
|
342
|
-
operator: string;
|
|
343
|
-
}>;
|
|
344
|
-
}, "strip", z.ZodTypeAny, {
|
|
345
|
-
filter: {
|
|
346
|
-
value: string;
|
|
347
|
-
keyword: string;
|
|
348
|
-
operator: string;
|
|
349
|
-
};
|
|
350
|
-
queryText: string;
|
|
351
|
-
}, {
|
|
352
|
-
filter: {
|
|
353
|
-
value: string;
|
|
354
|
-
keyword: string;
|
|
355
|
-
operator: string;
|
|
356
|
-
};
|
|
357
|
-
queryText: string;
|
|
358
|
-
}>, z.ZodObject<{
|
|
359
|
-
relevantContext: z.ZodAny;
|
|
360
|
-
}, "strip", z.ZodTypeAny, {
|
|
361
|
-
relevantContext?: any;
|
|
362
|
-
}, {
|
|
363
|
-
relevantContext?: any;
|
|
364
|
-
}>, _mastra_core.ToolExecutionContext<z.ZodObject<{
|
|
365
|
-
queryText: z.ZodString;
|
|
366
|
-
filter: z.ZodObject<{
|
|
367
|
-
keyword: z.ZodString;
|
|
368
|
-
operator: z.ZodString;
|
|
369
|
-
value: z.ZodString;
|
|
370
|
-
}, "strip", z.ZodTypeAny, {
|
|
371
|
-
value: string;
|
|
372
|
-
keyword: string;
|
|
373
|
-
operator: string;
|
|
374
|
-
}, {
|
|
375
|
-
value: string;
|
|
376
|
-
keyword: string;
|
|
377
|
-
operator: string;
|
|
378
|
-
}>;
|
|
379
|
-
}, "strip", z.ZodTypeAny, {
|
|
380
|
-
filter: {
|
|
381
|
-
value: string;
|
|
382
|
-
keyword: string;
|
|
383
|
-
operator: string;
|
|
384
|
-
};
|
|
385
|
-
queryText: string;
|
|
386
|
-
}, {
|
|
387
|
-
filter: {
|
|
388
|
-
value: string;
|
|
389
|
-
keyword: string;
|
|
390
|
-
operator: string;
|
|
391
|
-
};
|
|
392
|
-
queryText: string;
|
|
393
|
-
}>, _mastra_core.WorkflowContext<any>>>;
|
|
394
|
-
declare const createDocumentChunkerTool: ({ doc, params, }: {
|
|
395
|
-
doc: MDocument;
|
|
396
|
-
params?: ChunkParams;
|
|
397
|
-
}) => _mastra_core_tools.Tool<"Document Chunker undefined undefined" | `Document Chunker undefined ${number}` | "Document Chunker markdown undefined" | `Document Chunker markdown ${number}` | "Document Chunker latex undefined" | `Document Chunker latex ${number}` | "Document Chunker html undefined" | `Document Chunker html ${number}` | "Document Chunker recursive undefined" | `Document Chunker recursive ${number}` | "Document Chunker character undefined" | `Document Chunker character ${number}` | "Document Chunker token undefined" | `Document Chunker token ${number}` | "Document Chunker json undefined" | `Document Chunker json ${number}`, z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>, undefined, _mastra_core.ToolExecutionContext<z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>, _mastra_core.WorkflowContext<any>>>;
|
|
398
|
-
|
|
399
158
|
/**
|
|
400
159
|
* TODO: GraphRAG Enhancements
|
|
401
160
|
* - Add support for more edge types (sequential, hierarchical, citation, etc)
|
|
@@ -444,7 +203,120 @@ declare class GraphRAG {
|
|
|
444
203
|
createGraph(chunks: GraphChunk[], embeddings: GraphEmbedding[]): void;
|
|
445
204
|
private selectWeightedNeighbor;
|
|
446
205
|
private randomWalkWithRestart;
|
|
447
|
-
query(query
|
|
206
|
+
query({ query, topK, randomWalkSteps, restartProb, }: {
|
|
207
|
+
query: number[];
|
|
208
|
+
topK?: number;
|
|
209
|
+
randomWalkSteps?: number;
|
|
210
|
+
restartProb?: number;
|
|
211
|
+
}): RankedNode[];
|
|
448
212
|
}
|
|
449
213
|
|
|
450
|
-
|
|
214
|
+
declare const createDocumentChunkerTool: ({ doc, params, }: {
|
|
215
|
+
doc: MDocument;
|
|
216
|
+
params?: ChunkParams;
|
|
217
|
+
}) => _mastra_core_tools.Tool<"Document Chunker undefined undefined" | `Document Chunker undefined ${number}` | "Document Chunker markdown undefined" | `Document Chunker markdown ${number}` | "Document Chunker latex undefined" | `Document Chunker latex ${number}` | "Document Chunker html undefined" | `Document Chunker html ${number}` | "Document Chunker recursive undefined" | `Document Chunker recursive ${number}` | "Document Chunker character undefined" | `Document Chunker character ${number}` | "Document Chunker token undefined" | `Document Chunker token ${number}` | "Document Chunker json undefined" | `Document Chunker json ${number}`, z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>, undefined, _mastra_core.ToolExecutionContext<z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>, _mastra_core.WorkflowContext<any>>>;
|
|
218
|
+
|
|
219
|
+
declare const createGraphRAGTool: ({ vectorStoreName, indexName, options, enableFilter, graphOptions, id, description, }: {
|
|
220
|
+
vectorStoreName: string;
|
|
221
|
+
indexName: string;
|
|
222
|
+
options: EmbeddingOptions$1;
|
|
223
|
+
enableFilter?: boolean;
|
|
224
|
+
graphOptions?: {
|
|
225
|
+
dimension?: number;
|
|
226
|
+
randomWalkSteps?: number;
|
|
227
|
+
restartProb?: number;
|
|
228
|
+
threshold?: number;
|
|
229
|
+
};
|
|
230
|
+
id?: string;
|
|
231
|
+
description?: string;
|
|
232
|
+
}) => _mastra_core_tools.Tool<string, z.ZodObject<{
|
|
233
|
+
queryText: z.ZodString;
|
|
234
|
+
topK: z.ZodNumber;
|
|
235
|
+
filter: z.ZodString;
|
|
236
|
+
}, "strip", z.ZodTypeAny, {
|
|
237
|
+
filter: string;
|
|
238
|
+
topK: number;
|
|
239
|
+
queryText: string;
|
|
240
|
+
}, {
|
|
241
|
+
filter: string;
|
|
242
|
+
topK: number;
|
|
243
|
+
queryText: string;
|
|
244
|
+
}>, z.ZodObject<{
|
|
245
|
+
relevantContext: z.ZodAny;
|
|
246
|
+
}, "strip", z.ZodTypeAny, {
|
|
247
|
+
relevantContext?: any;
|
|
248
|
+
}, {
|
|
249
|
+
relevantContext?: any;
|
|
250
|
+
}>, _mastra_core.ToolExecutionContext<z.ZodObject<{
|
|
251
|
+
queryText: z.ZodString;
|
|
252
|
+
topK: z.ZodNumber;
|
|
253
|
+
filter: z.ZodString;
|
|
254
|
+
}, "strip", z.ZodTypeAny, {
|
|
255
|
+
filter: string;
|
|
256
|
+
topK: number;
|
|
257
|
+
queryText: string;
|
|
258
|
+
}, {
|
|
259
|
+
filter: string;
|
|
260
|
+
topK: number;
|
|
261
|
+
queryText: string;
|
|
262
|
+
}>, _mastra_core.WorkflowContext<any>>>;
|
|
263
|
+
|
|
264
|
+
declare const createVectorQueryTool: ({ vectorStoreName, indexName, options, enableFilter, reranker, id, description, }: {
|
|
265
|
+
vectorStoreName: string;
|
|
266
|
+
indexName: string;
|
|
267
|
+
options: EmbeddingOptions$1;
|
|
268
|
+
enableFilter?: boolean;
|
|
269
|
+
reranker?: RerankConfig;
|
|
270
|
+
id?: string;
|
|
271
|
+
description?: string;
|
|
272
|
+
}) => _mastra_core_tools.Tool<string, z.ZodObject<{
|
|
273
|
+
queryText: z.ZodString;
|
|
274
|
+
topK: z.ZodNumber;
|
|
275
|
+
filter: z.ZodString;
|
|
276
|
+
}, "strip", z.ZodTypeAny, {
|
|
277
|
+
filter: string;
|
|
278
|
+
topK: number;
|
|
279
|
+
queryText: string;
|
|
280
|
+
}, {
|
|
281
|
+
filter: string;
|
|
282
|
+
topK: number;
|
|
283
|
+
queryText: string;
|
|
284
|
+
}>, z.ZodObject<{
|
|
285
|
+
relevantContext: z.ZodAny;
|
|
286
|
+
}, "strip", z.ZodTypeAny, {
|
|
287
|
+
relevantContext?: any;
|
|
288
|
+
}, {
|
|
289
|
+
relevantContext?: any;
|
|
290
|
+
}>, _mastra_core.ToolExecutionContext<z.ZodObject<{
|
|
291
|
+
queryText: z.ZodString;
|
|
292
|
+
topK: z.ZodNumber;
|
|
293
|
+
filter: z.ZodString;
|
|
294
|
+
}, "strip", z.ZodTypeAny, {
|
|
295
|
+
filter: string;
|
|
296
|
+
topK: number;
|
|
297
|
+
queryText: string;
|
|
298
|
+
}, {
|
|
299
|
+
filter: string;
|
|
300
|
+
topK: number;
|
|
301
|
+
queryText: string;
|
|
302
|
+
}>, _mastra_core.WorkflowContext<any>>>;
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* Vector store specific prompts that detail supported operators and examples.
|
|
306
|
+
* These prompts help users construct valid filters for each vector store.
|
|
307
|
+
*/
|
|
308
|
+
declare const ASTRA_PROMPT = "When querying Astra, you can ONLY use the operators listed below. Any other operators will be rejected.\nImportant: Don't explain how to construct the filter - use the specified operators and fields to search the content and return relevant results.\nIf a user tries to give an explicit operator that is not supported, reject the filter entirely and let them know that the operator is not supported.\n\nBasic Comparison Operators:\n- $eq: Exact match (default when using field: value)\n Example: { \"category\": \"electronics\" }\n- $ne: Not equal\n Example: { \"category\": { \"$ne\": \"electronics\" } }\n- $gt: Greater than\n Example: { \"price\": { \"$gt\": 100 } }\n- $gte: Greater than or equal\n Example: { \"price\": { \"$gte\": 100 } }\n- $lt: Less than\n Example: { \"price\": { \"$lt\": 100 } }\n- $lte: Less than or equal\n Example: { \"price\": { \"$lte\": 100 } }\n\nArray Operators:\n- $in: Match any value in array\n Example: { \"category\": { \"$in\": [\"electronics\", \"books\"] } }\n- $nin: Does not match any value in array\n Example: { \"category\": { \"$nin\": [\"electronics\", \"books\"] } }\n- $all: Match all values in array\n Example: { \"tags\": { \"$all\": [\"premium\", \"sale\"] } }\n\nLogical Operators:\n- $and: Logical AND (can be implicit or explicit)\n Implicit Example: { \"price\": { \"$gt\": 100 }, \"category\": \"electronics\" }\n Explicit Example: { \"$and\": [{ \"price\": { \"$gt\": 100 } }, { \"category\": \"electronics\" }] }\n- $or: Logical OR\n Example: { \"$or\": [{ \"price\": { \"$lt\": 50 } }, { \"category\": \"books\" }] }\n- $not: Logical NOT\n Example: { \"$not\": { \"category\": \"electronics\" } }\n\nElement Operators:\n- $exists: Check if field exists\n Example: { \"rating\": { \"$exists\": true } }\n\nSpecial Operators:\n- $size: Array length check\n Example: { \"tags\": { \"$size\": 2 } }\n\nRestrictions:\n- Regex patterns are not supported\n- Only $and, $or, and $not logical operators are supported\n- Nested fields are supported using dot notation\n- Multiple conditions on the same field are supported with both implicit and explicit $and\n- Empty arrays in $in/$nin will return no results\n- A non-empty array is required for $all operator\n- Only logical operators ($and, $or, $not) can be used at the top level\n- All other operators must be used within a field condition\n Valid: { \"field\": { \"$gt\": 100 } }\n Valid: { \"$and\": [...] }\n Invalid: { \"$gt\": 100 }\n- Logical operators must contain field conditions, not direct operators\n Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n Invalid: { \"$and\": [{ \"$gt\": 100 }] }\n- $not operator:\n - Must be an object\n - Cannot be empty\n - Can be used at field level or top level\n - Valid: { \"$not\": { \"field\": \"value\" } }\n - Valid: { \"field\": { \"$not\": { \"$eq\": \"value\" } } }\n- Other logical operators ($and, $or):\n - Can only be used at top level or nested within other logical operators\n - Can not be used on a field level, or be nested inside a field\n - Can not be used inside an operator\n - Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n - Valid: { \"$or\": [{ \"$and\": [{ \"field\": { \"$gt\": 100 } }] }] }\n - Invalid: { \"field\": { \"$and\": [{ \"$gt\": 100 }] } }\n - Invalid: { \"field\": { \"$or\": [{ \"$gt\": 100 }] } }\n - Invalid: { \"field\": { \"$gt\": { \"$and\": [{...}] } } }\n\nExample Complex Query:\n{\n \"$and\": [\n { \"category\": { \"$in\": [\"electronics\", \"computers\"] } },\n { \"price\": { \"$gte\": 100, \"$lte\": 1000 } },\n { \"tags\": { \"$all\": [\"premium\"] } },\n { \"rating\": { \"$exists\": true, \"$gt\": 4 } },\n { \"$or\": [\n { \"stock\": { \"$gt\": 0 } },\n { \"preorder\": true }\n ]}\n ]\n}";
|
|
309
|
+
declare const CHROMA_PROMPT = "When querying Chroma, you can ONLY use the operators listed below. Any other operators will be rejected.\nImportant: Don't explain how to construct the filter - use the specified operators and fields to search the content and return relevant results.\nIf a user tries to give an explicit operator that is not supported, reject the filter entirely and let them know that the operator is not supported.\n\nBasic Comparison Operators:\n- $eq: Exact match (default when using field: value)\n Example: { \"category\": \"electronics\" }\n- $ne: Not equal\n Example: { \"category\": { \"$ne\": \"electronics\" } }\n- $gt: Greater than\n Example: { \"price\": { \"$gt\": 100 } }\n- $gte: Greater than or equal\n Example: { \"price\": { \"$gte\": 100 } }\n- $lt: Less than\n Example: { \"price\": { \"$lt\": 100 } }\n- $lte: Less than or equal\n Example: { \"price\": { \"$lte\": 100 } }\n\nArray Operators:\n- $in: Match any value in array\n Example: { \"category\": { \"$in\": [\"electronics\", \"books\"] } }\n- $nin: Does not match any value in array\n Example: { \"category\": { \"$nin\": [\"electronics\", \"books\"] } }\n\nLogical Operators:\n- $and: Logical AND\n Example: { \"$and\": [{ \"price\": { \"$gt\": 100 } }, { \"category\": \"electronics\" }] }\n- $or: Logical OR\n Example: { \"$or\": [{ \"price\": { \"$lt\": 50 } }, { \"category\": \"books\" }] }\n\nRestrictions:\n- Regex patterns are not supported\n- Element operators are not supported\n- Only $and and $or logical operators are supported\n- Nested fields are supported using dot notation\n- Multiple conditions on the same field are supported with both implicit and explicit $and\n- Empty arrays in $in/$nin will return no results\n- If multiple top-level fields exist, they're wrapped in $and\n- Only logical operators ($and, $or) can be used at the top level\n- All other operators must be used within a field condition\n Valid: { \"field\": { \"$gt\": 100 } }\n Valid: { \"$and\": [...] }\n Invalid: { \"$gt\": 100 }\n Invalid: { \"$in\": [...] }\n- Logical operators must contain field conditions, not direct operators\n Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n Invalid: { \"$and\": [{ \"$gt\": 100 }] }\n- Logical operators ($and, $or):\n - Can only be used at top level or nested within other logical operators\n - Can not be used on a field level, or be nested inside a field\n - Can not be used inside an operator\n - Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n - Valid: { \"$or\": [{ \"$and\": [{ \"field\": { \"$gt\": 100 } }] }] }\n - Invalid: { \"field\": { \"$and\": [{ \"$gt\": 100 }] } }\n - Invalid: { \"field\": { \"$or\": [{ \"$gt\": 100 }] } }\n - Invalid: { \"field\": { \"$gt\": { \"$and\": [{...}] } } }\nExample Complex Query:\n{\n \"$and\": [\n { \"category\": { \"$in\": [\"electronics\", \"computers\"] } },\n { \"price\": { \"$gte\": 100, \"$lte\": 1000 } },\n { \"$or\": [\n { \"inStock\": true },\n { \"preorder\": true }\n ]}\n ]\n}";
|
|
310
|
+
declare const LIBSQL_PROMPT = "When querying LibSQL Vector, you can ONLY use the operators listed below. Any other operators will be rejected.\nImportant: Don't explain how to construct the filter - use the specified operators and fields to search the content and return relevant results.\nIf a user tries to give an explicit operator that is not supported, reject the filter entirely and let them know that the operator is not supported.\n\nBasic Comparison Operators:\n- $eq: Exact match (default when using field: value)\n Example: { \"category\": \"electronics\" }\n- $ne: Not equal\n Example: { \"category\": { \"$ne\": \"electronics\" } }\n- $gt: Greater than\n Example: { \"price\": { \"$gt\": 100 } }\n- $gte: Greater than or equal\n Example: { \"price\": { \"$gte\": 100 } }\n- $lt: Less than\n Example: { \"price\": { \"$lt\": 100 } }\n- $lte: Less than or equal\n Example: { \"price\": { \"$lte\": 100 } }\n\nArray Operators:\n- $in: Match any value in array\n Example: { \"category\": { \"$in\": [\"electronics\", \"books\"] } }\n- $nin: Does not match any value in array\n Example: { \"category\": { \"$nin\": [\"electronics\", \"books\"] } }\n- $all: Match all values in array\n Example: { \"tags\": { \"$all\": [\"premium\", \"sale\"] } }\n- $elemMatch: Match array elements that meet all specified conditions\n Example: { \"items\": { \"$elemMatch\": { \"price\": { \"$gt\": 100 } } } }\n- $contains: Check if array contains value\n Example: { \"tags\": { \"$contains\": \"premium\" } }\n\nLogical Operators:\n- $and: Logical AND (implicit when using multiple conditions)\n Example: { \"$and\": [{ \"price\": { \"$gt\": 100 } }, { \"category\": \"electronics\" }] }\n- $or: Logical OR\n Example: { \"$or\": [{ \"price\": { \"$lt\": 50 } }, { \"category\": \"books\" }] }\n- $not: Logical NOT\n Example: { \"$not\": { \"category\": \"electronics\" } }\n- $nor: Logical NOR\n Example: { \"$nor\": [{ \"price\": { \"$lt\": 50 } }, { \"category\": \"books\" }] }\n\nElement Operators:\n- $exists: Check if field exists\n Example: { \"rating\": { \"$exists\": true } }\n\nSpecial Operators:\n- $size: Array length check\n Example: { \"tags\": { \"$size\": 2 } }\n\nRestrictions:\n- Regex patterns are not supported\n- Direct RegExp patterns will throw an error\n- Nested fields are supported using dot notation\n- Multiple conditions on the same field are supported with both implicit and explicit $and\n- Array operations work on array fields only\n- Basic operators handle array values as JSON strings\n- Empty arrays in conditions are handled gracefully\n- Only logical operators ($and, $or, $not, $nor) can be used at the top level\n- All other operators must be used within a field condition\n Valid: { \"field\": { \"$gt\": 100 } }\n Valid: { \"$and\": [...] }\n Invalid: { \"$gt\": 100 }\n Invalid: { \"$contains\": \"value\" }\n- Logical operators must contain field conditions, not direct operators\n Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n Invalid: { \"$and\": [{ \"$gt\": 100 }] }\n- $not operator:\n - Must be an object\n - Cannot be empty\n - Can be used at field level or top level\n - Valid: { \"$not\": { \"field\": \"value\" } }\n - Valid: { \"field\": { \"$not\": { \"$eq\": \"value\" } } }\n- Other logical operators ($and, $or, $nor):\n - Can only be used at top level or nested within other logical operators\n - Can not be used on a field level, or be nested inside a field\n - Can not be used inside an operator\n - Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n - Valid: { \"$or\": [{ \"$and\": [{ \"field\": { \"$gt\": 100 } }] }] }\n - Invalid: { \"field\": { \"$and\": [{ \"$gt\": 100 }] } }\n - Invalid: { \"field\": { \"$or\": [{ \"$gt\": 100 }] } }\n - Invalid: { \"field\": { \"$gt\": { \"$and\": [{...}] } } }\n- $elemMatch requires an object with conditions\n Valid: { \"array\": { \"$elemMatch\": { \"field\": \"value\" } } }\n Invalid: { \"array\": { \"$elemMatch\": \"value\" } }\n\nExample Complex Query:\n{\n \"$and\": [\n { \"category\": { \"$in\": [\"electronics\", \"computers\"] } },\n { \"price\": { \"$gte\": 100, \"$lte\": 1000 } },\n { \"tags\": { \"$all\": [\"premium\", \"sale\"] } },\n { \"items\": { \"$elemMatch\": { \"price\": { \"$gt\": 50 }, \"inStock\": true } } },\n { \"$or\": [\n { \"stock\": { \"$gt\": 0 } },\n { \"preorder\": true }\n ]}\n ]\n}";
|
|
311
|
+
declare const PGVECTOR_PROMPT = "When querying PG Vector, you can ONLY use the operators listed below. Any other operators will be rejected.\nImportant: Don't explain how to construct the filter - use the specified operators and fields to search the content and return relevant results.\nIf a user tries to give an explicit operator that is not supported, reject the filter entirely and let them know that the operator is not supported.\n\nBasic Comparison Operators:\n- $eq: Exact match (default when using field: value)\n Example: { \"category\": \"electronics\" }\n- $ne: Not equal\n Example: { \"category\": { \"$ne\": \"electronics\" } }\n- $gt: Greater than\n Example: { \"price\": { \"$gt\": 100 } }\n- $gte: Greater than or equal\n Example: { \"price\": { \"$gte\": 100 } }\n- $lt: Less than\n Example: { \"price\": { \"$lt\": 100 } }\n- $lte: Less than or equal\n Example: { \"price\": { \"$lte\": 100 } }\n\nArray Operators:\n- $in: Match any value in array\n Example: { \"category\": { \"$in\": [\"electronics\", \"books\"] } }\n- $nin: Does not match any value in array\n Example: { \"category\": { \"$nin\": [\"electronics\", \"books\"] } }\n- $all: Match all values in array\n Example: { \"tags\": { \"$all\": [\"premium\", \"sale\"] } }\n- $elemMatch: Match array elements that meet all specified conditions\n Example: { \"items\": { \"$elemMatch\": { \"price\": { \"$gt\": 100 } } } }\n- $contains: Check if array contains value\n Example: { \"tags\": { \"$contains\": \"premium\" } }\n\nLogical Operators:\n- $and: Logical AND\n Example: { \"$and\": [{ \"price\": { \"$gt\": 100 } }, { \"category\": \"electronics\" }] }\n- $or: Logical OR\n Example: { \"$or\": [{ \"price\": { \"$lt\": 50 } }, { \"category\": \"books\" }] }\n- $not: Logical NOT\n Example: { \"$not\": { \"category\": \"electronics\" } }\n- $nor: Logical NOR\n Example: { \"$nor\": [{ \"price\": { \"$lt\": 50 } }, { \"category\": \"books\" }] }\n\nElement Operators:\n- $exists: Check if field exists\n Example: { \"rating\": { \"$exists\": true } }\n\nSpecial Operators:\n- $size: Array length check\n Example: { \"tags\": { \"$size\": 2 } }\n- $regex: Pattern matching (PostgreSQL regex syntax)\n Example: { \"name\": { \"$regex\": \"^iphone\" } }\n- $options: Regex options (used with $regex)\n Example: { \"name\": { \"$regex\": \"iphone\", \"$options\": \"i\" } }\n\nRestrictions:\n- Direct RegExp patterns are supported\n- Nested fields are supported using dot notation\n- Multiple conditions on the same field are supported with both implicit and explicit $and\n- Array operations work on array fields only\n- Regex patterns must follow PostgreSQL syntax\n- Empty arrays in conditions are handled gracefully\n- Only logical operators ($and, $or, $not, $nor) can be used at the top level\n- All other operators must be used within a field condition\n Valid: { \"field\": { \"$gt\": 100 } }\n Valid: { \"$and\": [...] }\n Invalid: { \"$gt\": 100 }\n Invalid: { \"$regex\": \"pattern\" }\n- Logical operators must contain field conditions, not direct operators\n Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n Invalid: { \"$and\": [{ \"$gt\": 100 }] }\n- $not operator:\n - Must be an object\n - Cannot be empty\n - Can be used at field level or top level\n - Valid: { \"$not\": { \"field\": \"value\" } }\n - Valid: { \"field\": { \"$not\": { \"$eq\": \"value\" } } }\n- Other logical operators ($and, $or, $nor):\n - Can only be used at top level or nested within other logical operators\n - Can not be used on a field level, or be nested inside a field\n - Can not be used inside an operator\n - Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n - Valid: { \"$or\": [{ \"$and\": [{ \"field\": { \"$gt\": 100 } }] }] }\n - Invalid: { \"field\": { \"$and\": [{ \"$gt\": 100 }] } }\n - Invalid: { \"field\": { \"$or\": [{ \"$gt\": 100 }] } }\n - Invalid: { \"field\": { \"$gt\": { \"$and\": [{...}] } } }\n- $elemMatch requires an object with conditions\n Valid: { \"array\": { \"$elemMatch\": { \"field\": \"value\" } } }\n Invalid: { \"array\": { \"$elemMatch\": \"value\" } }\n\nExample Complex Query:\n{\n \"$and\": [\n { \"category\": { \"$in\": [\"electronics\", \"computers\"] } },\n { \"price\": { \"$gte\": 100, \"$lte\": 1000 } },\n { \"tags\": { \"$all\": [\"premium\", \"sale\"] } },\n { \"items\": { \"$elemMatch\": { \"price\": { \"$gt\": 50 }, \"inStock\": true } } },\n { \"$or\": [\n { \"name\": { \"$regex\": \"^iphone\", \"$options\": \"i\" } },\n { \"description\": { \"$regex\": \".*apple.*\" } }\n ]}\n ]\n}";
|
|
312
|
+
declare const PINECONE_PROMPT = "When querying Pinecone, you can ONLY use the operators listed below. Any other operators will be rejected.\nImportant: Don't explain how to construct the filter - use the specified operators and fields to search the content and return relevant results.\nIf a user tries to give an explicit operator that is not supported, reject the filter entirely and let them know that the operator is not supported.\n\nBasic Comparison Operators:\n- $eq: Exact match (default when using field: value)\n Example: { \"category\": \"electronics\" }\n- $ne: Not equal\n Example: { \"category\": { \"$ne\": \"electronics\" } }\n- $gt: Greater than\n Example: { \"price\": { \"$gt\": 100 } }\n- $gte: Greater than or equal\n Example: { \"price\": { \"$gte\": 100 } }\n- $lt: Less than\n Example: { \"price\": { \"$lt\": 100 } }\n- $lte: Less than or equal\n Example: { \"price\": { \"$lte\": 100 } }\n\nArray Operators:\n- $in: Match any value in array\n Example: { \"category\": { \"$in\": [\"electronics\", \"books\"] } }\n- $nin: Does not match any value in array\n Example: { \"category\": { \"$nin\": [\"electronics\", \"books\"] } }\n- $all: Match all values in array\n Example: { \"tags\": { \"$all\": [\"premium\", \"sale\"] } }\n\nLogical Operators:\n- $and: Logical AND (can be implicit or explicit)\n Implicit Example: { \"price\": { \"$gt\": 100 }, \"category\": \"electronics\" }\n Explicit Example: { \"$and\": [{ \"price\": { \"$gt\": 100 } }, { \"category\": \"electronics\" }] }\n- $or: Logical OR\n Example: { \"$or\": [{ \"price\": { \"$lt\": 50 } }, { \"category\": \"books\" }] }\n\nElement Operators:\n- $exists: Check if field exists\n Example: { \"rating\": { \"$exists\": true } }\n\nRestrictions:\n- Regex patterns are not supported\n- Only $and and $or logical operators are supported at the top level\n- Empty arrays in $in/$nin will return no results\n- A non-empty array is required for $all operator\n- Nested fields are supported using dot notation\n- Multiple conditions on the same field are supported with both implicit and explicit $and\n- At least one key-value pair is required in filter object\n- Empty objects and undefined values are treated as no filter\n- Invalid types in comparison operators will throw errors\n- All non-logical operators must be used within a field condition\n Valid: { \"field\": { \"$gt\": 100 } }\n Valid: { \"$and\": [...] }\n Invalid: { \"$gt\": 100 }\n- Logical operators must contain field conditions, not direct operators\n Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n Invalid: { \"$and\": [{ \"$gt\": 100 }] }\n- Logical operators ($and, $or):\n - Can only be used at top level or nested within other logical operators\n - Can not be used on a field level, or be nested inside a field\n - Can not be used inside an operator\n - Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n - Valid: { \"$or\": [{ \"$and\": [{ \"field\": { \"$gt\": 100 } }] }] }\n - Invalid: { \"field\": { \"$and\": [{ \"$gt\": 100 }] } }\n - Invalid: { \"field\": { \"$or\": [{ \"$gt\": 100 }] } }\n - Invalid: { \"field\": { \"$gt\": { \"$and\": [{...}] } } }\nExample Complex Query:\n{\n \"$and\": [\n { \"category\": { \"$in\": [\"electronics\", \"computers\"] } },\n { \"price\": { \"$gte\": 100, \"$lte\": 1000 } },\n { \"tags\": { \"$all\": [\"premium\", \"sale\"] } },\n { \"rating\": { \"$exists\": true, \"$gt\": 4 } },\n { \"$or\": [\n { \"stock\": { \"$gt\": 0 } },\n { \"preorder\": true }\n ]}\n ]\n}";
|
|
313
|
+
declare const QDRANT_PROMPT = "When querying Qdrant, you can ONLY use the operators listed below. Any other operators will be rejected.\nImportant: Don't explain how to construct the filter - use the specified operators and fields to search the content and return relevant results.\nIf a user tries to give an explicit operator that is not supported, reject the filter entirely and let them know that the operator is not supported.\n\nBasic Comparison Operators:\n- $eq: Exact match (default when using field: value)\n Example: { \"category\": \"electronics\" }\n- $ne: Not equal\n Example: { \"category\": { \"$ne\": \"electronics\" } }\n- $gt: Greater than\n Example: { \"price\": { \"$gt\": 100 } }\n- $gte: Greater than or equal\n Example: { \"price\": { \"$gte\": 100 } }\n- $lt: Less than\n Example: { \"price\": { \"$lt\": 100 } }\n- $lte: Less than or equal\n Example: { \"price\": { \"$lte\": 100 } }\n\nArray Operators:\n- $in: Match any value in array\n Example: { \"category\": { \"$in\": [\"electronics\", \"books\"] } }\n- $nin: Does not match any value in array\n Example: { \"category\": { \"$nin\": [\"electronics\", \"books\"] } }\n\nLogical Operators:\n- $and: Logical AND (implicit when using multiple conditions)\n Example: { \"$and\": [{ \"price\": { \"$gt\": 100 } }, { \"category\": \"electronics\" }] }\n- $or: Logical OR\n Example: { \"$or\": [{ \"price\": { \"$lt\": 50 } }, { \"category\": \"books\" }] }\n- $not: Logical NOT\n Example: { \"$not\": { \"category\": \"electronics\" } }\n\nElement Operators:\n- $exists: Check if field exists\n Example: { \"rating\": { \"$exists\": true } }\n\nSpecial Operators:\n- $regex: Pattern matching\n Example: { \"name\": { \"$regex\": \"iphone.*\" } }\n- $count: Array length/value count\n Example: { \"tags\": { \"$count\": { \"$gt\": 2 } } }\n- $geo: Geographical filters (supports radius, box, polygon)\n Example: {\n \"location\": {\n \"$geo\": {\n \"type\": \"radius\",\n \"center\": { \"lat\": 52.5, \"lon\": 13.4 },\n \"radius\": 10000\n }\n }\n }\n- $hasId: Match specific document IDs\n Example: { \"$hasId\": [\"doc1\", \"doc2\"] }\n- $hasVector: Check vector existence\n Example: { \"$hasVector\": \"\" }\n- $datetime: RFC 3339 datetime range\n Example: {\n \"created_at\": {\n \"$datetime\": {\n \"range\": {\n \"gt\": \"2024-01-01T00:00:00Z\",\n \"lt\": \"2024-12-31T23:59:59Z\"\n }\n }\n }\n }\n- $null: Check for null values\n Example: { \"field\": { \"$null\": true } }\n- $empty: Check for empty values\n Example: { \"array\": { \"$empty\": true } }\n- $nested: Nested object filters\n Example: {\n \"items[]\": {\n \"$nested\": {\n \"price\": { \"$gt\": 100 },\n \"stock\": { \"$gt\": 0 }\n }\n }\n }\n\nRestrictions:\n- Only logical operators ($and, $or, $not) and collection operators ($hasId, $hasVector) can be used at the top level\n- All other operators must be used within a field condition\n Valid: { \"field\": { \"$gt\": 100 } }\n Valid: { \"$and\": [...] }\n Valid: { \"$hasId\": [...] }\n Invalid: { \"$gt\": 100 }\n- Nested fields are supported using dot notation\n- Array fields with nested objects use [] suffix: \"items[]\"\n- Geo filtering requires specific format for radius, box, or polygon\n- Datetime values must be in RFC 3339 format\n- Empty arrays in conditions are handled as empty values\n- Null values are handled with $null operator\n- Empty values are handled with $empty operator\n- $regex uses standard regex syntax\n- $count can only be used with numeric comparison operators\n- $nested requires an object with conditions\n- Logical operators must contain field conditions, not direct operators\n Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n Invalid: { \"$and\": [{ \"$gt\": 100 }] }\n- $not operator:\n - Must be an object\n - Cannot be empty\n - Can be used at field level or top level\n - Valid: { \"$not\": { \"field\": \"value\" } }\n - Valid: { \"field\": { \"$not\": { \"$eq\": \"value\" } } }\n- Other logical operators ($and, $or):\n - Can only be used at top level or nested within other logical operators\n - Can not be used on a field level, or be nested inside a field\n - Can not be used inside an operator\n - Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n - Valid: { \"$or\": [{ \"$and\": [{ \"field\": { \"$gt\": 100 } }] }] }\n - Invalid: { \"field\": { \"$and\": [{ \"$gt\": 100 }] } }\n - Invalid: { \"field\": { \"$or\": [{ \"$gt\": 100 }] } }\n - Invalid: { \"field\": { \"$gt\": { \"$and\": [{...}] } } }\nExample Complex Query:\n{\n \"$and\": [\n { \"category\": { \"$in\": [\"electronics\"] } },\n { \"price\": { \"$gt\": 100 } },\n { \"location\": {\n \"$geo\": {\n \"type\": \"radius\",\n \"center\": { \"lat\": 52.5, \"lon\": 13.4 },\n \"radius\": 5000\n }\n }},\n { \"items[]\": {\n \"$nested\": {\n \"price\": { \"$gt\": 50 },\n \"stock\": { \"$gt\": 0 }\n }\n }},\n { \"created_at\": {\n \"$datetime\": {\n \"range\": {\n \"gt\": \"2024-01-01T00:00:00Z\"\n }\n }\n }},\n { \"$or\": [\n { \"status\": { \"$ne\": \"discontinued\" } },\n { \"clearance\": true }\n ]}\n ]\n}";
|
|
314
|
+
declare const UPSTASH_PROMPT = "When querying Upstash Vector, you can ONLY use the operators listed below. Any other operators will be rejected.\nImportant: Don't explain how to construct the filter - use the specified operators and fields to search the content and return relevant results.\nIf a user tries to give an explicit operator that is not supported, reject the filter entirely and let them know that the operator is not supported.\n\nBasic Comparison Operators:\n- $eq: Exact match (default when using field: value)\n Example: { \"category\": \"electronics\" } or { \"category\": { \"$eq\": \"electronics\" } }\n- $ne: Not equal\n Example: { \"category\": { \"$ne\": \"electronics\" } }\n- $gt: Greater than\n Example: { \"price\": { \"$gt\": 100 } }\n- $gte: Greater than or equal\n Example: { \"price\": { \"$gte\": 100 } }\n- $lt: Less than\n Example: { \"price\": { \"$lt\": 100 } }\n- $lte: Less than or equal\n Example: { \"price\": { \"$lte\": 100 } }\n\nArray Operators:\n- $in: Match any value in array\n Example: { \"category\": { \"$in\": [\"electronics\", \"books\"] } }\n- $nin: Does not match any value in array\n Example: { \"category\": { \"$nin\": [\"electronics\", \"books\"] } }\n- $all: Matches all values in array\n Example: { \"tags\": { \"$all\": [\"premium\", \"new\"] } }\n\nLogical Operators:\n- $and: Logical AND (implicit when using multiple conditions)\n Example: { \"$and\": [{ \"price\": { \"$gt\": 100 } }, { \"category\": \"electronics\" }] }\n- $or: Logical OR\n Example: { \"$or\": [{ \"price\": { \"$lt\": 50 } }, { \"category\": \"books\" }] }\n- $not: Logical NOT\n Example: { \"$not\": { \"category\": \"electronics\" } }\n- $nor: Logical NOR\n Example: { \"$nor\": [{ \"price\": { \"$lt\": 50 } }, { \"category\": \"books\" }] }\n\nElement Operators:\n- $exists: Check if field exists\n Example: { \"rating\": { \"$exists\": true } }\n\nSpecial Operators:\n- $regex: Pattern matching using glob syntax (only as operator, not direct RegExp)\n Example: { \"name\": { \"$regex\": \"iphone*\" } }\n- $contains: Check if array/string contains value\n Example: { \"tags\": { \"$contains\": \"premium\" } }\n\nRestrictions:\n- Null/undefined values are not supported in any operator\n- Empty arrays are only supported in $in/$nin operators\n- Direct RegExp patterns are not supported, use $regex with glob syntax\n- Nested fields are supported using dot notation\n- Multiple conditions on same field are combined with AND\n- String values with quotes are automatically escaped\n- Only logical operators ($and, $or, $not, $nor) can be used at the top level\n- All other operators must be used within a field condition\n Valid: { \"field\": { \"$gt\": 100 } }\n Valid: { \"$and\": [...] }\n Invalid: { \"$gt\": 100 }\n- $regex uses glob syntax (*, ?) not standard regex patterns\n- $contains works on both arrays and string fields\n- Logical operators must contain field conditions, not direct operators\n Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n Invalid: { \"$and\": [{ \"$gt\": 100 }] }\n- $not operator:\n - Must be an object\n - Cannot be empty\n - Can be used at field level or top level\n - Valid: { \"$not\": { \"field\": \"value\" } }\n - Valid: { \"field\": { \"$not\": { \"$eq\": \"value\" } } }\n- Other logical operators ($and, $or, $nor):\n - Can only be used at top level or nested within other logical operators\n - Can not be used on a field level, or be nested inside a field\n - Can not be used inside an operator\n - Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n - Valid: { \"$or\": [{ \"$and\": [{ \"field\": { \"$gt\": 100 } }] }] }\n - Invalid: { \"field\": { \"$and\": [{ \"$gt\": 100 }] } }\n - Invalid: { \"field\": { \"$or\": [{ \"$gt\": 100 }] } }\n - Invalid: { \"field\": { \"$gt\": { \"$and\": [{...}] } } }\nExample Complex Query:\n{\n \"$and\": [\n { \"category\": { \"$in\": [\"electronics\", \"computers\"] } },\n { \"price\": { \"$gt\": 100, \"$lt\": 1000 } },\n { \"tags\": { \"$all\": [\"premium\", \"new\"] } },\n { \"name\": { \"$regex\": \"iphone*\" } },\n { \"description\": { \"$contains\": \"latest\" } },\n { \"$or\": [\n { \"brand\": \"Apple\" },\n { \"rating\": { \"$gte\": 4.5 } }\n ]}\n ]\n}";
|
|
315
|
+
declare const VECTORIZE_PROMPT = "When querying Vectorize, you can ONLY use the operators listed below. Any other operators will be rejected.\nImportant: Don't explain how to construct the filter - use the specified operators and fields to search the content and return relevant results.\nIf a user tries to give an explicit operator that is not supported, reject the filter entirely and let them know that the operator is not supported.\n\nBasic Comparison Operators:\n- $eq: Exact match (default when using field: value)\n Example: { \"category\": \"electronics\" }\n- $ne: Not equal\n Example: { \"category\": { \"$ne\": \"electronics\" } }\n- $gt: Greater than\n Example: { \"price\": { \"$gt\": 100 } }\n- $gte: Greater than or equal\n Example: { \"price\": { \"$gte\": 100 } }\n- $lt: Less than\n Example: { \"price\": { \"$lt\": 100 } }\n- $lte: Less than or equal\n Example: { \"price\": { \"$lte\": 100 } }\n\nArray Operators:\n- $in: Match any value in array\n Example: { \"category\": { \"$in\": [\"electronics\", \"books\"] } }\n- $nin: Does not match any value in array\n Example: { \"category\": { \"$nin\": [\"electronics\", \"books\"] } }\n\nRestrictions:\n- Regex patterns are not supported\n- Logical operators are not supported\n- Element operators are not supported\n- Fields must have a flat structure, as nested fields are not supported\n- Multiple conditions on the same field are supported\n- Empty arrays in $in/$nin will return no results\n- Filter keys cannot be longer than 512 characters\n- Filter keys cannot contain invalid characters ($, \", empty)\n- Filter size is limited to prevent oversized queries\n- Invalid types in operators return no results instead of throwing errors\n- Empty objects are accepted in filters\n- Metadata must use flat structure with dot notation (no nested objects)\n- Must explicitly create metadata indexes for filterable fields (limit 10 per index)\n- Can only effectively filter on indexed metadata fields\n- Metadata values can be strings, numbers, booleans, or homogeneous arrays\n- No operators can be used at the top level (no logical operators supported)\n- All operators must be used within a field condition\n Valid: { \"field\": { \"$gt\": 100 } }\n Invalid: { \"$gt\": 100 }\n Invalid: { \"$in\": [...] }\n\nExample Complex Query:\n{\n \"category\": { \"$in\": [\"electronics\", \"computers\"] },\n \"price\": { \"$gte\": 100, \"$lte\": 1000 },\n \"inStock\": true\n}";
|
|
316
|
+
|
|
317
|
+
declare const defaultTopK = "You MUST generate for each query:\n topK: number of results to return (REQUIRED) (Default: 10)\n - Generate topK based on exactly what user specifies\n - must be a valid number\n\n Notes: \n - If user provides a valid topK, use the topK provided\n - If user does not specify topK or provides an invalid topK, use default topK: 10\n";
|
|
318
|
+
declare const defaultFilter = "You MUST generate for each query:\n filter: query filter (REQUIRED) (Default: {})\n - Generate filter based on user's explicit query intent\n - Must be valid JSON string\n\n Notes: \n - If user provides a valid filter, use the filter provided\n - If user does not specify filter or provides an invalid filter, use default filter: {}\n";
|
|
319
|
+
declare const defaultVectorQueryDescription: (vectorStoreName: string, indexName: string) => string;
|
|
320
|
+
declare const defaultGraphRagDescription: (vectorStoreName: string, indexName: string) => string;
|
|
321
|
+
|
|
322
|
+
export { ASTRA_PROMPT, CHROMA_PROMPT, GraphRAG, LIBSQL_PROMPT, MDocument, PGVECTOR_PROMPT, PINECONE_PROMPT, QDRANT_PROMPT, type RerankConfig, type RerankResult, type RerankerFunctionOptions, type RerankerOptions, UPSTASH_PROMPT, VECTORIZE_PROMPT, createDocumentChunkerTool, createGraphRAGTool, createVectorQueryTool, defaultFilter, defaultGraphRagDescription, defaultTopK, defaultVectorQueryDescription, embed, embedMany, rerank };
|