@mastra/upstash 0.3.1-alpha.4 → 0.3.1-alpha.6
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 +15 -0
- package/dist/_tsup-dts-rollup.d.cts +8 -0
- package/dist/_tsup-dts-rollup.d.ts +8 -0
- package/dist/index.cjs +76 -0
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +76 -1
- package/package.json +2 -2
- package/src/index.ts +1 -0
- package/src/vector/prompt.ts +77 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
|
|
2
|
-
> @mastra/upstash@0.3.1-alpha.
|
|
2
|
+
> @mastra/upstash@0.3.1-alpha.6 build /home/runner/work/mastra/mastra/stores/upstash
|
|
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 9501ms
|
|
10
10
|
[34mDTS[39m Build start
|
|
11
11
|
[34mCLI[39m Target: es2022
|
|
12
12
|
Analysis will use the bundled TypeScript version 5.8.3
|
|
13
13
|
[36mWriting package typings: /home/runner/work/mastra/mastra/stores/upstash/dist/_tsup-dts-rollup.d.ts[39m
|
|
14
14
|
Analysis will use the bundled TypeScript version 5.8.3
|
|
15
15
|
[36mWriting package typings: /home/runner/work/mastra/mastra/stores/upstash/dist/_tsup-dts-rollup.d.cts[39m
|
|
16
|
-
[32mDTS[39m ⚡️ Build success in
|
|
16
|
+
[32mDTS[39m ⚡️ Build success in 11190ms
|
|
17
17
|
[34mCLI[39m Cleaning output folder
|
|
18
18
|
[34mESM[39m Build start
|
|
19
19
|
[34mCJS[39m Build start
|
|
20
|
-
[32mESM[39m [1mdist/index.js [22m[
|
|
21
|
-
[32mESM[39m ⚡️ Build success in
|
|
22
|
-
[32mCJS[39m [1mdist/index.cjs [22m[
|
|
23
|
-
[32mCJS[39m ⚡️ Build success in
|
|
20
|
+
[32mESM[39m [1mdist/index.js [22m[32m28.51 KB[39m
|
|
21
|
+
[32mESM[39m ⚡️ Build success in 735ms
|
|
22
|
+
[32mCJS[39m [1mdist/index.cjs [22m[32m28.65 KB[39m
|
|
23
|
+
[32mCJS[39m ⚡️ Build success in 735ms
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @mastra/upstash
|
|
2
2
|
|
|
3
|
+
## 0.3.1-alpha.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [c23a81c]
|
|
8
|
+
- @mastra/core@0.9.1-alpha.6
|
|
9
|
+
|
|
10
|
+
## 0.3.1-alpha.5
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- 5f826d9: Moved vector store specific prompts from @mastra/rag to be exported from the store that the prompt belongs to, ie @mastra/pg
|
|
15
|
+
- Updated dependencies [3e7b69d]
|
|
16
|
+
- @mastra/core@0.9.1-alpha.5
|
|
17
|
+
|
|
3
18
|
## 0.3.1-alpha.4
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
|
@@ -18,6 +18,14 @@ import type { WorkflowRun } from '@mastra/core/storage';
|
|
|
18
18
|
import type { WorkflowRuns } from '@mastra/core/storage';
|
|
19
19
|
import type { WorkflowRunState } from '@mastra/core/workflows';
|
|
20
20
|
|
|
21
|
+
/**
|
|
22
|
+
* Vector store specific prompt that details supported operators and examples.
|
|
23
|
+
* This prompt helps users construct valid filters for Upstash Vector.
|
|
24
|
+
*/
|
|
25
|
+
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\" }\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 (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- 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\": [{...}] } } }\n\nExample Complex Query:\n{\n \"$and\": [\n { \"category\": { \"$in\": [\"electronics\", \"computers\"] } },\n { \"price\": { \"$gte\": 100, \"$lte\": 1000 } },\n { \"rating\": { \"$exists\": true, \"$gt\": 4 } },\n { \"$or\": [\n { \"stock\": { \"$gt\": 0 } },\n { \"preorder\": true }\n ]}\n ]\n}";
|
|
26
|
+
export { UPSTASH_PROMPT }
|
|
27
|
+
export { UPSTASH_PROMPT as UPSTASH_PROMPT_alias_1 }
|
|
28
|
+
|
|
21
29
|
declare interface UpstashConfig {
|
|
22
30
|
url: string;
|
|
23
31
|
token: string;
|
|
@@ -18,6 +18,14 @@ import type { WorkflowRun } from '@mastra/core/storage';
|
|
|
18
18
|
import type { WorkflowRuns } from '@mastra/core/storage';
|
|
19
19
|
import type { WorkflowRunState } from '@mastra/core/workflows';
|
|
20
20
|
|
|
21
|
+
/**
|
|
22
|
+
* Vector store specific prompt that details supported operators and examples.
|
|
23
|
+
* This prompt helps users construct valid filters for Upstash Vector.
|
|
24
|
+
*/
|
|
25
|
+
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\" }\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 (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- 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\": [{...}] } } }\n\nExample Complex Query:\n{\n \"$and\": [\n { \"category\": { \"$in\": [\"electronics\", \"computers\"] } },\n { \"price\": { \"$gte\": 100, \"$lte\": 1000 } },\n { \"rating\": { \"$exists\": true, \"$gt\": 4 } },\n { \"$or\": [\n { \"stock\": { \"$gt\": 0 } },\n { \"preorder\": true }\n ]}\n ]\n}";
|
|
26
|
+
export { UPSTASH_PROMPT }
|
|
27
|
+
export { UPSTASH_PROMPT as UPSTASH_PROMPT_alias_1 }
|
|
28
|
+
|
|
21
29
|
declare interface UpstashConfig {
|
|
22
30
|
url: string;
|
|
23
31
|
token: string;
|
package/dist/index.cjs
CHANGED
|
@@ -756,5 +756,81 @@ var UpstashVector = class extends vector.MastraVector {
|
|
|
756
756
|
}
|
|
757
757
|
};
|
|
758
758
|
|
|
759
|
+
// src/vector/prompt.ts
|
|
760
|
+
var UPSTASH_PROMPT = `When querying Upstash Vector, you can ONLY use the operators listed below. Any other operators will be rejected.
|
|
761
|
+
Important: Don't explain how to construct the filter - use the specified operators and fields to search the content and return relevant results.
|
|
762
|
+
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.
|
|
763
|
+
|
|
764
|
+
Basic Comparison Operators:
|
|
765
|
+
- $eq: Exact match (default when using field: value)
|
|
766
|
+
Example: { "category": "electronics" }
|
|
767
|
+
- $ne: Not equal
|
|
768
|
+
Example: { "category": { "$ne": "electronics" } }
|
|
769
|
+
- $gt: Greater than
|
|
770
|
+
Example: { "price": { "$gt": 100 } }
|
|
771
|
+
- $gte: Greater than or equal
|
|
772
|
+
Example: { "price": { "$gte": 100 } }
|
|
773
|
+
- $lt: Less than
|
|
774
|
+
Example: { "price": { "$lt": 100 } }
|
|
775
|
+
- $lte: Less than or equal
|
|
776
|
+
Example: { "price": { "$lte": 100 } }
|
|
777
|
+
|
|
778
|
+
Array Operators:
|
|
779
|
+
- $in: Match any value in array
|
|
780
|
+
Example: { "category": { "$in": ["electronics", "books"] } }
|
|
781
|
+
- $nin: Does not match any value in array
|
|
782
|
+
Example: { "category": { "$nin": ["electronics", "books"] } }
|
|
783
|
+
|
|
784
|
+
Logical Operators:
|
|
785
|
+
- $and: Logical AND (can be implicit or explicit)
|
|
786
|
+
Implicit Example: { "price": { "$gt": 100 }, "category": "electronics" }
|
|
787
|
+
Explicit Example: { "$and": [{ "price": { "$gt": 100 } }, { "category": "electronics" }] }
|
|
788
|
+
- $or: Logical OR
|
|
789
|
+
Example: { "$or": [{ "price": { "$lt": 50 } }, { "category": "books" }] }
|
|
790
|
+
|
|
791
|
+
Element Operators:
|
|
792
|
+
- $exists: Check if field exists
|
|
793
|
+
Example: { "rating": { "$exists": true } }
|
|
794
|
+
|
|
795
|
+
Restrictions:
|
|
796
|
+
- Regex patterns are not supported
|
|
797
|
+
- Only $and and $or logical operators are supported at the top level
|
|
798
|
+
- Empty arrays in $in/$nin will return no results
|
|
799
|
+
- Nested fields are supported using dot notation
|
|
800
|
+
- Multiple conditions on the same field are supported with both implicit and explicit $and
|
|
801
|
+
- At least one key-value pair is required in filter object
|
|
802
|
+
- Empty objects and undefined values are treated as no filter
|
|
803
|
+
- Invalid types in comparison operators will throw errors
|
|
804
|
+
- All non-logical operators must be used within a field condition
|
|
805
|
+
Valid: { "field": { "$gt": 100 } }
|
|
806
|
+
Valid: { "$and": [...] }
|
|
807
|
+
Invalid: { "$gt": 100 }
|
|
808
|
+
- Logical operators must contain field conditions, not direct operators
|
|
809
|
+
Valid: { "$and": [{ "field": { "$gt": 100 } }] }
|
|
810
|
+
Invalid: { "$and": [{ "$gt": 100 }] }
|
|
811
|
+
- Logical operators ($and, $or):
|
|
812
|
+
- Can only be used at top level or nested within other logical operators
|
|
813
|
+
- Can not be used on a field level, or be nested inside a field
|
|
814
|
+
- Can not be used inside an operator
|
|
815
|
+
- Valid: { "$and": [{ "field": { "$gt": 100 } }] }
|
|
816
|
+
- Valid: { "$or": [{ "$and": [{ "field": { "$gt": 100 } }] }] }
|
|
817
|
+
- Invalid: { "field": { "$and": [{ "$gt": 100 }] } }
|
|
818
|
+
- Invalid: { "field": { "$or": [{ "$gt": 100 }] } }
|
|
819
|
+
- Invalid: { "field": { "$gt": { "$and": [{...}] } } }
|
|
820
|
+
|
|
821
|
+
Example Complex Query:
|
|
822
|
+
{
|
|
823
|
+
"$and": [
|
|
824
|
+
{ "category": { "$in": ["electronics", "computers"] } },
|
|
825
|
+
{ "price": { "$gte": 100, "$lte": 1000 } },
|
|
826
|
+
{ "rating": { "$exists": true, "$gt": 4 } },
|
|
827
|
+
{ "$or": [
|
|
828
|
+
{ "stock": { "$gt": 0 } },
|
|
829
|
+
{ "preorder": true }
|
|
830
|
+
]}
|
|
831
|
+
]
|
|
832
|
+
}`;
|
|
833
|
+
|
|
834
|
+
exports.UPSTASH_PROMPT = UPSTASH_PROMPT;
|
|
759
835
|
exports.UpstashStore = UpstashStore;
|
|
760
836
|
exports.UpstashVector = UpstashVector;
|
package/dist/index.d.cts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -754,4 +754,79 @@ var UpstashVector = class extends MastraVector {
|
|
|
754
754
|
}
|
|
755
755
|
};
|
|
756
756
|
|
|
757
|
-
|
|
757
|
+
// src/vector/prompt.ts
|
|
758
|
+
var UPSTASH_PROMPT = `When querying Upstash Vector, you can ONLY use the operators listed below. Any other operators will be rejected.
|
|
759
|
+
Important: Don't explain how to construct the filter - use the specified operators and fields to search the content and return relevant results.
|
|
760
|
+
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.
|
|
761
|
+
|
|
762
|
+
Basic Comparison Operators:
|
|
763
|
+
- $eq: Exact match (default when using field: value)
|
|
764
|
+
Example: { "category": "electronics" }
|
|
765
|
+
- $ne: Not equal
|
|
766
|
+
Example: { "category": { "$ne": "electronics" } }
|
|
767
|
+
- $gt: Greater than
|
|
768
|
+
Example: { "price": { "$gt": 100 } }
|
|
769
|
+
- $gte: Greater than or equal
|
|
770
|
+
Example: { "price": { "$gte": 100 } }
|
|
771
|
+
- $lt: Less than
|
|
772
|
+
Example: { "price": { "$lt": 100 } }
|
|
773
|
+
- $lte: Less than or equal
|
|
774
|
+
Example: { "price": { "$lte": 100 } }
|
|
775
|
+
|
|
776
|
+
Array Operators:
|
|
777
|
+
- $in: Match any value in array
|
|
778
|
+
Example: { "category": { "$in": ["electronics", "books"] } }
|
|
779
|
+
- $nin: Does not match any value in array
|
|
780
|
+
Example: { "category": { "$nin": ["electronics", "books"] } }
|
|
781
|
+
|
|
782
|
+
Logical Operators:
|
|
783
|
+
- $and: Logical AND (can be implicit or explicit)
|
|
784
|
+
Implicit Example: { "price": { "$gt": 100 }, "category": "electronics" }
|
|
785
|
+
Explicit Example: { "$and": [{ "price": { "$gt": 100 } }, { "category": "electronics" }] }
|
|
786
|
+
- $or: Logical OR
|
|
787
|
+
Example: { "$or": [{ "price": { "$lt": 50 } }, { "category": "books" }] }
|
|
788
|
+
|
|
789
|
+
Element Operators:
|
|
790
|
+
- $exists: Check if field exists
|
|
791
|
+
Example: { "rating": { "$exists": true } }
|
|
792
|
+
|
|
793
|
+
Restrictions:
|
|
794
|
+
- Regex patterns are not supported
|
|
795
|
+
- Only $and and $or logical operators are supported at the top level
|
|
796
|
+
- Empty arrays in $in/$nin will return no results
|
|
797
|
+
- Nested fields are supported using dot notation
|
|
798
|
+
- Multiple conditions on the same field are supported with both implicit and explicit $and
|
|
799
|
+
- At least one key-value pair is required in filter object
|
|
800
|
+
- Empty objects and undefined values are treated as no filter
|
|
801
|
+
- Invalid types in comparison operators will throw errors
|
|
802
|
+
- All non-logical operators must be used within a field condition
|
|
803
|
+
Valid: { "field": { "$gt": 100 } }
|
|
804
|
+
Valid: { "$and": [...] }
|
|
805
|
+
Invalid: { "$gt": 100 }
|
|
806
|
+
- Logical operators must contain field conditions, not direct operators
|
|
807
|
+
Valid: { "$and": [{ "field": { "$gt": 100 } }] }
|
|
808
|
+
Invalid: { "$and": [{ "$gt": 100 }] }
|
|
809
|
+
- Logical operators ($and, $or):
|
|
810
|
+
- Can only be used at top level or nested within other logical operators
|
|
811
|
+
- Can not be used on a field level, or be nested inside a field
|
|
812
|
+
- Can not be used inside an operator
|
|
813
|
+
- Valid: { "$and": [{ "field": { "$gt": 100 } }] }
|
|
814
|
+
- Valid: { "$or": [{ "$and": [{ "field": { "$gt": 100 } }] }] }
|
|
815
|
+
- Invalid: { "field": { "$and": [{ "$gt": 100 }] } }
|
|
816
|
+
- Invalid: { "field": { "$or": [{ "$gt": 100 }] } }
|
|
817
|
+
- Invalid: { "field": { "$gt": { "$and": [{...}] } } }
|
|
818
|
+
|
|
819
|
+
Example Complex Query:
|
|
820
|
+
{
|
|
821
|
+
"$and": [
|
|
822
|
+
{ "category": { "$in": ["electronics", "computers"] } },
|
|
823
|
+
{ "price": { "$gte": 100, "$lte": 1000 } },
|
|
824
|
+
{ "rating": { "$exists": true, "$gt": 4 } },
|
|
825
|
+
{ "$or": [
|
|
826
|
+
{ "stock": { "$gt": 0 } },
|
|
827
|
+
{ "preorder": true }
|
|
828
|
+
]}
|
|
829
|
+
]
|
|
830
|
+
}`;
|
|
831
|
+
|
|
832
|
+
export { UPSTASH_PROMPT, UpstashStore, UpstashVector };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/upstash",
|
|
3
|
-
"version": "0.3.1-alpha.
|
|
3
|
+
"version": "0.3.1-alpha.6",
|
|
4
4
|
"description": "Upstash provider for Mastra - includes both vector and db storage capabilities",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@upstash/redis": "^1.34.5",
|
|
24
24
|
"@upstash/vector": "^1.2.1",
|
|
25
|
-
"@mastra/core": "^0.9.1-alpha.
|
|
25
|
+
"@mastra/core": "^0.9.1-alpha.6"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@microsoft/api-extractor": "^7.52.5",
|
package/src/index.ts
CHANGED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vector store specific prompt that details supported operators and examples.
|
|
3
|
+
* This prompt helps users construct valid filters for Upstash Vector.
|
|
4
|
+
*/
|
|
5
|
+
export const UPSTASH_PROMPT = `When querying Upstash Vector, 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
|
+
|
|
29
|
+
Logical Operators:
|
|
30
|
+
- $and: Logical AND (can be implicit or explicit)
|
|
31
|
+
Implicit Example: { "price": { "$gt": 100 }, "category": "electronics" }
|
|
32
|
+
Explicit Example: { "$and": [{ "price": { "$gt": 100 } }, { "category": "electronics" }] }
|
|
33
|
+
- $or: Logical OR
|
|
34
|
+
Example: { "$or": [{ "price": { "$lt": 50 } }, { "category": "books" }] }
|
|
35
|
+
|
|
36
|
+
Element Operators:
|
|
37
|
+
- $exists: Check if field exists
|
|
38
|
+
Example: { "rating": { "$exists": true } }
|
|
39
|
+
|
|
40
|
+
Restrictions:
|
|
41
|
+
- Regex patterns are not supported
|
|
42
|
+
- Only $and and $or logical operators are supported at the top level
|
|
43
|
+
- Empty arrays in $in/$nin will return no results
|
|
44
|
+
- Nested fields are supported using dot notation
|
|
45
|
+
- Multiple conditions on the same field are supported with both implicit and explicit $and
|
|
46
|
+
- At least one key-value pair is required in filter object
|
|
47
|
+
- Empty objects and undefined values are treated as no filter
|
|
48
|
+
- Invalid types in comparison operators will throw errors
|
|
49
|
+
- All non-logical operators must be used within a field condition
|
|
50
|
+
Valid: { "field": { "$gt": 100 } }
|
|
51
|
+
Valid: { "$and": [...] }
|
|
52
|
+
Invalid: { "$gt": 100 }
|
|
53
|
+
- Logical operators must contain field conditions, not direct operators
|
|
54
|
+
Valid: { "$and": [{ "field": { "$gt": 100 } }] }
|
|
55
|
+
Invalid: { "$and": [{ "$gt": 100 }] }
|
|
56
|
+
- Logical operators ($and, $or):
|
|
57
|
+
- Can only be used at top level or nested within other logical operators
|
|
58
|
+
- Can not be used on a field level, or be nested inside a field
|
|
59
|
+
- Can not be used inside an operator
|
|
60
|
+
- Valid: { "$and": [{ "field": { "$gt": 100 } }] }
|
|
61
|
+
- Valid: { "$or": [{ "$and": [{ "field": { "$gt": 100 } }] }] }
|
|
62
|
+
- Invalid: { "field": { "$and": [{ "$gt": 100 }] } }
|
|
63
|
+
- Invalid: { "field": { "$or": [{ "$gt": 100 }] } }
|
|
64
|
+
- Invalid: { "field": { "$gt": { "$and": [{...}] } } }
|
|
65
|
+
|
|
66
|
+
Example Complex Query:
|
|
67
|
+
{
|
|
68
|
+
"$and": [
|
|
69
|
+
{ "category": { "$in": ["electronics", "computers"] } },
|
|
70
|
+
{ "price": { "$gte": 100, "$lte": 1000 } },
|
|
71
|
+
{ "rating": { "$exists": true, "$gt": 4 } },
|
|
72
|
+
{ "$or": [
|
|
73
|
+
{ "stock": { "$gt": 0 } },
|
|
74
|
+
{ "preorder": true }
|
|
75
|
+
]}
|
|
76
|
+
]
|
|
77
|
+
}`;
|