@mastra/astra 0.2.12-alpha.3 → 0.2.12-alpha.5
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 +9 -9
- package/CHANGELOG.md +16 -0
- package/dist/_tsup-dts-rollup.d.cts +8 -0
- package/dist/_tsup-dts-rollup.d.ts +8 -0
- package/dist/index.cjs +90 -0
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +90 -1
- package/package.json +4 -4
- package/src/index.ts +1 -0
- package/src/vector/index.test.ts +1 -1
- package/src/vector/prompt.ts +91 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
|
|
2
|
-
> @mastra/astra@0.2.12-alpha.
|
|
2
|
+
> @mastra/astra@0.2.12-alpha.5 build /home/runner/work/mastra/mastra/stores/astra
|
|
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 6781ms
|
|
10
10
|
[34mDTS[39m Build start
|
|
11
11
|
[34mCLI[39m Target: es2022
|
|
12
|
-
Analysis will use the bundled TypeScript version 5.8.
|
|
12
|
+
Analysis will use the bundled TypeScript version 5.8.3
|
|
13
13
|
[36mWriting package typings: /home/runner/work/mastra/mastra/stores/astra/dist/_tsup-dts-rollup.d.ts[39m
|
|
14
|
-
Analysis will use the bundled TypeScript version 5.8.
|
|
14
|
+
Analysis will use the bundled TypeScript version 5.8.3
|
|
15
15
|
[36mWriting package typings: /home/runner/work/mastra/mastra/stores/astra/dist/_tsup-dts-rollup.d.cts[39m
|
|
16
|
-
[32mDTS[39m ⚡️ Build success in
|
|
16
|
+
[32mDTS[39m ⚡️ Build success in 9377ms
|
|
17
17
|
[34mCLI[39m Cleaning output folder
|
|
18
18
|
[34mESM[39m Build start
|
|
19
19
|
[34mCJS[39m Build start
|
|
20
|
-
[32mCJS[39m [1mdist/index.cjs [22m[
|
|
21
|
-
[32mCJS[39m ⚡️ Build success in
|
|
22
|
-
[32mESM[39m [1mdist/index.js [22m[
|
|
23
|
-
[32mESM[39m ⚡️ Build success in
|
|
20
|
+
[32mCJS[39m [1mdist/index.cjs [22m[32m10.60 KB[39m
|
|
21
|
+
[32mCJS[39m ⚡️ Build success in 602ms
|
|
22
|
+
[32mESM[39m [1mdist/index.js [22m[32m10.54 KB[39m
|
|
23
|
+
[32mESM[39m ⚡️ Build success in 612ms
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @mastra/astra
|
|
2
2
|
|
|
3
|
+
## 0.2.12-alpha.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 5f826d9: Moved vector store specific prompts from @mastra/rag to be exported from the store that the prompt belongs to, ie @mastra/pg
|
|
8
|
+
- Updated dependencies [3e7b69d]
|
|
9
|
+
- @mastra/core@0.9.1-alpha.5
|
|
10
|
+
|
|
11
|
+
## 0.2.12-alpha.4
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Updated dependencies [e4943b8]
|
|
16
|
+
- Updated dependencies [479f490]
|
|
17
|
+
- @mastra/core@0.9.1-alpha.4
|
|
18
|
+
|
|
3
19
|
## 0.2.12-alpha.3
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
|
@@ -9,6 +9,14 @@ import type { QueryVectorParams } from '@mastra/core/vector';
|
|
|
9
9
|
import type { UpsertVectorParams } from '@mastra/core/vector';
|
|
10
10
|
import type { VectorFilter } from '@mastra/core/vector/filter';
|
|
11
11
|
|
|
12
|
+
/**
|
|
13
|
+
* Vector store specific prompt that details supported operators and examples.
|
|
14
|
+
* This prompt helps users construct valid filters for Astra Vector.
|
|
15
|
+
*/
|
|
16
|
+
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}";
|
|
17
|
+
export { ASTRA_PROMPT }
|
|
18
|
+
export { ASTRA_PROMPT as ASTRA_PROMPT_alias_1 }
|
|
19
|
+
|
|
12
20
|
declare interface AstraDbOptions {
|
|
13
21
|
token: string;
|
|
14
22
|
endpoint: string;
|
|
@@ -9,6 +9,14 @@ import type { QueryVectorParams } from '@mastra/core/vector';
|
|
|
9
9
|
import type { UpsertVectorParams } from '@mastra/core/vector';
|
|
10
10
|
import type { VectorFilter } from '@mastra/core/vector/filter';
|
|
11
11
|
|
|
12
|
+
/**
|
|
13
|
+
* Vector store specific prompt that details supported operators and examples.
|
|
14
|
+
* This prompt helps users construct valid filters for Astra Vector.
|
|
15
|
+
*/
|
|
16
|
+
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}";
|
|
17
|
+
export { ASTRA_PROMPT }
|
|
18
|
+
export { ASTRA_PROMPT as ASTRA_PROMPT_alias_1 }
|
|
19
|
+
|
|
12
20
|
declare interface AstraDbOptions {
|
|
13
21
|
token: string;
|
|
14
22
|
endpoint: string;
|
package/dist/index.cjs
CHANGED
|
@@ -195,4 +195,94 @@ var AstraVector = class extends vector.MastraVector {
|
|
|
195
195
|
}
|
|
196
196
|
};
|
|
197
197
|
|
|
198
|
+
// src/vector/prompt.ts
|
|
199
|
+
var ASTRA_PROMPT = `When querying Astra, you can ONLY use the operators listed below. Any other operators will be rejected.
|
|
200
|
+
Important: Don't explain how to construct the filter - use the specified operators and fields to search the content and return relevant results.
|
|
201
|
+
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.
|
|
202
|
+
|
|
203
|
+
Basic Comparison Operators:
|
|
204
|
+
- $eq: Exact match (default when using field: value)
|
|
205
|
+
Example: { "category": "electronics" }
|
|
206
|
+
- $ne: Not equal
|
|
207
|
+
Example: { "category": { "$ne": "electronics" } }
|
|
208
|
+
- $gt: Greater than
|
|
209
|
+
Example: { "price": { "$gt": 100 } }
|
|
210
|
+
- $gte: Greater than or equal
|
|
211
|
+
Example: { "price": { "$gte": 100 } }
|
|
212
|
+
- $lt: Less than
|
|
213
|
+
Example: { "price": { "$lt": 100 } }
|
|
214
|
+
- $lte: Less than or equal
|
|
215
|
+
Example: { "price": { "$lte": 100 } }
|
|
216
|
+
|
|
217
|
+
Array Operators:
|
|
218
|
+
- $in: Match any value in array
|
|
219
|
+
Example: { "category": { "$in": ["electronics", "books"] } }
|
|
220
|
+
- $nin: Does not match any value in array
|
|
221
|
+
Example: { "category": { "$nin": ["electronics", "books"] } }
|
|
222
|
+
- $all: Match all values in array
|
|
223
|
+
Example: { "tags": { "$all": ["premium", "sale"] } }
|
|
224
|
+
|
|
225
|
+
Logical Operators:
|
|
226
|
+
- $and: Logical AND (can be implicit or explicit)
|
|
227
|
+
Implicit Example: { "price": { "$gt": 100 }, "category": "electronics" }
|
|
228
|
+
Explicit Example: { "$and": [{ "price": { "$gt": 100 } }, { "category": "electronics" }] }
|
|
229
|
+
- $or: Logical OR
|
|
230
|
+
Example: { "$or": [{ "price": { "$lt": 50 } }, { "category": "books" }] }
|
|
231
|
+
- $not: Logical NOT
|
|
232
|
+
Example: { "$not": { "category": "electronics" } }
|
|
233
|
+
|
|
234
|
+
Element Operators:
|
|
235
|
+
- $exists: Check if field exists
|
|
236
|
+
Example: { "rating": { "$exists": true } }
|
|
237
|
+
|
|
238
|
+
Special Operators:
|
|
239
|
+
- $size: Array length check
|
|
240
|
+
Example: { "tags": { "$size": 2 } }
|
|
241
|
+
|
|
242
|
+
Restrictions:
|
|
243
|
+
- Regex patterns are not supported
|
|
244
|
+
- Only $and, $or, and $not logical operators are supported
|
|
245
|
+
- Nested fields are supported using dot notation
|
|
246
|
+
- Multiple conditions on the same field are supported with both implicit and explicit $and
|
|
247
|
+
- Empty arrays in $in/$nin will return no results
|
|
248
|
+
- A non-empty array is required for $all operator
|
|
249
|
+
- Only logical operators ($and, $or, $not) can be used at the top level
|
|
250
|
+
- All other operators must be used within a field condition
|
|
251
|
+
Valid: { "field": { "$gt": 100 } }
|
|
252
|
+
Valid: { "$and": [...] }
|
|
253
|
+
Invalid: { "$gt": 100 }
|
|
254
|
+
- Logical operators must contain field conditions, not direct operators
|
|
255
|
+
Valid: { "$and": [{ "field": { "$gt": 100 } }] }
|
|
256
|
+
Invalid: { "$and": [{ "$gt": 100 }] }
|
|
257
|
+
- $not operator:
|
|
258
|
+
- Must be an object
|
|
259
|
+
- Cannot be empty
|
|
260
|
+
- Can be used at field level or top level
|
|
261
|
+
- Valid: { "$not": { "field": "value" } }
|
|
262
|
+
- Valid: { "field": { "$not": { "$eq": "value" } } }
|
|
263
|
+
- Other logical operators ($and, $or):
|
|
264
|
+
- Can only be used at top level or nested within other logical operators
|
|
265
|
+
- Can not be used on a field level, or be nested inside a field
|
|
266
|
+
- Can not be used inside an operator
|
|
267
|
+
- Valid: { "$and": [{ "field": { "$gt": 100 } }] }
|
|
268
|
+
- Valid: { "$or": [{ "$and": [{ "field": { "$gt": 100 } }] }] }
|
|
269
|
+
- Invalid: { "field": { "$and": [{ "$gt": 100 }] } }
|
|
270
|
+
- Invalid: { "field": { "$or": [{ "$gt": 100 }] } }
|
|
271
|
+
- Invalid: { "field": { "$gt": { "$and": [{...}] } } }
|
|
272
|
+
|
|
273
|
+
Example Complex Query:
|
|
274
|
+
{
|
|
275
|
+
"$and": [
|
|
276
|
+
{ "category": { "$in": ["electronics", "computers"] } },
|
|
277
|
+
{ "price": { "$gte": 100, "$lte": 1000 } },
|
|
278
|
+
{ "tags": { "$all": ["premium"] } },
|
|
279
|
+
{ "rating": { "$exists": true, "$gt": 4 } },
|
|
280
|
+
{ "$or": [
|
|
281
|
+
{ "stock": { "$gt": 0 } },
|
|
282
|
+
{ "preorder": true }
|
|
283
|
+
]}
|
|
284
|
+
]
|
|
285
|
+
}`;
|
|
286
|
+
|
|
287
|
+
exports.ASTRA_PROMPT = ASTRA_PROMPT;
|
|
198
288
|
exports.AstraVector = AstraVector;
|
package/dist/index.d.cts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -193,4 +193,93 @@ var AstraVector = class extends MastraVector {
|
|
|
193
193
|
}
|
|
194
194
|
};
|
|
195
195
|
|
|
196
|
-
|
|
196
|
+
// src/vector/prompt.ts
|
|
197
|
+
var ASTRA_PROMPT = `When querying Astra, you can ONLY use the operators listed below. Any other operators will be rejected.
|
|
198
|
+
Important: Don't explain how to construct the filter - use the specified operators and fields to search the content and return relevant results.
|
|
199
|
+
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.
|
|
200
|
+
|
|
201
|
+
Basic Comparison Operators:
|
|
202
|
+
- $eq: Exact match (default when using field: value)
|
|
203
|
+
Example: { "category": "electronics" }
|
|
204
|
+
- $ne: Not equal
|
|
205
|
+
Example: { "category": { "$ne": "electronics" } }
|
|
206
|
+
- $gt: Greater than
|
|
207
|
+
Example: { "price": { "$gt": 100 } }
|
|
208
|
+
- $gte: Greater than or equal
|
|
209
|
+
Example: { "price": { "$gte": 100 } }
|
|
210
|
+
- $lt: Less than
|
|
211
|
+
Example: { "price": { "$lt": 100 } }
|
|
212
|
+
- $lte: Less than or equal
|
|
213
|
+
Example: { "price": { "$lte": 100 } }
|
|
214
|
+
|
|
215
|
+
Array Operators:
|
|
216
|
+
- $in: Match any value in array
|
|
217
|
+
Example: { "category": { "$in": ["electronics", "books"] } }
|
|
218
|
+
- $nin: Does not match any value in array
|
|
219
|
+
Example: { "category": { "$nin": ["electronics", "books"] } }
|
|
220
|
+
- $all: Match all values in array
|
|
221
|
+
Example: { "tags": { "$all": ["premium", "sale"] } }
|
|
222
|
+
|
|
223
|
+
Logical Operators:
|
|
224
|
+
- $and: Logical AND (can be implicit or explicit)
|
|
225
|
+
Implicit Example: { "price": { "$gt": 100 }, "category": "electronics" }
|
|
226
|
+
Explicit Example: { "$and": [{ "price": { "$gt": 100 } }, { "category": "electronics" }] }
|
|
227
|
+
- $or: Logical OR
|
|
228
|
+
Example: { "$or": [{ "price": { "$lt": 50 } }, { "category": "books" }] }
|
|
229
|
+
- $not: Logical NOT
|
|
230
|
+
Example: { "$not": { "category": "electronics" } }
|
|
231
|
+
|
|
232
|
+
Element Operators:
|
|
233
|
+
- $exists: Check if field exists
|
|
234
|
+
Example: { "rating": { "$exists": true } }
|
|
235
|
+
|
|
236
|
+
Special Operators:
|
|
237
|
+
- $size: Array length check
|
|
238
|
+
Example: { "tags": { "$size": 2 } }
|
|
239
|
+
|
|
240
|
+
Restrictions:
|
|
241
|
+
- Regex patterns are not supported
|
|
242
|
+
- Only $and, $or, and $not logical operators are supported
|
|
243
|
+
- Nested fields are supported using dot notation
|
|
244
|
+
- Multiple conditions on the same field are supported with both implicit and explicit $and
|
|
245
|
+
- Empty arrays in $in/$nin will return no results
|
|
246
|
+
- A non-empty array is required for $all operator
|
|
247
|
+
- Only logical operators ($and, $or, $not) can be used at the top level
|
|
248
|
+
- All other operators must be used within a field condition
|
|
249
|
+
Valid: { "field": { "$gt": 100 } }
|
|
250
|
+
Valid: { "$and": [...] }
|
|
251
|
+
Invalid: { "$gt": 100 }
|
|
252
|
+
- Logical operators must contain field conditions, not direct operators
|
|
253
|
+
Valid: { "$and": [{ "field": { "$gt": 100 } }] }
|
|
254
|
+
Invalid: { "$and": [{ "$gt": 100 }] }
|
|
255
|
+
- $not operator:
|
|
256
|
+
- Must be an object
|
|
257
|
+
- Cannot be empty
|
|
258
|
+
- Can be used at field level or top level
|
|
259
|
+
- Valid: { "$not": { "field": "value" } }
|
|
260
|
+
- Valid: { "field": { "$not": { "$eq": "value" } } }
|
|
261
|
+
- Other logical operators ($and, $or):
|
|
262
|
+
- Can only be used at top level or nested within other logical operators
|
|
263
|
+
- Can not be used on a field level, or be nested inside a field
|
|
264
|
+
- Can not be used inside an operator
|
|
265
|
+
- Valid: { "$and": [{ "field": { "$gt": 100 } }] }
|
|
266
|
+
- Valid: { "$or": [{ "$and": [{ "field": { "$gt": 100 } }] }] }
|
|
267
|
+
- Invalid: { "field": { "$and": [{ "$gt": 100 }] } }
|
|
268
|
+
- Invalid: { "field": { "$or": [{ "$gt": 100 }] } }
|
|
269
|
+
- Invalid: { "field": { "$gt": { "$and": [{...}] } } }
|
|
270
|
+
|
|
271
|
+
Example Complex Query:
|
|
272
|
+
{
|
|
273
|
+
"$and": [
|
|
274
|
+
{ "category": { "$in": ["electronics", "computers"] } },
|
|
275
|
+
{ "price": { "$gte": 100, "$lte": 1000 } },
|
|
276
|
+
{ "tags": { "$all": ["premium"] } },
|
|
277
|
+
{ "rating": { "$exists": true, "$gt": 4 } },
|
|
278
|
+
{ "$or": [
|
|
279
|
+
{ "stock": { "$gt": 0 } },
|
|
280
|
+
{ "preorder": true }
|
|
281
|
+
]}
|
|
282
|
+
]
|
|
283
|
+
}`;
|
|
284
|
+
|
|
285
|
+
export { ASTRA_PROMPT, AstraVector };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/astra",
|
|
3
|
-
"version": "0.2.12-alpha.
|
|
3
|
+
"version": "0.2.12-alpha.5",
|
|
4
4
|
"description": "Astra DB provider for Mastra - includes vector store capabilities",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -21,15 +21,15 @@
|
|
|
21
21
|
"license": "MIT",
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@datastax/astra-db-ts": "^1.5.0",
|
|
24
|
-
"@mastra/core": "^0.9.1-alpha.
|
|
24
|
+
"@mastra/core": "^0.9.1-alpha.5"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@microsoft/api-extractor": "^7.52.
|
|
27
|
+
"@microsoft/api-extractor": "^7.52.5",
|
|
28
28
|
"@types/node": "^20.17.27",
|
|
29
29
|
"eslint": "^9.23.0",
|
|
30
30
|
"tsup": "^8.4.0",
|
|
31
31
|
"typescript": "^5.8.2",
|
|
32
|
-
"vitest": "^3.
|
|
32
|
+
"vitest": "^3.1.2",
|
|
33
33
|
"@internal/lint": "0.0.2"
|
|
34
34
|
},
|
|
35
35
|
"scripts": {
|
package/src/index.ts
CHANGED
package/src/vector/index.test.ts
CHANGED
|
@@ -58,7 +58,7 @@ async function deleteIndexAndWait(vectorDB: AstraVector, indexName: string) {
|
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
describe('AstraVector Integration Tests', () => {
|
|
61
|
+
describe.skip('AstraVector Integration Tests', () => {
|
|
62
62
|
let vectorDB: AstraVector;
|
|
63
63
|
const testIndexName = 'testvectors1733728136118'; // Unique collection name
|
|
64
64
|
const testIndexName2 = 'testvectors1733728136119'; // Unique collection name
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vector store specific prompt that details supported operators and examples.
|
|
3
|
+
* This prompt helps users construct valid filters for Astra Vector.
|
|
4
|
+
*/
|
|
5
|
+
export const ASTRA_PROMPT = `When querying Astra, you can ONLY use the operators listed below. Any other operators will be rejected.
|
|
6
|
+
Important: Don't explain how to construct the filter - use the specified operators and fields to search the content and return relevant results.
|
|
7
|
+
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.
|
|
8
|
+
|
|
9
|
+
Basic Comparison Operators:
|
|
10
|
+
- $eq: Exact match (default when using field: value)
|
|
11
|
+
Example: { "category": "electronics" }
|
|
12
|
+
- $ne: Not equal
|
|
13
|
+
Example: { "category": { "$ne": "electronics" } }
|
|
14
|
+
- $gt: Greater than
|
|
15
|
+
Example: { "price": { "$gt": 100 } }
|
|
16
|
+
- $gte: Greater than or equal
|
|
17
|
+
Example: { "price": { "$gte": 100 } }
|
|
18
|
+
- $lt: Less than
|
|
19
|
+
Example: { "price": { "$lt": 100 } }
|
|
20
|
+
- $lte: Less than or equal
|
|
21
|
+
Example: { "price": { "$lte": 100 } }
|
|
22
|
+
|
|
23
|
+
Array Operators:
|
|
24
|
+
- $in: Match any value in array
|
|
25
|
+
Example: { "category": { "$in": ["electronics", "books"] } }
|
|
26
|
+
- $nin: Does not match any value in array
|
|
27
|
+
Example: { "category": { "$nin": ["electronics", "books"] } }
|
|
28
|
+
- $all: Match all values in array
|
|
29
|
+
Example: { "tags": { "$all": ["premium", "sale"] } }
|
|
30
|
+
|
|
31
|
+
Logical Operators:
|
|
32
|
+
- $and: Logical AND (can be implicit or explicit)
|
|
33
|
+
Implicit Example: { "price": { "$gt": 100 }, "category": "electronics" }
|
|
34
|
+
Explicit Example: { "$and": [{ "price": { "$gt": 100 } }, { "category": "electronics" }] }
|
|
35
|
+
- $or: Logical OR
|
|
36
|
+
Example: { "$or": [{ "price": { "$lt": 50 } }, { "category": "books" }] }
|
|
37
|
+
- $not: Logical NOT
|
|
38
|
+
Example: { "$not": { "category": "electronics" } }
|
|
39
|
+
|
|
40
|
+
Element Operators:
|
|
41
|
+
- $exists: Check if field exists
|
|
42
|
+
Example: { "rating": { "$exists": true } }
|
|
43
|
+
|
|
44
|
+
Special Operators:
|
|
45
|
+
- $size: Array length check
|
|
46
|
+
Example: { "tags": { "$size": 2 } }
|
|
47
|
+
|
|
48
|
+
Restrictions:
|
|
49
|
+
- Regex patterns are not supported
|
|
50
|
+
- Only $and, $or, and $not logical operators are supported
|
|
51
|
+
- Nested fields are supported using dot notation
|
|
52
|
+
- Multiple conditions on the same field are supported with both implicit and explicit $and
|
|
53
|
+
- Empty arrays in $in/$nin will return no results
|
|
54
|
+
- A non-empty array is required for $all operator
|
|
55
|
+
- Only logical operators ($and, $or, $not) can be used at the top level
|
|
56
|
+
- All other operators must be used within a field condition
|
|
57
|
+
Valid: { "field": { "$gt": 100 } }
|
|
58
|
+
Valid: { "$and": [...] }
|
|
59
|
+
Invalid: { "$gt": 100 }
|
|
60
|
+
- Logical operators must contain field conditions, not direct operators
|
|
61
|
+
Valid: { "$and": [{ "field": { "$gt": 100 } }] }
|
|
62
|
+
Invalid: { "$and": [{ "$gt": 100 }] }
|
|
63
|
+
- $not operator:
|
|
64
|
+
- Must be an object
|
|
65
|
+
- Cannot be empty
|
|
66
|
+
- Can be used at field level or top level
|
|
67
|
+
- Valid: { "$not": { "field": "value" } }
|
|
68
|
+
- Valid: { "field": { "$not": { "$eq": "value" } } }
|
|
69
|
+
- Other logical operators ($and, $or):
|
|
70
|
+
- Can only be used at top level or nested within other logical operators
|
|
71
|
+
- Can not be used on a field level, or be nested inside a field
|
|
72
|
+
- Can not be used inside an operator
|
|
73
|
+
- Valid: { "$and": [{ "field": { "$gt": 100 } }] }
|
|
74
|
+
- Valid: { "$or": [{ "$and": [{ "field": { "$gt": 100 } }] }] }
|
|
75
|
+
- Invalid: { "field": { "$and": [{ "$gt": 100 }] } }
|
|
76
|
+
- Invalid: { "field": { "$or": [{ "$gt": 100 }] } }
|
|
77
|
+
- Invalid: { "field": { "$gt": { "$and": [{...}] } } }
|
|
78
|
+
|
|
79
|
+
Example Complex Query:
|
|
80
|
+
{
|
|
81
|
+
"$and": [
|
|
82
|
+
{ "category": { "$in": ["electronics", "computers"] } },
|
|
83
|
+
{ "price": { "$gte": 100, "$lte": 1000 } },
|
|
84
|
+
{ "tags": { "$all": ["premium"] } },
|
|
85
|
+
{ "rating": { "$exists": true, "$gt": 4 } },
|
|
86
|
+
{ "$or": [
|
|
87
|
+
{ "stock": { "$gt": 0 } },
|
|
88
|
+
{ "preorder": true }
|
|
89
|
+
]}
|
|
90
|
+
]
|
|
91
|
+
}`;
|