@mastra/rag 0.1.20-alpha.1 → 0.1.20-alpha.3
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/.turbo/turbo-build.log +7 -7
- package/CHANGELOG.md +17 -0
- package/dist/_tsup-dts-rollup.d.cts +4 -0
- package/dist/_tsup-dts-rollup.d.ts +4 -0
- package/dist/index.cjs +97 -0
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +97 -1
- package/package.json +2 -2
- package/src/utils/vector-prompts.ts +85 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
|
|
2
|
-
> @mastra/rag@0.1.20-alpha.
|
|
2
|
+
> @mastra/rag@0.1.20-alpha.3 build /home/runner/work/mastra/mastra/packages/rag
|
|
3
3
|
> tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake=smallest --splitting
|
|
4
4
|
|
|
5
5
|
[34mCLI[39m Building entry: src/index.ts
|
|
6
6
|
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
7
7
|
[34mCLI[39m tsup v8.4.0
|
|
8
8
|
[34mTSC[39m Build start
|
|
9
|
-
[32mTSC[39m ⚡️ Build success in
|
|
9
|
+
[32mTSC[39m ⚡️ Build success in 15036ms
|
|
10
10
|
[34mDTS[39m Build start
|
|
11
11
|
[34mCLI[39m Target: es2022
|
|
12
12
|
Analysis will use the bundled TypeScript version 5.8.2
|
|
13
13
|
[36mWriting package typings: /home/runner/work/mastra/mastra/packages/rag/dist/_tsup-dts-rollup.d.ts[39m
|
|
14
14
|
Analysis will use the bundled TypeScript version 5.8.2
|
|
15
15
|
[36mWriting package typings: /home/runner/work/mastra/mastra/packages/rag/dist/_tsup-dts-rollup.d.cts[39m
|
|
16
|
-
[32mDTS[39m ⚡️ Build success in
|
|
16
|
+
[32mDTS[39m ⚡️ Build success in 12853ms
|
|
17
17
|
[34mCLI[39m Cleaning output folder
|
|
18
18
|
[34mESM[39m Build start
|
|
19
19
|
[34mCJS[39m Build start
|
|
20
|
-
[
|
|
21
|
-
[
|
|
22
|
-
[
|
|
23
|
-
[
|
|
20
|
+
[32mCJS[39m [1mdist/index.cjs [22m[32m237.80 KB[39m
|
|
21
|
+
[32mCJS[39m ⚡️ Build success in 4424ms
|
|
22
|
+
[32mESM[39m [1mdist/index.js [22m[32m236.10 KB[39m
|
|
23
|
+
[32mESM[39m ⚡️ Build success in 4424ms
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @mastra/rag
|
|
2
2
|
|
|
3
|
+
## 0.1.20-alpha.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- c4c6f04: added and updated docs for mongodb
|
|
8
|
+
- Updated dependencies [6262bd5]
|
|
9
|
+
- @mastra/core@0.9.1-alpha.3
|
|
10
|
+
|
|
11
|
+
## 0.1.20-alpha.2
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Updated dependencies [405b63d]
|
|
16
|
+
- Updated dependencies [61e92f5]
|
|
17
|
+
- Updated dependencies [c71013a]
|
|
18
|
+
- @mastra/core@0.9.1-alpha.2
|
|
19
|
+
|
|
3
20
|
## 0.1.20-alpha.1
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
|
@@ -518,6 +518,10 @@ declare type Metadata = Record<string, any>;
|
|
|
518
518
|
export { Metadata }
|
|
519
519
|
export { Metadata as Metadata_alias_1 }
|
|
520
520
|
|
|
521
|
+
declare const MONGODB_PROMPT = "When querying MongoDB, 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 by criteria\n Example: { \"scores\": { \"$elemMatch\": { \"$gt\": 80 } } }\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: { \"field\": { \"$not\": { \"$eq\": \"value\" } } }\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: Regular expression match\n Example: { \"title\": { \"$regex\": \"^laptop\", \"$options\": \"i\" } }\n- $size: Array length check\n Example: { \"tags\": { \"$size\": 2 } }\n\nUsage Notes:\n- You can use both 'filter' (for metadata fields) and 'documentFilter' (for document content fields).\n- Nested fields are supported using dot notation (e.g., \"metadata.author.name\").\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- All logical operators ($and, $or, $not, $nor) can be used at the top level or nested.\n- All other operators must be used within a field condition.\n Valid: { \"field\": { \"$gt\": 100 } }\n Valid: { \"$and\": [...] }\n Invalid: { \"$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- Logical operators must contain field conditions, not direct operators\n Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n Invalid: { \"$and\": [{ \"$gt\": 100 }] }\n- Regex uses standard MongoDB regex syntax (with optional $options).\n- Metadata values can be strings, numbers, booleans, or arrays.\n- Metadata and document fields can be filtered in the same query.\n\nExample Complex Query:\n{\n \"category\": { \"$in\": [\"electronics\", \"computers\"] },\n \"price\": { \"$gte\": 100, \"$lte\": 1000 },\n \"inStock\": true,\n \"title\": { \"$regex\": \"laptop\", \"$options\": \"i\" },\n \"$or\": [\n { \"brand\": \"Apple\" },\n { \"rating\": { \"$gte\": 4.5 } }\n ]\n}\n";
|
|
522
|
+
export { MONGODB_PROMPT }
|
|
523
|
+
export { MONGODB_PROMPT as MONGODB_PROMPT_alias_1 }
|
|
524
|
+
|
|
521
525
|
declare enum NodeRelationship {
|
|
522
526
|
SOURCE = "SOURCE",
|
|
523
527
|
PREVIOUS = "PREVIOUS",
|
|
@@ -518,6 +518,10 @@ declare type Metadata = Record<string, any>;
|
|
|
518
518
|
export { Metadata }
|
|
519
519
|
export { Metadata as Metadata_alias_1 }
|
|
520
520
|
|
|
521
|
+
declare const MONGODB_PROMPT = "When querying MongoDB, 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 by criteria\n Example: { \"scores\": { \"$elemMatch\": { \"$gt\": 80 } } }\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: { \"field\": { \"$not\": { \"$eq\": \"value\" } } }\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: Regular expression match\n Example: { \"title\": { \"$regex\": \"^laptop\", \"$options\": \"i\" } }\n- $size: Array length check\n Example: { \"tags\": { \"$size\": 2 } }\n\nUsage Notes:\n- You can use both 'filter' (for metadata fields) and 'documentFilter' (for document content fields).\n- Nested fields are supported using dot notation (e.g., \"metadata.author.name\").\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- All logical operators ($and, $or, $not, $nor) can be used at the top level or nested.\n- All other operators must be used within a field condition.\n Valid: { \"field\": { \"$gt\": 100 } }\n Valid: { \"$and\": [...] }\n Invalid: { \"$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- Logical operators must contain field conditions, not direct operators\n Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n Invalid: { \"$and\": [{ \"$gt\": 100 }] }\n- Regex uses standard MongoDB regex syntax (with optional $options).\n- Metadata values can be strings, numbers, booleans, or arrays.\n- Metadata and document fields can be filtered in the same query.\n\nExample Complex Query:\n{\n \"category\": { \"$in\": [\"electronics\", \"computers\"] },\n \"price\": { \"$gte\": 100, \"$lte\": 1000 },\n \"inStock\": true,\n \"title\": { \"$regex\": \"laptop\", \"$options\": \"i\" },\n \"$or\": [\n { \"brand\": \"Apple\" },\n { \"rating\": { \"$gte\": 4.5 } }\n ]\n}\n";
|
|
522
|
+
export { MONGODB_PROMPT }
|
|
523
|
+
export { MONGODB_PROMPT as MONGODB_PROMPT_alias_1 }
|
|
524
|
+
|
|
521
525
|
declare enum NodeRelationship {
|
|
522
526
|
SOURCE = "SOURCE",
|
|
523
527
|
PREVIOUS = "PREVIOUS",
|
package/dist/index.cjs
CHANGED
|
@@ -2309,11 +2309,23 @@ var reasoningModels = {
|
|
|
2309
2309
|
"o1-preview-2024-09-12": {
|
|
2310
2310
|
systemMessageMode: "remove"
|
|
2311
2311
|
},
|
|
2312
|
+
o3: {
|
|
2313
|
+
systemMessageMode: "developer"
|
|
2314
|
+
},
|
|
2315
|
+
"o3-2025-04-16": {
|
|
2316
|
+
systemMessageMode: "developer"
|
|
2317
|
+
},
|
|
2312
2318
|
"o3-mini": {
|
|
2313
2319
|
systemMessageMode: "developer"
|
|
2314
2320
|
},
|
|
2315
2321
|
"o3-mini-2025-01-31": {
|
|
2316
2322
|
systemMessageMode: "developer"
|
|
2323
|
+
},
|
|
2324
|
+
"o4-mini": {
|
|
2325
|
+
systemMessageMode: "developer"
|
|
2326
|
+
},
|
|
2327
|
+
"o4-mini-2025-04-16": {
|
|
2328
|
+
systemMessageMode: "developer"
|
|
2317
2329
|
}
|
|
2318
2330
|
};
|
|
2319
2331
|
function convertToOpenAICompletionPrompt({
|
|
@@ -7213,12 +7225,97 @@ Example Complex Query:
|
|
|
7213
7225
|
"price": { "$gte": 100, "$lte": 1000 },
|
|
7214
7226
|
"inStock": true
|
|
7215
7227
|
}`;
|
|
7228
|
+
var MONGODB_PROMPT = `When querying MongoDB, you can ONLY use the operators listed below. Any other operators will be rejected.
|
|
7229
|
+
Important: Don't explain how to construct the filter - use the specified operators and fields to search the content and return relevant results.
|
|
7230
|
+
If 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.
|
|
7231
|
+
|
|
7232
|
+
Basic Comparison Operators:
|
|
7233
|
+
- $eq: Exact match (default when using field: value)
|
|
7234
|
+
Example: { "category": "electronics" }
|
|
7235
|
+
- $ne: Not equal
|
|
7236
|
+
Example: { "category": { "$ne": "electronics" } }
|
|
7237
|
+
- $gt: Greater than
|
|
7238
|
+
Example: { "price": { "$gt": 100 } }
|
|
7239
|
+
- $gte: Greater than or equal
|
|
7240
|
+
Example: { "price": { "$gte": 100 } }
|
|
7241
|
+
- $lt: Less than
|
|
7242
|
+
Example: { "price": { "$lt": 100 } }
|
|
7243
|
+
- $lte: Less than or equal
|
|
7244
|
+
Example: { "price": { "$lte": 100 } }
|
|
7245
|
+
|
|
7246
|
+
Array Operators:
|
|
7247
|
+
- $in: Match any value in array
|
|
7248
|
+
Example: { "category": { "$in": ["electronics", "books"] } }
|
|
7249
|
+
- $nin: Does not match any value in array
|
|
7250
|
+
Example: { "category": { "$nin": ["electronics", "books"] } }
|
|
7251
|
+
- $all: Match all values in array
|
|
7252
|
+
Example: { "tags": { "$all": ["premium", "sale"] } }
|
|
7253
|
+
- $elemMatch: Match array elements by criteria
|
|
7254
|
+
Example: { "scores": { "$elemMatch": { "$gt": 80 } } }
|
|
7255
|
+
|
|
7256
|
+
Logical Operators:
|
|
7257
|
+
- $and: Logical AND (can be implicit or explicit)
|
|
7258
|
+
Implicit Example: { "price": { "$gt": 100 }, "category": "electronics" }
|
|
7259
|
+
Explicit Example: { "$and": [{ "price": { "$gt": 100 } }, { "category": "electronics" }] }
|
|
7260
|
+
- $or: Logical OR
|
|
7261
|
+
Example: { "$or": [{ "price": { "$lt": 50 } }, { "category": "books" }] }
|
|
7262
|
+
- $not: Logical NOT
|
|
7263
|
+
Example: { "field": { "$not": { "$eq": "value" } } }
|
|
7264
|
+
- $nor: Logical NOR
|
|
7265
|
+
Example: { "$nor": [{ "price": { "$lt": 50 } }, { "category": "books" }] }
|
|
7266
|
+
|
|
7267
|
+
Element Operators:
|
|
7268
|
+
- $exists: Check if field exists
|
|
7269
|
+
Example: { "rating": { "$exists": true } }
|
|
7270
|
+
|
|
7271
|
+
Special Operators:
|
|
7272
|
+
- $regex: Regular expression match
|
|
7273
|
+
Example: { "title": { "$regex": "^laptop", "$options": "i" } }
|
|
7274
|
+
- $size: Array length check
|
|
7275
|
+
Example: { "tags": { "$size": 2 } }
|
|
7276
|
+
|
|
7277
|
+
Usage Notes:
|
|
7278
|
+
- You can use both 'filter' (for metadata fields) and 'documentFilter' (for document content fields).
|
|
7279
|
+
- Nested fields are supported using dot notation (e.g., "metadata.author.name").
|
|
7280
|
+
- Multiple conditions on the same field are supported with both implicit and explicit $and.
|
|
7281
|
+
- Empty arrays in $in/$nin will return no results.
|
|
7282
|
+
- All logical operators ($and, $or, $not, $nor) can be used at the top level or nested.
|
|
7283
|
+
- All other operators must be used within a field condition.
|
|
7284
|
+
Valid: { "field": { "$gt": 100 } }
|
|
7285
|
+
Valid: { "$and": [...] }
|
|
7286
|
+
Invalid: { "$gt": 100 }
|
|
7287
|
+
- $not operator:
|
|
7288
|
+
- Must be an object
|
|
7289
|
+
- Cannot be empty
|
|
7290
|
+
- Can be used at field level or top level
|
|
7291
|
+
- Valid: { "$not": { "field": "value" } }
|
|
7292
|
+
- Valid: { "field": { "$not": { "$eq": "value" } } }
|
|
7293
|
+
- Logical operators must contain field conditions, not direct operators
|
|
7294
|
+
Valid: { "$and": [{ "field": { "$gt": 100 } }] }
|
|
7295
|
+
Invalid: { "$and": [{ "$gt": 100 }] }
|
|
7296
|
+
- Regex uses standard MongoDB regex syntax (with optional $options).
|
|
7297
|
+
- Metadata values can be strings, numbers, booleans, or arrays.
|
|
7298
|
+
- Metadata and document fields can be filtered in the same query.
|
|
7299
|
+
|
|
7300
|
+
Example Complex Query:
|
|
7301
|
+
{
|
|
7302
|
+
"category": { "$in": ["electronics", "computers"] },
|
|
7303
|
+
"price": { "$gte": 100, "$lte": 1000 },
|
|
7304
|
+
"inStock": true,
|
|
7305
|
+
"title": { "$regex": "laptop", "$options": "i" },
|
|
7306
|
+
"$or": [
|
|
7307
|
+
{ "brand": "Apple" },
|
|
7308
|
+
{ "rating": { "$gte": 4.5 } }
|
|
7309
|
+
]
|
|
7310
|
+
}
|
|
7311
|
+
`;
|
|
7216
7312
|
|
|
7217
7313
|
exports.ASTRA_PROMPT = ASTRA_PROMPT;
|
|
7218
7314
|
exports.CHROMA_PROMPT = CHROMA_PROMPT;
|
|
7219
7315
|
exports.GraphRAG = GraphRAG;
|
|
7220
7316
|
exports.LIBSQL_PROMPT = LIBSQL_PROMPT;
|
|
7221
7317
|
exports.MDocument = MDocument;
|
|
7318
|
+
exports.MONGODB_PROMPT = MONGODB_PROMPT;
|
|
7222
7319
|
exports.PGVECTOR_PROMPT = PGVECTOR_PROMPT;
|
|
7223
7320
|
exports.PINECONE_PROMPT = PINECONE_PROMPT;
|
|
7224
7321
|
exports.QDRANT_PROMPT = QDRANT_PROMPT;
|
package/dist/index.d.cts
CHANGED
|
@@ -16,6 +16,7 @@ export { PINECONE_PROMPT } from './_tsup-dts-rollup.cjs';
|
|
|
16
16
|
export { QDRANT_PROMPT } from './_tsup-dts-rollup.cjs';
|
|
17
17
|
export { UPSTASH_PROMPT } from './_tsup-dts-rollup.cjs';
|
|
18
18
|
export { VECTORIZE_PROMPT } from './_tsup-dts-rollup.cjs';
|
|
19
|
+
export { MONGODB_PROMPT } from './_tsup-dts-rollup.cjs';
|
|
19
20
|
export { defaultVectorQueryDescription } from './_tsup-dts-rollup.cjs';
|
|
20
21
|
export { defaultGraphRagDescription } from './_tsup-dts-rollup.cjs';
|
|
21
22
|
export { queryTextDescription } from './_tsup-dts-rollup.cjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ export { PINECONE_PROMPT } from './_tsup-dts-rollup.js';
|
|
|
16
16
|
export { QDRANT_PROMPT } from './_tsup-dts-rollup.js';
|
|
17
17
|
export { UPSTASH_PROMPT } from './_tsup-dts-rollup.js';
|
|
18
18
|
export { VECTORIZE_PROMPT } from './_tsup-dts-rollup.js';
|
|
19
|
+
export { MONGODB_PROMPT } from './_tsup-dts-rollup.js';
|
|
19
20
|
export { defaultVectorQueryDescription } from './_tsup-dts-rollup.js';
|
|
20
21
|
export { defaultGraphRagDescription } from './_tsup-dts-rollup.js';
|
|
21
22
|
export { queryTextDescription } from './_tsup-dts-rollup.js';
|
package/dist/index.js
CHANGED
|
@@ -2307,11 +2307,23 @@ var reasoningModels = {
|
|
|
2307
2307
|
"o1-preview-2024-09-12": {
|
|
2308
2308
|
systemMessageMode: "remove"
|
|
2309
2309
|
},
|
|
2310
|
+
o3: {
|
|
2311
|
+
systemMessageMode: "developer"
|
|
2312
|
+
},
|
|
2313
|
+
"o3-2025-04-16": {
|
|
2314
|
+
systemMessageMode: "developer"
|
|
2315
|
+
},
|
|
2310
2316
|
"o3-mini": {
|
|
2311
2317
|
systemMessageMode: "developer"
|
|
2312
2318
|
},
|
|
2313
2319
|
"o3-mini-2025-01-31": {
|
|
2314
2320
|
systemMessageMode: "developer"
|
|
2321
|
+
},
|
|
2322
|
+
"o4-mini": {
|
|
2323
|
+
systemMessageMode: "developer"
|
|
2324
|
+
},
|
|
2325
|
+
"o4-mini-2025-04-16": {
|
|
2326
|
+
systemMessageMode: "developer"
|
|
2315
2327
|
}
|
|
2316
2328
|
};
|
|
2317
2329
|
function convertToOpenAICompletionPrompt({
|
|
@@ -7211,5 +7223,89 @@ Example Complex Query:
|
|
|
7211
7223
|
"price": { "$gte": 100, "$lte": 1000 },
|
|
7212
7224
|
"inStock": true
|
|
7213
7225
|
}`;
|
|
7226
|
+
var MONGODB_PROMPT = `When querying MongoDB, you can ONLY use the operators listed below. Any other operators will be rejected.
|
|
7227
|
+
Important: Don't explain how to construct the filter - use the specified operators and fields to search the content and return relevant results.
|
|
7228
|
+
If 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.
|
|
7229
|
+
|
|
7230
|
+
Basic Comparison Operators:
|
|
7231
|
+
- $eq: Exact match (default when using field: value)
|
|
7232
|
+
Example: { "category": "electronics" }
|
|
7233
|
+
- $ne: Not equal
|
|
7234
|
+
Example: { "category": { "$ne": "electronics" } }
|
|
7235
|
+
- $gt: Greater than
|
|
7236
|
+
Example: { "price": { "$gt": 100 } }
|
|
7237
|
+
- $gte: Greater than or equal
|
|
7238
|
+
Example: { "price": { "$gte": 100 } }
|
|
7239
|
+
- $lt: Less than
|
|
7240
|
+
Example: { "price": { "$lt": 100 } }
|
|
7241
|
+
- $lte: Less than or equal
|
|
7242
|
+
Example: { "price": { "$lte": 100 } }
|
|
7243
|
+
|
|
7244
|
+
Array Operators:
|
|
7245
|
+
- $in: Match any value in array
|
|
7246
|
+
Example: { "category": { "$in": ["electronics", "books"] } }
|
|
7247
|
+
- $nin: Does not match any value in array
|
|
7248
|
+
Example: { "category": { "$nin": ["electronics", "books"] } }
|
|
7249
|
+
- $all: Match all values in array
|
|
7250
|
+
Example: { "tags": { "$all": ["premium", "sale"] } }
|
|
7251
|
+
- $elemMatch: Match array elements by criteria
|
|
7252
|
+
Example: { "scores": { "$elemMatch": { "$gt": 80 } } }
|
|
7253
|
+
|
|
7254
|
+
Logical Operators:
|
|
7255
|
+
- $and: Logical AND (can be implicit or explicit)
|
|
7256
|
+
Implicit Example: { "price": { "$gt": 100 }, "category": "electronics" }
|
|
7257
|
+
Explicit Example: { "$and": [{ "price": { "$gt": 100 } }, { "category": "electronics" }] }
|
|
7258
|
+
- $or: Logical OR
|
|
7259
|
+
Example: { "$or": [{ "price": { "$lt": 50 } }, { "category": "books" }] }
|
|
7260
|
+
- $not: Logical NOT
|
|
7261
|
+
Example: { "field": { "$not": { "$eq": "value" } } }
|
|
7262
|
+
- $nor: Logical NOR
|
|
7263
|
+
Example: { "$nor": [{ "price": { "$lt": 50 } }, { "category": "books" }] }
|
|
7264
|
+
|
|
7265
|
+
Element Operators:
|
|
7266
|
+
- $exists: Check if field exists
|
|
7267
|
+
Example: { "rating": { "$exists": true } }
|
|
7268
|
+
|
|
7269
|
+
Special Operators:
|
|
7270
|
+
- $regex: Regular expression match
|
|
7271
|
+
Example: { "title": { "$regex": "^laptop", "$options": "i" } }
|
|
7272
|
+
- $size: Array length check
|
|
7273
|
+
Example: { "tags": { "$size": 2 } }
|
|
7274
|
+
|
|
7275
|
+
Usage Notes:
|
|
7276
|
+
- You can use both 'filter' (for metadata fields) and 'documentFilter' (for document content fields).
|
|
7277
|
+
- Nested fields are supported using dot notation (e.g., "metadata.author.name").
|
|
7278
|
+
- Multiple conditions on the same field are supported with both implicit and explicit $and.
|
|
7279
|
+
- Empty arrays in $in/$nin will return no results.
|
|
7280
|
+
- All logical operators ($and, $or, $not, $nor) can be used at the top level or nested.
|
|
7281
|
+
- All other operators must be used within a field condition.
|
|
7282
|
+
Valid: { "field": { "$gt": 100 } }
|
|
7283
|
+
Valid: { "$and": [...] }
|
|
7284
|
+
Invalid: { "$gt": 100 }
|
|
7285
|
+
- $not operator:
|
|
7286
|
+
- Must be an object
|
|
7287
|
+
- Cannot be empty
|
|
7288
|
+
- Can be used at field level or top level
|
|
7289
|
+
- Valid: { "$not": { "field": "value" } }
|
|
7290
|
+
- Valid: { "field": { "$not": { "$eq": "value" } } }
|
|
7291
|
+
- Logical operators must contain field conditions, not direct operators
|
|
7292
|
+
Valid: { "$and": [{ "field": { "$gt": 100 } }] }
|
|
7293
|
+
Invalid: { "$and": [{ "$gt": 100 }] }
|
|
7294
|
+
- Regex uses standard MongoDB regex syntax (with optional $options).
|
|
7295
|
+
- Metadata values can be strings, numbers, booleans, or arrays.
|
|
7296
|
+
- Metadata and document fields can be filtered in the same query.
|
|
7297
|
+
|
|
7298
|
+
Example Complex Query:
|
|
7299
|
+
{
|
|
7300
|
+
"category": { "$in": ["electronics", "computers"] },
|
|
7301
|
+
"price": { "$gte": 100, "$lte": 1000 },
|
|
7302
|
+
"inStock": true,
|
|
7303
|
+
"title": { "$regex": "laptop", "$options": "i" },
|
|
7304
|
+
"$or": [
|
|
7305
|
+
{ "brand": "Apple" },
|
|
7306
|
+
{ "rating": { "$gte": 4.5 } }
|
|
7307
|
+
]
|
|
7308
|
+
}
|
|
7309
|
+
`;
|
|
7214
7310
|
|
|
7215
|
-
export { ASTRA_PROMPT, CHROMA_PROMPT, GraphRAG, LIBSQL_PROMPT, MDocument, PGVECTOR_PROMPT, PINECONE_PROMPT, QDRANT_PROMPT, UPSTASH_PROMPT, VECTORIZE_PROMPT, createDocumentChunkerTool, createGraphRAGTool, createVectorQueryTool, defaultGraphRagDescription, defaultVectorQueryDescription, filterDescription, queryTextDescription, rerank, topKDescription };
|
|
7311
|
+
export { ASTRA_PROMPT, CHROMA_PROMPT, GraphRAG, LIBSQL_PROMPT, MDocument, MONGODB_PROMPT, PGVECTOR_PROMPT, PINECONE_PROMPT, QDRANT_PROMPT, UPSTASH_PROMPT, VECTORIZE_PROMPT, createDocumentChunkerTool, createGraphRAGTool, createVectorQueryTool, defaultGraphRagDescription, defaultVectorQueryDescription, filterDescription, queryTextDescription, rerank, topKDescription };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/rag",
|
|
3
|
-
"version": "0.1.20-alpha.
|
|
3
|
+
"version": "0.1.20-alpha.3",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"node-html-better-parser": "^1.4.7",
|
|
27
27
|
"pathe": "^2.0.3",
|
|
28
28
|
"zod": "^3.24.2",
|
|
29
|
-
"@mastra/core": "^0.9.1-alpha.
|
|
29
|
+
"@mastra/core": "^0.9.1-alpha.3"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
32
|
"ai": "^4.0.0"
|
|
@@ -727,3 +727,88 @@ Example Complex Query:
|
|
|
727
727
|
"price": { "$gte": 100, "$lte": 1000 },
|
|
728
728
|
"inStock": true
|
|
729
729
|
}`;
|
|
730
|
+
|
|
731
|
+
export const MONGODB_PROMPT = `When querying MongoDB, you can ONLY use the operators listed below. Any other operators will be rejected.
|
|
732
|
+
Important: Don't explain how to construct the filter - use the specified operators and fields to search the content and return relevant results.
|
|
733
|
+
If 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.
|
|
734
|
+
|
|
735
|
+
Basic Comparison Operators:
|
|
736
|
+
- $eq: Exact match (default when using field: value)
|
|
737
|
+
Example: { "category": "electronics" }
|
|
738
|
+
- $ne: Not equal
|
|
739
|
+
Example: { "category": { "$ne": "electronics" } }
|
|
740
|
+
- $gt: Greater than
|
|
741
|
+
Example: { "price": { "$gt": 100 } }
|
|
742
|
+
- $gte: Greater than or equal
|
|
743
|
+
Example: { "price": { "$gte": 100 } }
|
|
744
|
+
- $lt: Less than
|
|
745
|
+
Example: { "price": { "$lt": 100 } }
|
|
746
|
+
- $lte: Less than or equal
|
|
747
|
+
Example: { "price": { "$lte": 100 } }
|
|
748
|
+
|
|
749
|
+
Array Operators:
|
|
750
|
+
- $in: Match any value in array
|
|
751
|
+
Example: { "category": { "$in": ["electronics", "books"] } }
|
|
752
|
+
- $nin: Does not match any value in array
|
|
753
|
+
Example: { "category": { "$nin": ["electronics", "books"] } }
|
|
754
|
+
- $all: Match all values in array
|
|
755
|
+
Example: { "tags": { "$all": ["premium", "sale"] } }
|
|
756
|
+
- $elemMatch: Match array elements by criteria
|
|
757
|
+
Example: { "scores": { "$elemMatch": { "$gt": 80 } } }
|
|
758
|
+
|
|
759
|
+
Logical Operators:
|
|
760
|
+
- $and: Logical AND (can be implicit or explicit)
|
|
761
|
+
Implicit Example: { "price": { "$gt": 100 }, "category": "electronics" }
|
|
762
|
+
Explicit Example: { "$and": [{ "price": { "$gt": 100 } }, { "category": "electronics" }] }
|
|
763
|
+
- $or: Logical OR
|
|
764
|
+
Example: { "$or": [{ "price": { "$lt": 50 } }, { "category": "books" }] }
|
|
765
|
+
- $not: Logical NOT
|
|
766
|
+
Example: { "field": { "$not": { "$eq": "value" } } }
|
|
767
|
+
- $nor: Logical NOR
|
|
768
|
+
Example: { "$nor": [{ "price": { "$lt": 50 } }, { "category": "books" }] }
|
|
769
|
+
|
|
770
|
+
Element Operators:
|
|
771
|
+
- $exists: Check if field exists
|
|
772
|
+
Example: { "rating": { "$exists": true } }
|
|
773
|
+
|
|
774
|
+
Special Operators:
|
|
775
|
+
- $regex: Regular expression match
|
|
776
|
+
Example: { "title": { "$regex": "^laptop", "$options": "i" } }
|
|
777
|
+
- $size: Array length check
|
|
778
|
+
Example: { "tags": { "$size": 2 } }
|
|
779
|
+
|
|
780
|
+
Usage Notes:
|
|
781
|
+
- You can use both 'filter' (for metadata fields) and 'documentFilter' (for document content fields).
|
|
782
|
+
- Nested fields are supported using dot notation (e.g., "metadata.author.name").
|
|
783
|
+
- Multiple conditions on the same field are supported with both implicit and explicit $and.
|
|
784
|
+
- Empty arrays in $in/$nin will return no results.
|
|
785
|
+
- All logical operators ($and, $or, $not, $nor) can be used at the top level or nested.
|
|
786
|
+
- All other operators must be used within a field condition.
|
|
787
|
+
Valid: { "field": { "$gt": 100 } }
|
|
788
|
+
Valid: { "$and": [...] }
|
|
789
|
+
Invalid: { "$gt": 100 }
|
|
790
|
+
- $not operator:
|
|
791
|
+
- Must be an object
|
|
792
|
+
- Cannot be empty
|
|
793
|
+
- Can be used at field level or top level
|
|
794
|
+
- Valid: { "$not": { "field": "value" } }
|
|
795
|
+
- Valid: { "field": { "$not": { "$eq": "value" } } }
|
|
796
|
+
- Logical operators must contain field conditions, not direct operators
|
|
797
|
+
Valid: { "$and": [{ "field": { "$gt": 100 } }] }
|
|
798
|
+
Invalid: { "$and": [{ "$gt": 100 }] }
|
|
799
|
+
- Regex uses standard MongoDB regex syntax (with optional $options).
|
|
800
|
+
- Metadata values can be strings, numbers, booleans, or arrays.
|
|
801
|
+
- Metadata and document fields can be filtered in the same query.
|
|
802
|
+
|
|
803
|
+
Example Complex Query:
|
|
804
|
+
{
|
|
805
|
+
"category": { "$in": ["electronics", "computers"] },
|
|
806
|
+
"price": { "$gte": 100, "$lte": 1000 },
|
|
807
|
+
"inStock": true,
|
|
808
|
+
"title": { "$regex": "laptop", "$options": "i" },
|
|
809
|
+
"$or": [
|
|
810
|
+
{ "brand": "Apple" },
|
|
811
|
+
{ "rating": { "$gte": 4.5 } }
|
|
812
|
+
]
|
|
813
|
+
}
|
|
814
|
+
`;
|