@mastra/rag 0.0.0-commonjs-20250227130920

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.
Files changed (40) hide show
  1. package/.turbo/turbo-build.log +23 -0
  2. package/CHANGELOG.md +1151 -0
  3. package/LICENSE +44 -0
  4. package/README.md +26 -0
  5. package/dist/_tsup-dts-rollup.d.cts +620 -0
  6. package/dist/_tsup-dts-rollup.d.ts +620 -0
  7. package/dist/index.cjs +2524 -0
  8. package/dist/index.d.cts +22 -0
  9. package/dist/index.d.ts +22 -0
  10. package/dist/index.js +2505 -0
  11. package/docker-compose.yaml +22 -0
  12. package/eslint.config.js +6 -0
  13. package/package.json +72 -0
  14. package/src/document/document.test.ts +985 -0
  15. package/src/document/document.ts +281 -0
  16. package/src/document/index.ts +2 -0
  17. package/src/document/transformers/character.ts +279 -0
  18. package/src/document/transformers/html.ts +346 -0
  19. package/src/document/transformers/json.ts +265 -0
  20. package/src/document/transformers/latex.ts +19 -0
  21. package/src/document/transformers/markdown.ts +244 -0
  22. package/src/document/transformers/text.ts +134 -0
  23. package/src/document/transformers/token.ts +148 -0
  24. package/src/document/transformers/transformer.ts +5 -0
  25. package/src/document/types.ts +103 -0
  26. package/src/graph-rag/index.test.ts +235 -0
  27. package/src/graph-rag/index.ts +306 -0
  28. package/src/index.ts +6 -0
  29. package/src/rerank/index.test.ts +150 -0
  30. package/src/rerank/index.ts +154 -0
  31. package/src/tools/document-chunker.ts +30 -0
  32. package/src/tools/graph-rag.ts +117 -0
  33. package/src/tools/index.ts +3 -0
  34. package/src/tools/vector-query.ts +90 -0
  35. package/src/utils/default-settings.ts +33 -0
  36. package/src/utils/index.ts +2 -0
  37. package/src/utils/vector-prompts.ts +729 -0
  38. package/src/utils/vector-search.ts +41 -0
  39. package/tsconfig.json +5 -0
  40. package/vitest.config.ts +11 -0
@@ -0,0 +1,620 @@
1
+ import { createTool } from '@mastra/core/tools';
2
+ import { Document as Document_2 } from 'llamaindex';
3
+ import type { EmbeddingModel } from 'ai';
4
+ import type { KeywordExtractPrompt } from 'llamaindex';
5
+ import type { LanguageModelV1 } from 'ai';
6
+ import type { LLM } from 'llamaindex';
7
+ import type { MastraVector } from '@mastra/core/vector';
8
+ import type { QueryResult } from '@mastra/core/vector';
9
+ import type { QuestionExtractPrompt } from 'llamaindex';
10
+ import type { SummaryPrompt } from 'llamaindex';
11
+ import type { TiktokenEncoding } from 'js-tiktoken';
12
+ import type { TiktokenModel } from 'js-tiktoken';
13
+ import type { TitleCombinePrompt } from 'llamaindex';
14
+ import type { TitleExtractorPrompt } from 'llamaindex';
15
+
16
+ /**
17
+ * Vector store specific prompts that detail supported operators and examples.
18
+ * These prompts help users construct valid filters for each vector store.
19
+ */
20
+ 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}";
21
+ export { ASTRA_PROMPT }
22
+ export { ASTRA_PROMPT as ASTRA_PROMPT_alias_1 }
23
+
24
+ export declare class CharacterTransformer extends TextTransformer {
25
+ protected separator: string;
26
+ protected isSeparatorRegex: boolean;
27
+ constructor({ separator, isSeparatorRegex, options, }: {
28
+ separator?: string;
29
+ isSeparatorRegex?: boolean;
30
+ options?: {
31
+ size?: number;
32
+ overlap?: number;
33
+ lengthFunction?: (text: string) => number;
34
+ keepSeparator?: boolean | 'start' | 'end';
35
+ addStartIndex?: boolean;
36
+ stripWhitespace?: boolean;
37
+ };
38
+ });
39
+ splitText({ text }: {
40
+ text: string;
41
+ }): string[];
42
+ private __splitChunk;
43
+ }
44
+
45
+ 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}";
46
+ export { CHROMA_PROMPT }
47
+ export { CHROMA_PROMPT as CHROMA_PROMPT_alias_1 }
48
+
49
+ declare type ChunkOptions = {
50
+ headers?: [string, string][];
51
+ returnEachLine?: boolean;
52
+ sections?: [string, string][];
53
+ separator?: string;
54
+ separators?: string[];
55
+ isSeparatorRegex?: boolean;
56
+ size?: number;
57
+ maxSize?: number;
58
+ minSize?: number;
59
+ overlap?: number;
60
+ lengthFunction?: (text: string) => number;
61
+ keepSeparator?: boolean | 'start' | 'end';
62
+ addStartIndex?: boolean;
63
+ stripWhitespace?: boolean;
64
+ language?: Language;
65
+ ensureAscii?: boolean;
66
+ convertLists?: boolean;
67
+ encodingName?: TiktokenEncoding;
68
+ modelName?: TiktokenModel;
69
+ allowedSpecial?: Set<string> | 'all';
70
+ disallowedSpecial?: Set<string> | 'all';
71
+ stripHeaders?: boolean;
72
+ };
73
+ export { ChunkOptions }
74
+ export { ChunkOptions as ChunkOptions_alias_1 }
75
+
76
+ declare interface ChunkParams extends ChunkOptions {
77
+ strategy?: ChunkStrategy;
78
+ extract?: ExtractParams;
79
+ }
80
+ export { ChunkParams }
81
+ export { ChunkParams as ChunkParams_alias_1 }
82
+
83
+ declare type ChunkStrategy = 'recursive' | 'character' | 'token' | 'markdown' | 'html' | 'json' | 'latex';
84
+ export { ChunkStrategy }
85
+ export { ChunkStrategy as ChunkStrategy_alias_1 }
86
+
87
+ declare const createDocumentChunkerTool: ({ doc, params, }: {
88
+ doc: MDocument;
89
+ params?: ChunkParams;
90
+ }) => ReturnType<typeof createTool>;
91
+ export { createDocumentChunkerTool }
92
+ export { createDocumentChunkerTool as createDocumentChunkerTool_alias_1 }
93
+ export { createDocumentChunkerTool as createDocumentChunkerTool_alias_2 }
94
+
95
+ declare const createGraphRAGTool: ({ vectorStoreName, indexName, model, enableFilter, graphOptions, id, description, }: {
96
+ vectorStoreName: string;
97
+ indexName: string;
98
+ model: EmbeddingModel<string>;
99
+ enableFilter?: boolean;
100
+ graphOptions?: {
101
+ dimension?: number;
102
+ randomWalkSteps?: number;
103
+ restartProb?: number;
104
+ threshold?: number;
105
+ };
106
+ id?: string;
107
+ description?: string;
108
+ }) => ReturnType<typeof createTool>;
109
+ export { createGraphRAGTool }
110
+ export { createGraphRAGTool as createGraphRAGTool_alias_1 }
111
+ export { createGraphRAGTool as createGraphRAGTool_alias_2 }
112
+
113
+ declare const createVectorQueryTool: ({ vectorStoreName, indexName, model, enableFilter, reranker, id, description, }: {
114
+ vectorStoreName: string;
115
+ indexName: string;
116
+ model: EmbeddingModel<string>;
117
+ enableFilter?: boolean;
118
+ reranker?: RerankConfig;
119
+ id?: string;
120
+ description?: string;
121
+ }) => ReturnType<typeof createTool>;
122
+ export { createVectorQueryTool }
123
+ export { createVectorQueryTool as createVectorQueryTool_alias_1 }
124
+ export { createVectorQueryTool as createVectorQueryTool_alias_2 }
125
+
126
+ 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";
127
+ export { defaultFilter }
128
+ export { defaultFilter as defaultFilter_alias_1 }
129
+ export { defaultFilter as defaultFilter_alias_2 }
130
+
131
+ declare const defaultGraphRagDescription: (vectorStoreName: string, indexName: string) => string;
132
+ export { defaultGraphRagDescription }
133
+ export { defaultGraphRagDescription as defaultGraphRagDescription_alias_1 }
134
+ export { defaultGraphRagDescription as defaultGraphRagDescription_alias_2 }
135
+
136
+ 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";
137
+ export { defaultTopK }
138
+ export { defaultTopK as defaultTopK_alias_1 }
139
+ export { defaultTopK as defaultTopK_alias_2 }
140
+
141
+ declare const defaultVectorQueryDescription: (vectorStoreName: string, indexName: string) => string;
142
+ export { defaultVectorQueryDescription }
143
+ export { defaultVectorQueryDescription as defaultVectorQueryDescription_alias_1 }
144
+ export { defaultVectorQueryDescription as defaultVectorQueryDescription_alias_2 }
145
+
146
+ declare type ExtractParams = {
147
+ title?: TitleExtractorsArgs | boolean;
148
+ summary?: SummaryExtractArgs | boolean;
149
+ questions?: QuestionAnswerExtractArgs | boolean;
150
+ keywords?: boolean | Record<string, any>;
151
+ };
152
+ export { ExtractParams }
153
+ export { ExtractParams as ExtractParams_alias_1 }
154
+
155
+ export declare interface GraphChunk {
156
+ text: string;
157
+ metadata: Record<string, any>;
158
+ }
159
+
160
+ export declare interface GraphEdge {
161
+ source: string;
162
+ target: string;
163
+ weight: number;
164
+ type: SupportedEdgeType;
165
+ }
166
+
167
+ export declare interface GraphEmbedding {
168
+ vector: number[];
169
+ }
170
+
171
+ export declare interface GraphNode {
172
+ id: string;
173
+ content: string;
174
+ embedding?: number[];
175
+ metadata?: Record<string, any>;
176
+ }
177
+
178
+ declare class GraphRAG {
179
+ private nodes;
180
+ private edges;
181
+ private dimension;
182
+ private threshold;
183
+ constructor(dimension?: number, threshold?: number);
184
+ addNode(node: GraphNode): void;
185
+ addEdge(edge: GraphEdge): void;
186
+ getNodes(): GraphNode[];
187
+ getEdges(): GraphEdge[];
188
+ getEdgesByType(type: string): GraphEdge[];
189
+ clear(): void;
190
+ updateNodeContent(id: string, newContent: string): void;
191
+ private getNeighbors;
192
+ private cosineSimilarity;
193
+ createGraph(chunks: GraphChunk[], embeddings: GraphEmbedding[]): void;
194
+ private selectWeightedNeighbor;
195
+ private randomWalkWithRestart;
196
+ query({ query, topK, randomWalkSteps, restartProb, }: {
197
+ query: number[];
198
+ topK?: number;
199
+ randomWalkSteps?: number;
200
+ restartProb?: number;
201
+ }): RankedNode[];
202
+ }
203
+ export { GraphRAG }
204
+ export { GraphRAG as GraphRAG_alias_1 }
205
+
206
+ export declare class HTMLHeaderTransformer {
207
+ private headersToSplitOn;
208
+ private returnEachElement;
209
+ constructor(headersToSplitOn: [string, string][], returnEachElement?: boolean);
210
+ splitText({ text }: {
211
+ text: string;
212
+ }): Document_2[];
213
+ private getXPath;
214
+ private getTextContent;
215
+ private aggregateElementsToChunks;
216
+ createDocuments(texts: string[], metadatas?: Record<string, any>[]): Document_2[];
217
+ transformDocuments(documents: Document_2[]): Document_2[];
218
+ }
219
+
220
+ export declare class HTMLSectionTransformer {
221
+ private headersToSplitOn;
222
+ private options;
223
+ constructor(headersToSplitOn: [string, string][], options?: Record<string, any>);
224
+ splitText(text: string): Document_2[];
225
+ private getXPath;
226
+ private splitHtmlByHeaders;
227
+ splitDocuments(documents: Document_2[]): Promise<Document_2[]>;
228
+ createDocuments(texts: string[], metadatas?: Record<string, any>[]): Document_2[];
229
+ transformDocuments(documents: Document_2[]): Document_2[];
230
+ }
231
+
232
+ declare type KeywordExtractArgs = {
233
+ llm?: LLM;
234
+ keywords?: number;
235
+ promptTemplate?: KeywordExtractPrompt['template'];
236
+ };
237
+ export { KeywordExtractArgs }
238
+ export { KeywordExtractArgs as KeywordExtractArgs_alias_1 }
239
+
240
+ declare enum Language {
241
+ CPP = "cpp",
242
+ GO = "go",
243
+ JAVA = "java",
244
+ KOTLIN = "kotlin",
245
+ JS = "js",
246
+ TS = "ts",
247
+ PHP = "php",
248
+ PROTO = "proto",
249
+ PYTHON = "python",
250
+ RST = "rst",
251
+ RUBY = "ruby",
252
+ RUST = "rust",
253
+ SCALA = "scala",
254
+ SWIFT = "swift",
255
+ MARKDOWN = "markdown",
256
+ LATEX = "latex",
257
+ HTML = "html",
258
+ SOL = "sol",
259
+ CSHARP = "csharp",
260
+ COBOL = "cobol",
261
+ C = "c",
262
+ LUA = "lua",
263
+ PERL = "perl",
264
+ HASKELL = "haskell",
265
+ ELIXIR = "elixir",
266
+ POWERSHELL = "powershell"
267
+ }
268
+ export { Language }
269
+ export { Language as Language_alias_1 }
270
+
271
+ export declare class LatexTransformer extends RecursiveCharacterTransformer {
272
+ constructor(options?: {
273
+ size?: number;
274
+ overlap?: number;
275
+ lengthFunction?: (text: string) => number;
276
+ keepSeparator?: boolean | 'start' | 'end';
277
+ addStartIndex?: boolean;
278
+ stripWhitespace?: boolean;
279
+ });
280
+ }
281
+
282
+ 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}";
283
+ export { LIBSQL_PROMPT }
284
+ export { LIBSQL_PROMPT as LIBSQL_PROMPT_alias_1 }
285
+
286
+ export declare class MarkdownHeaderTransformer {
287
+ private headersToSplitOn;
288
+ private returnEachLine;
289
+ private stripHeaders;
290
+ constructor(headersToSplitOn: [string, string][], returnEachLine?: boolean, stripHeaders?: boolean);
291
+ private aggregateLinesToChunks;
292
+ splitText({ text }: {
293
+ text: string;
294
+ }): Document_2[];
295
+ createDocuments(texts: string[], metadatas?: Record<string, any>[]): Document_2[];
296
+ transformDocuments(documents: Document_2[]): Document_2[];
297
+ }
298
+
299
+ export declare class MarkdownTransformer extends RecursiveCharacterTransformer {
300
+ constructor(options?: {
301
+ chunkSize?: number;
302
+ chunkOverlap?: number;
303
+ lengthFunction?: (text: string) => number;
304
+ keepSeparator?: boolean | 'start' | 'end';
305
+ addStartIndex?: boolean;
306
+ stripWhitespace?: boolean;
307
+ });
308
+ }
309
+
310
+ declare class MDocument {
311
+ private chunks;
312
+ private type;
313
+ constructor({ docs, type }: {
314
+ docs: {
315
+ text: string;
316
+ metadata?: Record<string, any>;
317
+ }[];
318
+ type: string;
319
+ });
320
+ extractMetadata({ title, summary, questions, keywords }: ExtractParams): Promise<MDocument>;
321
+ static fromText(text: string, metadata?: Record<string, any>): MDocument;
322
+ static fromHTML(html: string, metadata?: Record<string, any>): MDocument;
323
+ static fromMarkdown(markdown: string, metadata?: Record<string, any>): MDocument;
324
+ static fromJSON(jsonString: string, metadata?: Record<string, any>): MDocument;
325
+ private defaultStrategy;
326
+ private chunkBy;
327
+ chunkRecursive(options?: ChunkOptions): Promise<void>;
328
+ chunkCharacter(options?: ChunkOptions): Promise<void>;
329
+ chunkHTML(options?: ChunkOptions): Promise<void>;
330
+ chunkJSON(options?: ChunkOptions): Promise<void>;
331
+ chunkLatex(options?: ChunkOptions): Promise<void>;
332
+ chunkToken(options?: ChunkOptions): Promise<void>;
333
+ chunkMarkdown(options?: ChunkOptions): Promise<void>;
334
+ chunk(params?: ChunkParams): Promise<Document_2[]>;
335
+ getDocs(): Document_2[];
336
+ getText(): string[];
337
+ getMetadata(): Record<string, any>[];
338
+ }
339
+ export { MDocument }
340
+ export { MDocument as MDocument_alias_1 }
341
+ export { MDocument as MDocument_alias_2 }
342
+
343
+ 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}";
344
+ export { PGVECTOR_PROMPT }
345
+ export { PGVECTOR_PROMPT as PGVECTOR_PROMPT_alias_1 }
346
+
347
+ 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}";
348
+ export { PINECONE_PROMPT }
349
+ export { PINECONE_PROMPT as PINECONE_PROMPT_alias_1 }
350
+
351
+ 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}";
352
+ export { QDRANT_PROMPT }
353
+ export { QDRANT_PROMPT as QDRANT_PROMPT_alias_1 }
354
+
355
+ declare type QuestionAnswerExtractArgs = {
356
+ llm?: LLM;
357
+ questions?: number;
358
+ promptTemplate?: QuestionExtractPrompt['template'];
359
+ embeddingOnly?: boolean;
360
+ };
361
+ export { QuestionAnswerExtractArgs }
362
+ export { QuestionAnswerExtractArgs as QuestionAnswerExtractArgs_alias_1 }
363
+
364
+ declare interface RankedNode extends GraphNode {
365
+ score: number;
366
+ }
367
+
368
+ export declare class RecursiveCharacterTransformer extends TextTransformer {
369
+ protected separators: string[];
370
+ protected isSeparatorRegex: boolean;
371
+ constructor({ separators, isSeparatorRegex, options, }: {
372
+ separators?: string[];
373
+ isSeparatorRegex?: boolean;
374
+ options?: ChunkOptions;
375
+ });
376
+ private _splitText;
377
+ splitText({ text }: {
378
+ text: string;
379
+ }): string[];
380
+ static fromLanguage(language: Language, options?: {
381
+ size?: number;
382
+ chunkOverlap?: number;
383
+ lengthFunction?: (text: string) => number;
384
+ keepSeparator?: boolean | 'start' | 'end';
385
+ addStartIndex?: boolean;
386
+ stripWhitespace?: boolean;
387
+ }): RecursiveCharacterTransformer;
388
+ static getSeparatorsForLanguage(language: Language): string[];
389
+ }
390
+
391
+ export declare class RecursiveJsonTransformer {
392
+ private maxSize;
393
+ private minSize;
394
+ constructor({ maxSize, minSize }: {
395
+ maxSize: number;
396
+ minSize?: number;
397
+ });
398
+ private static jsonSize;
399
+ /**
400
+ * Transform JSON data while handling circular references
401
+ */
402
+ transform(data: Record<string, any>): Record<string, any>;
403
+ /**
404
+ * Set a value in a nested dictionary based on the given path
405
+ */
406
+ private static setNestedDict;
407
+ /**
408
+ * Convert lists in the JSON structure to dictionaries with index-based keys
409
+ */
410
+ private listToDictPreprocessing;
411
+ /**
412
+ * Split json into maximum size dictionaries while preserving structure
413
+ */
414
+ private jsonSplit;
415
+ /**
416
+ * Splits JSON into a list of JSON chunks
417
+ */
418
+ splitJson({ jsonData, convertLists, }: {
419
+ jsonData: Record<string, any>;
420
+ convertLists?: boolean;
421
+ }): Record<string, any>[];
422
+ private escapeNonAscii;
423
+ /**
424
+ * Splits JSON into a list of JSON formatted strings
425
+ */
426
+ splitText({ jsonData, convertLists, ensureAscii, }: {
427
+ jsonData: Record<string, any>;
428
+ convertLists?: boolean;
429
+ ensureAscii?: boolean;
430
+ }): string[];
431
+ /**
432
+ * Create documents from a list of json objects
433
+ */
434
+ createDocuments({ texts, convertLists, ensureAscii, metadatas, }: {
435
+ texts: string[];
436
+ convertLists?: boolean;
437
+ ensureAscii?: boolean;
438
+ metadatas?: Record<string, any>[];
439
+ }): Document_2[];
440
+ transformDocuments({ ensureAscii, documents, convertLists, }: {
441
+ ensureAscii?: boolean;
442
+ convertLists?: boolean;
443
+ documents: Document_2[];
444
+ }): Document_2[];
445
+ }
446
+
447
+ declare function rerank(results: QueryResult[], query: string, model: LanguageModelV1, options: RerankerFunctionOptions): Promise<RerankResult[]>;
448
+ export { rerank }
449
+ export { rerank as rerank_alias_1 }
450
+
451
+ declare interface RerankConfig {
452
+ options?: RerankerOptions;
453
+ model: LanguageModelV1;
454
+ }
455
+ export { RerankConfig }
456
+ export { RerankConfig as RerankConfig_alias_1 }
457
+
458
+ declare interface RerankerFunctionOptions {
459
+ weights?: WeightConfig;
460
+ queryEmbedding?: number[];
461
+ topK?: number;
462
+ }
463
+ export { RerankerFunctionOptions }
464
+ export { RerankerFunctionOptions as RerankerFunctionOptions_alias_1 }
465
+
466
+ declare interface RerankerOptions {
467
+ weights?: WeightConfig;
468
+ topK?: number;
469
+ }
470
+ export { RerankerOptions }
471
+ export { RerankerOptions as RerankerOptions_alias_1 }
472
+
473
+ declare interface RerankResult {
474
+ result: QueryResult;
475
+ score: number;
476
+ details: ScoringDetails;
477
+ }
478
+ export { RerankResult }
479
+ export { RerankResult as RerankResult_alias_1 }
480
+
481
+ declare interface ScoringDetails {
482
+ semantic: number;
483
+ vector: number;
484
+ position: number;
485
+ queryAnalysis?: {
486
+ magnitude: number;
487
+ dominantFeatures: number[];
488
+ };
489
+ }
490
+
491
+ export declare function splitTextOnTokens({ text, tokenizer }: {
492
+ text: string;
493
+ tokenizer: Tokenizer;
494
+ }): string[];
495
+
496
+ declare type SummaryExtractArgs = {
497
+ llm?: LLM;
498
+ summaries?: string[];
499
+ promptTemplate?: SummaryPrompt['template'];
500
+ };
501
+ export { SummaryExtractArgs }
502
+ export { SummaryExtractArgs as SummaryExtractArgs_alias_1 }
503
+
504
+ /**
505
+ * TODO: GraphRAG Enhancements
506
+ * - Add support for more edge types (sequential, hierarchical, citation, etc)
507
+ * - Allow for custom edge types
508
+ * - Utilize metadata for richer connections
509
+ * - Improve graph traversal and querying using types
510
+ */
511
+ declare type SupportedEdgeType = 'semantic';
512
+
513
+ export declare abstract class TextTransformer implements Transformer_2 {
514
+ protected size: number;
515
+ protected overlap: number;
516
+ protected lengthFunction: (text: string) => number;
517
+ protected keepSeparator: boolean | 'start' | 'end';
518
+ protected addStartIndex: boolean;
519
+ protected stripWhitespace: boolean;
520
+ constructor({ size, overlap, lengthFunction, keepSeparator, addStartIndex, stripWhitespace, }: ChunkOptions);
521
+ setAddStartIndex(value: boolean): void;
522
+ abstract splitText({ text }: {
523
+ text: string;
524
+ }): string[];
525
+ createDocuments(texts: string[], metadatas?: Record<string, any>[]): Document_2[];
526
+ splitDocuments(documents: Document_2[]): Document_2[];
527
+ transformDocuments(documents: Document_2[]): Document_2[];
528
+ protected joinDocs(docs: string[], separator: string): string | null;
529
+ protected mergeSplits(splits: string[], separator: string): string[];
530
+ }
531
+
532
+ declare type TitleExtractorsArgs = {
533
+ llm?: LLM;
534
+ nodes?: number;
535
+ nodeTemplate?: TitleExtractorPrompt['template'];
536
+ combineTemplate?: TitleCombinePrompt['template'];
537
+ };
538
+ export { TitleExtractorsArgs }
539
+ export { TitleExtractorsArgs as TitleExtractorsArgs_alias_1 }
540
+
541
+ declare interface Tokenizer {
542
+ overlap: number;
543
+ tokensPerChunk: number;
544
+ decode: (tokens: number[]) => string;
545
+ encode: (text: string) => number[];
546
+ }
547
+
548
+ export declare class TokenTransformer extends TextTransformer {
549
+ private tokenizer;
550
+ private allowedSpecial;
551
+ private disallowedSpecial;
552
+ constructor({ encodingName, modelName, allowedSpecial, disallowedSpecial, options, }: {
553
+ encodingName: TiktokenEncoding;
554
+ modelName?: TiktokenModel;
555
+ allowedSpecial?: Set<string> | 'all';
556
+ disallowedSpecial?: Set<string> | 'all';
557
+ options: {
558
+ size?: number;
559
+ overlap?: number;
560
+ lengthFunction?: (text: string) => number;
561
+ keepSeparator?: boolean | 'start' | 'end';
562
+ addStartIndex?: boolean;
563
+ stripWhitespace?: boolean;
564
+ };
565
+ });
566
+ splitText({ text }: {
567
+ text: string;
568
+ }): string[];
569
+ static fromTikToken({ encodingName, modelName, options, }: {
570
+ encodingName?: TiktokenEncoding;
571
+ modelName?: TiktokenModel;
572
+ options?: {
573
+ size?: number;
574
+ overlap?: number;
575
+ allowedSpecial?: Set<string> | 'all';
576
+ disallowedSpecial?: Set<string> | 'all';
577
+ };
578
+ }): TokenTransformer;
579
+ }
580
+
581
+ declare interface Transformer_2 {
582
+ transformDocuments(documents: Document_2[]): Document_2[];
583
+ }
584
+ export { Transformer_2 as Transformer }
585
+
586
+ 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}";
587
+ export { UPSTASH_PROMPT }
588
+ export { UPSTASH_PROMPT as UPSTASH_PROMPT_alias_1 }
589
+
590
+ 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}";
591
+ export { VECTORIZE_PROMPT }
592
+ export { VECTORIZE_PROMPT as VECTORIZE_PROMPT_alias_1 }
593
+
594
+ declare const vectorQuerySearch: ({ indexName, vectorStore, queryText, model, queryFilter, topK, includeVectors, maxRetries, }: VectorQuerySearchParams) => Promise<VectorQuerySearchResult>;
595
+ export { vectorQuerySearch }
596
+ export { vectorQuerySearch as vectorQuerySearch_alias_1 }
597
+
598
+ declare interface VectorQuerySearchParams {
599
+ indexName: string;
600
+ vectorStore: MastraVector;
601
+ queryText: string;
602
+ model: EmbeddingModel<string>;
603
+ queryFilter?: any;
604
+ topK: number;
605
+ includeVectors?: boolean;
606
+ maxRetries?: number;
607
+ }
608
+
609
+ declare interface VectorQuerySearchResult {
610
+ results: QueryResult[];
611
+ queryEmbedding: number[];
612
+ }
613
+
614
+ declare type WeightConfig = {
615
+ semantic?: number;
616
+ vector?: number;
617
+ position?: number;
618
+ };
619
+
620
+ export { }