@mastra/chroma 0.0.0-vector-query-sources-20250516172905 → 0.0.0-vector-query-tool-provider-options-20250828222356
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +361 -4
- package/LICENSE.md +12 -4
- package/README.md +47 -21
- package/dist/index.cjs +280 -157
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +277 -154
- package/dist/index.js.map +1 -0
- package/dist/vector/filter.d.ts +19 -0
- package/dist/vector/filter.d.ts.map +1 -0
- package/dist/vector/index.d.ts +70 -0
- package/dist/vector/index.d.ts.map +1 -0
- package/dist/vector/prompt.d.ts +6 -0
- package/dist/vector/prompt.d.ts.map +1 -0
- package/package.json +18 -13
- package/src/vector/filter.test.ts +27 -19
- package/src/vector/filter.ts +28 -5
- package/src/vector/index.test.ts +142 -129
- package/src/vector/index.ts +306 -200
- package/tsconfig.build.json +9 -0
- package/tsconfig.json +1 -1
- package/tsup.config.ts +17 -0
- package/dist/_tsup-dts-rollup.d.cts +0 -126
- package/dist/_tsup-dts-rollup.d.ts +0 -126
- package/dist/index.d.cts +0 -2
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
import { BaseFilterTranslator } from '@mastra/core/vector/filter';
|
|
2
|
-
import type { CreateIndexParams } from '@mastra/core/vector';
|
|
3
|
-
import type { DeleteIndexParams } from '@mastra/core/vector';
|
|
4
|
-
import type { DeleteVectorParams } from '@mastra/core/vector';
|
|
5
|
-
import type { DescribeIndexParams } from '@mastra/core/vector';
|
|
6
|
-
import type { IndexStats } from '@mastra/core/vector';
|
|
7
|
-
import { MastraVector } from '@mastra/core/vector';
|
|
8
|
-
import type { OperatorSupport } from '@mastra/core/vector/filter';
|
|
9
|
-
import type { ParamsToArgs } from '@mastra/core/vector';
|
|
10
|
-
import type { QueryResult } from '@mastra/core/vector';
|
|
11
|
-
import type { QueryVectorArgs } from '@mastra/core/vector';
|
|
12
|
-
import type { QueryVectorParams } from '@mastra/core/vector';
|
|
13
|
-
import type { UpdateVectorParams } from '@mastra/core/vector';
|
|
14
|
-
import type { UpsertVectorArgs } from '@mastra/core/vector';
|
|
15
|
-
import type { UpsertVectorParams } from '@mastra/core/vector';
|
|
16
|
-
import type { VectorFilter } from '@mastra/core/vector/filter';
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Vector store specific prompt that details supported operators and examples.
|
|
20
|
-
* This prompt helps users construct valid filters for Chroma Vector.
|
|
21
|
-
*/
|
|
22
|
-
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\": [{...}] } } }\n\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}";
|
|
23
|
-
export { CHROMA_PROMPT }
|
|
24
|
-
export { CHROMA_PROMPT as CHROMA_PROMPT_alias_1 }
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Translator for Chroma filter queries.
|
|
28
|
-
* Maintains MongoDB-compatible syntax while ensuring proper validation
|
|
29
|
-
* and normalization of values.
|
|
30
|
-
*/
|
|
31
|
-
export declare class ChromaFilterTranslator extends BaseFilterTranslator {
|
|
32
|
-
protected getSupportedOperators(): OperatorSupport;
|
|
33
|
-
translate(filter?: VectorFilter): VectorFilter;
|
|
34
|
-
private translateNode;
|
|
35
|
-
private translateOperator;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
declare type ChromaQueryArgs = [...QueryVectorArgs, VectorFilter?];
|
|
39
|
-
|
|
40
|
-
declare interface ChromaQueryVectorParams extends QueryVectorParams {
|
|
41
|
-
documentFilter?: VectorFilter;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
declare type ChromaUpsertArgs = [...UpsertVectorArgs, string[]?];
|
|
45
|
-
|
|
46
|
-
declare interface ChromaUpsertVectorParams extends UpsertVectorParams {
|
|
47
|
-
documents?: string[];
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
declare class ChromaVector extends MastraVector {
|
|
51
|
-
private client;
|
|
52
|
-
private collections;
|
|
53
|
-
constructor({ path, auth, }: {
|
|
54
|
-
path: string;
|
|
55
|
-
auth?: {
|
|
56
|
-
provider: string;
|
|
57
|
-
credentials: string;
|
|
58
|
-
};
|
|
59
|
-
});
|
|
60
|
-
getCollection(indexName: string, throwIfNotExists?: boolean): Promise<any>;
|
|
61
|
-
private validateVectorDimensions;
|
|
62
|
-
upsert(...args: ParamsToArgs<ChromaUpsertVectorParams> | ChromaUpsertArgs): Promise<string[]>;
|
|
63
|
-
private HnswSpaceMap;
|
|
64
|
-
createIndex(...args: ParamsToArgs<CreateIndexParams>): Promise<void>;
|
|
65
|
-
transformFilter(filter?: VectorFilter): VectorFilter;
|
|
66
|
-
query(...args: ParamsToArgs<ChromaQueryVectorParams> | ChromaQueryArgs): Promise<QueryResult[]>;
|
|
67
|
-
listIndexes(): Promise<string[]>;
|
|
68
|
-
/**
|
|
69
|
-
* Retrieves statistics about a vector index.
|
|
70
|
-
*
|
|
71
|
-
* @param params - The parameters for describing an index
|
|
72
|
-
* @param params.indexName - The name of the index to describe
|
|
73
|
-
* @returns A promise that resolves to the index statistics including dimension, count and metric
|
|
74
|
-
*/
|
|
75
|
-
describeIndex(...args: ParamsToArgs<DescribeIndexParams>): Promise<IndexStats>;
|
|
76
|
-
deleteIndex(...args: ParamsToArgs<DeleteIndexParams>): Promise<void>;
|
|
77
|
-
/**
|
|
78
|
-
* @deprecated Use {@link updateVector} instead. This method will be removed on May 20th, 2025.
|
|
79
|
-
*
|
|
80
|
-
* Updates a vector by its ID with the provided vector and/or metadata.
|
|
81
|
-
* @param indexName - The name of the index containing the vector.
|
|
82
|
-
* @param id - The ID of the vector to update.
|
|
83
|
-
* @param update - An object containing the vector and/or metadata to update.
|
|
84
|
-
* @param update.vector - An optional array of numbers representing the new vector.
|
|
85
|
-
* @param update.metadata - An optional record containing the new metadata.
|
|
86
|
-
* @returns A promise that resolves when the update is complete.
|
|
87
|
-
* @throws Will throw an error if no updates are provided or if the update operation fails.
|
|
88
|
-
*/
|
|
89
|
-
updateIndexById(indexName: string, id: string, update: {
|
|
90
|
-
vector?: number[];
|
|
91
|
-
metadata?: Record<string, any>;
|
|
92
|
-
}): Promise<void>;
|
|
93
|
-
/**
|
|
94
|
-
* Updates a vector by its ID with the provided vector and/or metadata.
|
|
95
|
-
* @param indexName - The name of the index containing the vector.
|
|
96
|
-
* @param id - The ID of the vector to update.
|
|
97
|
-
* @param update - An object containing the vector and/or metadata to update.
|
|
98
|
-
* @param update.vector - An optional array of numbers representing the new vector.
|
|
99
|
-
* @param update.metadata - An optional record containing the new metadata.
|
|
100
|
-
* @returns A promise that resolves when the update is complete.
|
|
101
|
-
* @throws Will throw an error if no updates are provided or if the update operation fails.
|
|
102
|
-
*/
|
|
103
|
-
updateVector(...args: ParamsToArgs<UpdateVectorParams>): Promise<void>;
|
|
104
|
-
/**
|
|
105
|
-
* @deprecated Use {@link deleteVector} instead. This method will be removed on May 20th, 2025.
|
|
106
|
-
*
|
|
107
|
-
* Deletes a vector by its ID.
|
|
108
|
-
* @param indexName - The name of the index containing the vector.
|
|
109
|
-
* @param id - The ID of the vector to delete.
|
|
110
|
-
* @returns A promise that resolves when the deletion is complete.
|
|
111
|
-
* @throws Will throw an error if the deletion operation fails.
|
|
112
|
-
*/
|
|
113
|
-
deleteIndexById(indexName: string, id: string): Promise<void>;
|
|
114
|
-
/**
|
|
115
|
-
* Deletes a vector by its ID.
|
|
116
|
-
* @param indexName - The name of the index containing the vector.
|
|
117
|
-
* @param id - The ID of the vector to delete.
|
|
118
|
-
* @returns A promise that resolves when the deletion is complete.
|
|
119
|
-
* @throws Will throw an error if the deletion operation fails.
|
|
120
|
-
*/
|
|
121
|
-
deleteVector(...args: ParamsToArgs<DeleteVectorParams>): Promise<void>;
|
|
122
|
-
}
|
|
123
|
-
export { ChromaVector }
|
|
124
|
-
export { ChromaVector as ChromaVector_alias_1 }
|
|
125
|
-
|
|
126
|
-
export { }
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
import { BaseFilterTranslator } from '@mastra/core/vector/filter';
|
|
2
|
-
import type { CreateIndexParams } from '@mastra/core/vector';
|
|
3
|
-
import type { DeleteIndexParams } from '@mastra/core/vector';
|
|
4
|
-
import type { DeleteVectorParams } from '@mastra/core/vector';
|
|
5
|
-
import type { DescribeIndexParams } from '@mastra/core/vector';
|
|
6
|
-
import type { IndexStats } from '@mastra/core/vector';
|
|
7
|
-
import { MastraVector } from '@mastra/core/vector';
|
|
8
|
-
import type { OperatorSupport } from '@mastra/core/vector/filter';
|
|
9
|
-
import type { ParamsToArgs } from '@mastra/core/vector';
|
|
10
|
-
import type { QueryResult } from '@mastra/core/vector';
|
|
11
|
-
import type { QueryVectorArgs } from '@mastra/core/vector';
|
|
12
|
-
import type { QueryVectorParams } from '@mastra/core/vector';
|
|
13
|
-
import type { UpdateVectorParams } from '@mastra/core/vector';
|
|
14
|
-
import type { UpsertVectorArgs } from '@mastra/core/vector';
|
|
15
|
-
import type { UpsertVectorParams } from '@mastra/core/vector';
|
|
16
|
-
import type { VectorFilter } from '@mastra/core/vector/filter';
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Vector store specific prompt that details supported operators and examples.
|
|
20
|
-
* This prompt helps users construct valid filters for Chroma Vector.
|
|
21
|
-
*/
|
|
22
|
-
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\": [{...}] } } }\n\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}";
|
|
23
|
-
export { CHROMA_PROMPT }
|
|
24
|
-
export { CHROMA_PROMPT as CHROMA_PROMPT_alias_1 }
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Translator for Chroma filter queries.
|
|
28
|
-
* Maintains MongoDB-compatible syntax while ensuring proper validation
|
|
29
|
-
* and normalization of values.
|
|
30
|
-
*/
|
|
31
|
-
export declare class ChromaFilterTranslator extends BaseFilterTranslator {
|
|
32
|
-
protected getSupportedOperators(): OperatorSupport;
|
|
33
|
-
translate(filter?: VectorFilter): VectorFilter;
|
|
34
|
-
private translateNode;
|
|
35
|
-
private translateOperator;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
declare type ChromaQueryArgs = [...QueryVectorArgs, VectorFilter?];
|
|
39
|
-
|
|
40
|
-
declare interface ChromaQueryVectorParams extends QueryVectorParams {
|
|
41
|
-
documentFilter?: VectorFilter;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
declare type ChromaUpsertArgs = [...UpsertVectorArgs, string[]?];
|
|
45
|
-
|
|
46
|
-
declare interface ChromaUpsertVectorParams extends UpsertVectorParams {
|
|
47
|
-
documents?: string[];
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
declare class ChromaVector extends MastraVector {
|
|
51
|
-
private client;
|
|
52
|
-
private collections;
|
|
53
|
-
constructor({ path, auth, }: {
|
|
54
|
-
path: string;
|
|
55
|
-
auth?: {
|
|
56
|
-
provider: string;
|
|
57
|
-
credentials: string;
|
|
58
|
-
};
|
|
59
|
-
});
|
|
60
|
-
getCollection(indexName: string, throwIfNotExists?: boolean): Promise<any>;
|
|
61
|
-
private validateVectorDimensions;
|
|
62
|
-
upsert(...args: ParamsToArgs<ChromaUpsertVectorParams> | ChromaUpsertArgs): Promise<string[]>;
|
|
63
|
-
private HnswSpaceMap;
|
|
64
|
-
createIndex(...args: ParamsToArgs<CreateIndexParams>): Promise<void>;
|
|
65
|
-
transformFilter(filter?: VectorFilter): VectorFilter;
|
|
66
|
-
query(...args: ParamsToArgs<ChromaQueryVectorParams> | ChromaQueryArgs): Promise<QueryResult[]>;
|
|
67
|
-
listIndexes(): Promise<string[]>;
|
|
68
|
-
/**
|
|
69
|
-
* Retrieves statistics about a vector index.
|
|
70
|
-
*
|
|
71
|
-
* @param params - The parameters for describing an index
|
|
72
|
-
* @param params.indexName - The name of the index to describe
|
|
73
|
-
* @returns A promise that resolves to the index statistics including dimension, count and metric
|
|
74
|
-
*/
|
|
75
|
-
describeIndex(...args: ParamsToArgs<DescribeIndexParams>): Promise<IndexStats>;
|
|
76
|
-
deleteIndex(...args: ParamsToArgs<DeleteIndexParams>): Promise<void>;
|
|
77
|
-
/**
|
|
78
|
-
* @deprecated Use {@link updateVector} instead. This method will be removed on May 20th, 2025.
|
|
79
|
-
*
|
|
80
|
-
* Updates a vector by its ID with the provided vector and/or metadata.
|
|
81
|
-
* @param indexName - The name of the index containing the vector.
|
|
82
|
-
* @param id - The ID of the vector to update.
|
|
83
|
-
* @param update - An object containing the vector and/or metadata to update.
|
|
84
|
-
* @param update.vector - An optional array of numbers representing the new vector.
|
|
85
|
-
* @param update.metadata - An optional record containing the new metadata.
|
|
86
|
-
* @returns A promise that resolves when the update is complete.
|
|
87
|
-
* @throws Will throw an error if no updates are provided or if the update operation fails.
|
|
88
|
-
*/
|
|
89
|
-
updateIndexById(indexName: string, id: string, update: {
|
|
90
|
-
vector?: number[];
|
|
91
|
-
metadata?: Record<string, any>;
|
|
92
|
-
}): Promise<void>;
|
|
93
|
-
/**
|
|
94
|
-
* Updates a vector by its ID with the provided vector and/or metadata.
|
|
95
|
-
* @param indexName - The name of the index containing the vector.
|
|
96
|
-
* @param id - The ID of the vector to update.
|
|
97
|
-
* @param update - An object containing the vector and/or metadata to update.
|
|
98
|
-
* @param update.vector - An optional array of numbers representing the new vector.
|
|
99
|
-
* @param update.metadata - An optional record containing the new metadata.
|
|
100
|
-
* @returns A promise that resolves when the update is complete.
|
|
101
|
-
* @throws Will throw an error if no updates are provided or if the update operation fails.
|
|
102
|
-
*/
|
|
103
|
-
updateVector(...args: ParamsToArgs<UpdateVectorParams>): Promise<void>;
|
|
104
|
-
/**
|
|
105
|
-
* @deprecated Use {@link deleteVector} instead. This method will be removed on May 20th, 2025.
|
|
106
|
-
*
|
|
107
|
-
* Deletes a vector by its ID.
|
|
108
|
-
* @param indexName - The name of the index containing the vector.
|
|
109
|
-
* @param id - The ID of the vector to delete.
|
|
110
|
-
* @returns A promise that resolves when the deletion is complete.
|
|
111
|
-
* @throws Will throw an error if the deletion operation fails.
|
|
112
|
-
*/
|
|
113
|
-
deleteIndexById(indexName: string, id: string): Promise<void>;
|
|
114
|
-
/**
|
|
115
|
-
* Deletes a vector by its ID.
|
|
116
|
-
* @param indexName - The name of the index containing the vector.
|
|
117
|
-
* @param id - The ID of the vector to delete.
|
|
118
|
-
* @returns A promise that resolves when the deletion is complete.
|
|
119
|
-
* @throws Will throw an error if the deletion operation fails.
|
|
120
|
-
*/
|
|
121
|
-
deleteVector(...args: ParamsToArgs<DeleteVectorParams>): Promise<void>;
|
|
122
|
-
}
|
|
123
|
-
export { ChromaVector }
|
|
124
|
-
export { ChromaVector as ChromaVector_alias_1 }
|
|
125
|
-
|
|
126
|
-
export { }
|
package/dist/index.d.cts
DELETED