@mastra/chroma 0.11.3 → 0.11.4
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 +1 -1
- package/CHANGELOG.md +45 -0
- package/README.md +47 -21
- package/dist/index.cjs +113 -49
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +114 -50
- package/dist/index.js.map +1 -1
- package/dist/vector/filter.d.ts +0 -3
- package/dist/vector/filter.d.ts.map +1 -1
- package/dist/vector/index.d.ts +33 -13
- package/dist/vector/index.d.ts.map +1 -1
- package/package.json +7 -6
- package/src/vector/filter.test.ts +3 -0
- package/src/vector/filter.ts +4 -12
- package/src/vector/index.test.ts +138 -16
- package/src/vector/index.ts +144 -66
package/.turbo/turbo-build.log
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,50 @@
|
|
|
1
1
|
# @mastra/chroma
|
|
2
2
|
|
|
3
|
+
## 0.11.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 8660c1b: Updating Chroma integration and adding support for Chroma Cloud
|
|
8
|
+
- 03997ae: Update peerdeps
|
|
9
|
+
- Updated dependencies [227c7e6]
|
|
10
|
+
- Updated dependencies [12cae67]
|
|
11
|
+
- Updated dependencies [fd3a3eb]
|
|
12
|
+
- Updated dependencies [6faaee5]
|
|
13
|
+
- Updated dependencies [4232b14]
|
|
14
|
+
- Updated dependencies [a89de7e]
|
|
15
|
+
- Updated dependencies [5a37d0c]
|
|
16
|
+
- Updated dependencies [4bde0cb]
|
|
17
|
+
- Updated dependencies [cf4f357]
|
|
18
|
+
- Updated dependencies [ad888a2]
|
|
19
|
+
- Updated dependencies [481751d]
|
|
20
|
+
- Updated dependencies [2454423]
|
|
21
|
+
- Updated dependencies [194e395]
|
|
22
|
+
- Updated dependencies [a722c0b]
|
|
23
|
+
- Updated dependencies [c30bca8]
|
|
24
|
+
- Updated dependencies [3b5fec7]
|
|
25
|
+
- Updated dependencies [a8f129d]
|
|
26
|
+
- @mastra/core@0.14.0
|
|
27
|
+
|
|
28
|
+
## 0.11.4-alpha.1
|
|
29
|
+
|
|
30
|
+
### Patch Changes
|
|
31
|
+
|
|
32
|
+
- 03997ae: Update peerdeps
|
|
33
|
+
- @mastra/core@0.14.0-alpha.7
|
|
34
|
+
|
|
35
|
+
## 0.11.4-alpha.0
|
|
36
|
+
|
|
37
|
+
### Patch Changes
|
|
38
|
+
|
|
39
|
+
- 8660c1b: Updating Chroma integration and adding support for Chroma Cloud
|
|
40
|
+
- Updated dependencies [6faaee5]
|
|
41
|
+
- Updated dependencies [4232b14]
|
|
42
|
+
- Updated dependencies [a89de7e]
|
|
43
|
+
- Updated dependencies [cf4f357]
|
|
44
|
+
- Updated dependencies [a722c0b]
|
|
45
|
+
- Updated dependencies [3b5fec7]
|
|
46
|
+
- @mastra/core@0.14.0-alpha.1
|
|
47
|
+
|
|
3
48
|
## 0.11.3
|
|
4
49
|
|
|
5
50
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @mastra/chroma
|
|
2
2
|
|
|
3
|
-
Vector store implementation for
|
|
3
|
+
Vector store implementation for Chroma using the official `chromadb` client with added dimension validation, collection management, and document storage capabilities.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -8,18 +8,56 @@ Vector store implementation for ChromaDB using the official chromadb client with
|
|
|
8
8
|
npm install @mastra/chroma
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
##
|
|
11
|
+
## Instantiation
|
|
12
|
+
|
|
13
|
+
### Local or Self-Deployments
|
|
14
|
+
|
|
15
|
+
To run a Chroma server, use the [Chroma CLI](https://docs.trychroma.com/docs/cli/db). It is available to you when you install this package.
|
|
16
|
+
|
|
17
|
+
```shell
|
|
18
|
+
chroma run
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
You will now have a Chroma server running on `localhost:8000`.
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
import { ChromaVector } from '@mastra/chroma';
|
|
25
|
+
|
|
26
|
+
const vectorStore = new ChromaVector();
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
If you run a Chroma server locally with a different configuration, or [deploy](https://docs.trychroma.com/guides/deploy/client-server-mode) a Chroma server yourself, you can configure your `ChromaVector` instantiation with specific connection details:
|
|
30
|
+
|
|
31
|
+
```typescript
|
|
32
|
+
import { ChromaVector } from '@mastra/chroma';
|
|
33
|
+
|
|
34
|
+
const vectorStore = new ChromaVector({
|
|
35
|
+
host: 'your-host-address',
|
|
36
|
+
port: 8000,
|
|
37
|
+
ssl: false,
|
|
38
|
+
headers: {}, // any HTTP headers to send,
|
|
39
|
+
});
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Chroma Cloud
|
|
43
|
+
|
|
44
|
+
Provide your Chroma Cloud API key, tenant, and database.
|
|
45
|
+
|
|
46
|
+
You can use the [Chroma CLI](https://docs.trychroma.com/docs/cli/db) to set these as environment variables: `chroma db connect [DB-NAME] --env-file`.
|
|
12
47
|
|
|
13
48
|
```typescript
|
|
14
49
|
import { ChromaVector } from '@mastra/chroma';
|
|
15
50
|
|
|
16
51
|
const vectorStore = new ChromaVector({
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
credentials: 'your-token'
|
|
21
|
-
}
|
|
52
|
+
apiKey: process.env.CHROMA_API_KEY,
|
|
53
|
+
tenant: process.env.CHROMA_TENANT,
|
|
54
|
+
database: process.env.CHROMA_DATABASE,
|
|
22
55
|
});
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Usage
|
|
59
|
+
|
|
60
|
+
```typescript
|
|
23
61
|
|
|
24
62
|
// Create a new collection
|
|
25
63
|
await vectorStore.createIndex({ indexName: 'myCollection', dimension: 1536, metric: 'cosine' });
|
|
@@ -46,18 +84,6 @@ const results = await vectorStore.query({
|
|
|
46
84
|
});
|
|
47
85
|
```
|
|
48
86
|
|
|
49
|
-
## Configuration
|
|
50
|
-
|
|
51
|
-
Required:
|
|
52
|
-
|
|
53
|
-
- `path`: URL of your ChromaDB server
|
|
54
|
-
|
|
55
|
-
Optional:
|
|
56
|
-
|
|
57
|
-
- `auth`: Authentication configuration
|
|
58
|
-
- `provider`: Authentication provider
|
|
59
|
-
- `credentials`: Authentication credentials
|
|
60
|
-
|
|
61
87
|
## Features
|
|
62
88
|
|
|
63
89
|
- Vector similarity search with cosine, euclidean, and dot product metrics
|
|
@@ -92,5 +118,5 @@ Query results include:
|
|
|
92
118
|
|
|
93
119
|
## Related Links
|
|
94
120
|
|
|
95
|
-
- [
|
|
96
|
-
- [
|
|
121
|
+
- [Chroma Documentation](https://docs.trychroma.com/)
|
|
122
|
+
- [Chroma API Reference](https://docs.trychroma.com/api/client)
|
package/dist/index.cjs
CHANGED
|
@@ -24,7 +24,7 @@ var ChromaFilterTranslator = class extends filter.BaseFilterTranslator {
|
|
|
24
24
|
}
|
|
25
25
|
translateNode(node, currentPath = "") {
|
|
26
26
|
if (this.isRegex(node)) {
|
|
27
|
-
throw new Error("Regex is
|
|
27
|
+
throw new Error("Regex is supported in Chroma via the `documentFilter` argument");
|
|
28
28
|
}
|
|
29
29
|
if (this.isPrimitive(node)) return this.normalizeComparisonValue(node);
|
|
30
30
|
if (Array.isArray(node)) return { $in: this.normalizeArrayValues(node) };
|
|
@@ -33,6 +33,9 @@ var ChromaFilterTranslator = class extends filter.BaseFilterTranslator {
|
|
|
33
33
|
if (entries.length === 1 && firstEntry && this.isOperator(firstEntry[0])) {
|
|
34
34
|
const [operator, value] = firstEntry;
|
|
35
35
|
const translated = this.translateOperator(operator, value);
|
|
36
|
+
if (this.isLogicalOperator(operator) && Array.isArray(translated) && translated.length === 1) {
|
|
37
|
+
return translated[0];
|
|
38
|
+
}
|
|
36
39
|
return this.isLogicalOperator(operator) ? { [operator]: translated } : translated;
|
|
37
40
|
}
|
|
38
41
|
const result = {};
|
|
@@ -90,31 +93,46 @@ var ChromaFilterTranslator = class extends filter.BaseFilterTranslator {
|
|
|
90
93
|
};
|
|
91
94
|
|
|
92
95
|
// src/vector/index.ts
|
|
96
|
+
var spaceMappings = {
|
|
97
|
+
cosine: "cosine",
|
|
98
|
+
euclidean: "l2",
|
|
99
|
+
dotproduct: "ip",
|
|
100
|
+
l2: "euclidean",
|
|
101
|
+
ip: "dotproduct"
|
|
102
|
+
};
|
|
93
103
|
var ChromaVector = class extends vector.MastraVector {
|
|
94
104
|
client;
|
|
95
105
|
collections;
|
|
96
|
-
constructor({
|
|
97
|
-
path,
|
|
98
|
-
auth
|
|
99
|
-
}) {
|
|
106
|
+
constructor(chromaClientArgs) {
|
|
100
107
|
super();
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
108
|
+
if (chromaClientArgs?.apiKey) {
|
|
109
|
+
this.client = new chromadb.CloudClient({
|
|
110
|
+
apiKey: chromaClientArgs.apiKey,
|
|
111
|
+
tenant: chromaClientArgs.tenant,
|
|
112
|
+
database: chromaClientArgs.database
|
|
113
|
+
});
|
|
114
|
+
} else {
|
|
115
|
+
this.client = new chromadb.ChromaClient(chromaClientArgs);
|
|
116
|
+
}
|
|
105
117
|
this.collections = /* @__PURE__ */ new Map();
|
|
106
118
|
}
|
|
107
|
-
async getCollection(indexName,
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
119
|
+
async getCollection({ indexName, forceUpdate = false }) {
|
|
120
|
+
let collection = this.collections.get(indexName);
|
|
121
|
+
if (forceUpdate || !collection) {
|
|
122
|
+
try {
|
|
123
|
+
collection = await this.client.getCollection({ name: indexName });
|
|
124
|
+
this.collections.set(indexName, collection);
|
|
125
|
+
return collection;
|
|
126
|
+
} catch {
|
|
127
|
+
throw new error.MastraError({
|
|
128
|
+
id: "CHROMA_COLLECTION_GET_FAILED",
|
|
129
|
+
domain: error.ErrorDomain.MASTRA_VECTOR,
|
|
130
|
+
category: error.ErrorCategory.THIRD_PARTY,
|
|
131
|
+
details: { indexName }
|
|
132
|
+
});
|
|
114
133
|
}
|
|
115
|
-
return null;
|
|
116
134
|
}
|
|
117
|
-
return
|
|
135
|
+
return collection;
|
|
118
136
|
}
|
|
119
137
|
validateVectorDimensions(vectors, dimension) {
|
|
120
138
|
for (let i = 0; i < vectors.length; i++) {
|
|
@@ -127,15 +145,14 @@ var ChromaVector = class extends vector.MastraVector {
|
|
|
127
145
|
}
|
|
128
146
|
async upsert({ indexName, vectors, metadata, ids, documents }) {
|
|
129
147
|
try {
|
|
130
|
-
const collection = await this.getCollection(indexName);
|
|
148
|
+
const collection = await this.getCollection({ indexName });
|
|
131
149
|
const stats = await this.describeIndex({ indexName });
|
|
132
150
|
this.validateVectorDimensions(vectors, stats.dimension);
|
|
133
151
|
const generatedIds = ids || vectors.map(() => crypto.randomUUID());
|
|
134
|
-
const normalizedMetadata = metadata || vectors.map(() => ({}));
|
|
135
152
|
await collection.upsert({
|
|
136
153
|
ids: generatedIds,
|
|
137
154
|
embeddings: vectors,
|
|
138
|
-
metadatas:
|
|
155
|
+
metadatas: metadata,
|
|
139
156
|
documents
|
|
140
157
|
});
|
|
141
158
|
return generatedIds;
|
|
@@ -152,13 +169,6 @@ var ChromaVector = class extends vector.MastraVector {
|
|
|
152
169
|
);
|
|
153
170
|
}
|
|
154
171
|
}
|
|
155
|
-
HnswSpaceMap = {
|
|
156
|
-
cosine: "cosine",
|
|
157
|
-
euclidean: "l2",
|
|
158
|
-
dotproduct: "ip",
|
|
159
|
-
l2: "euclidean",
|
|
160
|
-
ip: "dotproduct"
|
|
161
|
-
};
|
|
162
172
|
async createIndex({ indexName, dimension, metric = "cosine" }) {
|
|
163
173
|
if (!Number.isInteger(dimension) || dimension <= 0) {
|
|
164
174
|
throw new error.MastraError({
|
|
@@ -169,7 +179,7 @@ var ChromaVector = class extends vector.MastraVector {
|
|
|
169
179
|
details: { dimension }
|
|
170
180
|
});
|
|
171
181
|
}
|
|
172
|
-
const hnswSpace =
|
|
182
|
+
const hnswSpace = spaceMappings[metric];
|
|
173
183
|
if (!hnswSpace || !["cosine", "l2", "ip"].includes(hnswSpace)) {
|
|
174
184
|
throw new error.MastraError({
|
|
175
185
|
id: "CHROMA_VECTOR_CREATE_INDEX_INVALID_METRIC",
|
|
@@ -180,13 +190,13 @@ var ChromaVector = class extends vector.MastraVector {
|
|
|
180
190
|
});
|
|
181
191
|
}
|
|
182
192
|
try {
|
|
183
|
-
await this.client.createCollection({
|
|
193
|
+
const collection = await this.client.createCollection({
|
|
184
194
|
name: indexName,
|
|
185
|
-
metadata: {
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
}
|
|
195
|
+
metadata: { dimension },
|
|
196
|
+
configuration: { hnsw: { space: hnswSpace } },
|
|
197
|
+
embeddingFunction: null
|
|
189
198
|
});
|
|
199
|
+
this.collections.set(indexName, collection);
|
|
190
200
|
} catch (error$1) {
|
|
191
201
|
const message = error$1?.message || error$1?.toString();
|
|
192
202
|
if (message && message.toLowerCase().includes("already exists")) {
|
|
@@ -206,7 +216,8 @@ var ChromaVector = class extends vector.MastraVector {
|
|
|
206
216
|
}
|
|
207
217
|
transformFilter(filter) {
|
|
208
218
|
const translator = new ChromaFilterTranslator();
|
|
209
|
-
|
|
219
|
+
const translatedFilter = translator.translate(filter);
|
|
220
|
+
return translatedFilter ? translatedFilter : void 0;
|
|
210
221
|
}
|
|
211
222
|
async query({
|
|
212
223
|
indexName,
|
|
@@ -217,21 +228,21 @@ var ChromaVector = class extends vector.MastraVector {
|
|
|
217
228
|
documentFilter
|
|
218
229
|
}) {
|
|
219
230
|
try {
|
|
220
|
-
const collection = await this.getCollection(indexName
|
|
231
|
+
const collection = await this.getCollection({ indexName });
|
|
221
232
|
const defaultInclude = ["documents", "metadatas", "distances"];
|
|
222
233
|
const translatedFilter = this.transformFilter(filter);
|
|
223
234
|
const results = await collection.query({
|
|
224
235
|
queryEmbeddings: [queryVector],
|
|
225
236
|
nResults: topK,
|
|
226
|
-
where: translatedFilter,
|
|
227
|
-
whereDocument: documentFilter,
|
|
237
|
+
where: translatedFilter ?? void 0,
|
|
238
|
+
whereDocument: documentFilter ?? void 0,
|
|
228
239
|
include: includeVector ? [...defaultInclude, "embeddings"] : defaultInclude
|
|
229
240
|
});
|
|
230
241
|
return (results.ids[0] || []).map((id, index) => ({
|
|
231
242
|
id,
|
|
232
243
|
score: results.distances?.[0]?.[index] || 0,
|
|
233
244
|
metadata: results.metadatas?.[0]?.[index] || {},
|
|
234
|
-
document: results.documents?.[0]?.[index],
|
|
245
|
+
document: results.documents?.[0]?.[index] ?? void 0,
|
|
235
246
|
...includeVector && { vector: results.embeddings?.[0]?.[index] || [] }
|
|
236
247
|
}));
|
|
237
248
|
} catch (error$1) {
|
|
@@ -247,10 +258,45 @@ var ChromaVector = class extends vector.MastraVector {
|
|
|
247
258
|
);
|
|
248
259
|
}
|
|
249
260
|
}
|
|
261
|
+
async get({
|
|
262
|
+
indexName,
|
|
263
|
+
ids,
|
|
264
|
+
filter,
|
|
265
|
+
includeVector = false,
|
|
266
|
+
documentFilter,
|
|
267
|
+
offset,
|
|
268
|
+
limit
|
|
269
|
+
}) {
|
|
270
|
+
try {
|
|
271
|
+
const collection = await this.getCollection({ indexName });
|
|
272
|
+
const defaultInclude = ["documents", "metadatas"];
|
|
273
|
+
const translatedFilter = this.transformFilter(filter);
|
|
274
|
+
const result = await collection.get({
|
|
275
|
+
ids,
|
|
276
|
+
where: translatedFilter ?? void 0,
|
|
277
|
+
whereDocument: documentFilter ?? void 0,
|
|
278
|
+
offset,
|
|
279
|
+
limit,
|
|
280
|
+
include: includeVector ? [...defaultInclude, "embeddings"] : defaultInclude
|
|
281
|
+
});
|
|
282
|
+
return result.rows();
|
|
283
|
+
} catch (error$1) {
|
|
284
|
+
if (error$1 instanceof error.MastraError) throw error$1;
|
|
285
|
+
throw new error.MastraError(
|
|
286
|
+
{
|
|
287
|
+
id: "CHROMA_VECTOR_GET_FAILED",
|
|
288
|
+
domain: error.ErrorDomain.MASTRA_VECTOR,
|
|
289
|
+
category: error.ErrorCategory.THIRD_PARTY,
|
|
290
|
+
details: { indexName }
|
|
291
|
+
},
|
|
292
|
+
error$1
|
|
293
|
+
);
|
|
294
|
+
}
|
|
295
|
+
}
|
|
250
296
|
async listIndexes() {
|
|
251
297
|
try {
|
|
252
298
|
const collections = await this.client.listCollections();
|
|
253
|
-
return collections.map((collection) => collection);
|
|
299
|
+
return collections.map((collection) => collection.name);
|
|
254
300
|
} catch (error$1) {
|
|
255
301
|
throw new error.MastraError(
|
|
256
302
|
{
|
|
@@ -270,14 +316,14 @@ var ChromaVector = class extends vector.MastraVector {
|
|
|
270
316
|
*/
|
|
271
317
|
async describeIndex({ indexName }) {
|
|
272
318
|
try {
|
|
273
|
-
const collection = await this.getCollection(indexName);
|
|
319
|
+
const collection = await this.getCollection({ indexName });
|
|
274
320
|
const count = await collection.count();
|
|
275
321
|
const metadata = collection.metadata;
|
|
276
|
-
const
|
|
322
|
+
const space = collection.configuration.hnsw?.space || collection.configuration.spann?.space || void 0;
|
|
277
323
|
return {
|
|
278
324
|
dimension: metadata?.dimension || 0,
|
|
279
325
|
count,
|
|
280
|
-
metric:
|
|
326
|
+
metric: space ? spaceMappings[space] : void 0
|
|
281
327
|
};
|
|
282
328
|
} catch (error$1) {
|
|
283
329
|
if (error$1 instanceof error.MastraError) throw error$1;
|
|
@@ -308,6 +354,24 @@ var ChromaVector = class extends vector.MastraVector {
|
|
|
308
354
|
);
|
|
309
355
|
}
|
|
310
356
|
}
|
|
357
|
+
async forkIndex({ indexName, newIndexName }) {
|
|
358
|
+
try {
|
|
359
|
+
const collection = await this.getCollection({ indexName, forceUpdate: true });
|
|
360
|
+
const forkedCollection = await collection.fork({ name: newIndexName });
|
|
361
|
+
this.collections.set(newIndexName, forkedCollection);
|
|
362
|
+
} catch (error$1) {
|
|
363
|
+
if (error$1 instanceof error.MastraError) throw error$1;
|
|
364
|
+
throw new error.MastraError(
|
|
365
|
+
{
|
|
366
|
+
id: "CHROMA_INDEX_FORK_FAILED",
|
|
367
|
+
domain: error.ErrorDomain.MASTRA_VECTOR,
|
|
368
|
+
category: error.ErrorCategory.THIRD_PARTY,
|
|
369
|
+
details: { indexName }
|
|
370
|
+
},
|
|
371
|
+
error$1
|
|
372
|
+
);
|
|
373
|
+
}
|
|
374
|
+
}
|
|
311
375
|
/**
|
|
312
376
|
* Updates a vector by its ID with the provided vector and/or metadata.
|
|
313
377
|
* @param indexName - The name of the index containing the vector.
|
|
@@ -329,17 +393,17 @@ var ChromaVector = class extends vector.MastraVector {
|
|
|
329
393
|
});
|
|
330
394
|
}
|
|
331
395
|
try {
|
|
332
|
-
const collection = await this.getCollection(indexName
|
|
333
|
-
const
|
|
396
|
+
const collection = await this.getCollection({ indexName });
|
|
397
|
+
const updateRecordSet = { ids: [id] };
|
|
334
398
|
if (update?.vector) {
|
|
335
399
|
const stats = await this.describeIndex({ indexName });
|
|
336
400
|
this.validateVectorDimensions([update.vector], stats.dimension);
|
|
337
|
-
|
|
401
|
+
updateRecordSet.embeddings = [update.vector];
|
|
338
402
|
}
|
|
339
403
|
if (update?.metadata) {
|
|
340
|
-
|
|
404
|
+
updateRecordSet.metadatas = [update.metadata];
|
|
341
405
|
}
|
|
342
|
-
return await collection.update(
|
|
406
|
+
return await collection.update(updateRecordSet);
|
|
343
407
|
} catch (error$1) {
|
|
344
408
|
if (error$1 instanceof error.MastraError) throw error$1;
|
|
345
409
|
throw new error.MastraError(
|
|
@@ -355,7 +419,7 @@ var ChromaVector = class extends vector.MastraVector {
|
|
|
355
419
|
}
|
|
356
420
|
async deleteVector({ indexName, id }) {
|
|
357
421
|
try {
|
|
358
|
-
const collection = await this.getCollection(indexName
|
|
422
|
+
const collection = await this.getCollection({ indexName });
|
|
359
423
|
await collection.delete({ ids: [id] });
|
|
360
424
|
} catch (error$1) {
|
|
361
425
|
if (error$1 instanceof error.MastraError) throw error$1;
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/vector/filter.ts","../src/vector/index.ts","../src/vector/prompt.ts"],"names":["BaseFilterTranslator","MastraVector","ChromaClient","error","MastraError","ErrorDomain","ErrorCategory"],"mappings":";;;;;;;;AAuCO,IAAM,sBAAA,GAAN,cAAqCA,2BAAA,CAAyC;AAAA,EAChE,qBAAA,GAAyC;AAC1D,IAAA,OAAO;AAAA,MACL,GAAGA,2BAAA,CAAqB,iBAAA;AAAA,MACxB,OAAA,EAAS,CAAC,MAAA,EAAQ,KAAK,CAAA;AAAA,MACvB,KAAA,EAAO,CAAC,KAAA,EAAO,MAAM,CAAA;AAAA,MACrB,SAAS,EAAC;AAAA,MACV,OAAO,EAAC;AAAA,MACR,QAAQ;AAAC,KACX;AAAA,EACF;AAAA,EAEA,UAAU,MAAA,EAAiD;AACzD,IAAA,IAAI,IAAA,CAAK,OAAA,CAAQ,MAAM,CAAA,EAAG,OAAO,MAAA;AACjC,IAAA,IAAA,CAAK,eAAe,MAAM,CAAA;AAE1B,IAAA,OAAO,IAAA,CAAK,cAAc,MAAM,CAAA;AAAA,EAClC;AAAA,EAEQ,aAAA,CAAc,IAAA,EAA0B,WAAA,GAAsB,EAAA,EAAS;AAE7E,IAAA,IAAI,IAAA,CAAK,OAAA,CAAQ,IAAI,CAAA,EAAG;AACtB,MAAA,MAAM,IAAI,MAAM,kCAAkC,CAAA;AAAA,IACpD;AACA,IAAA,IAAI,KAAK,WAAA,CAAY,IAAI,GAAG,OAAO,IAAA,CAAK,yBAAyB,IAAI,CAAA;AACrE,IAAA,IAAI,KAAA,CAAM,OAAA,CAAQ,IAAI,CAAA,EAAG,OAAO,EAAE,GAAA,EAAK,IAAA,CAAK,oBAAA,CAAqB,IAAI,CAAA,EAAE;AAEvE,IAAA,MAAM,OAAA,GAAU,MAAA,CAAO,OAAA,CAAQ,IAA2B,CAAA;AAC1D,IAAA,MAAM,UAAA,GAAa,QAAQ,CAAC,CAAA;AAE5B,IAAA,IA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A,YAAiBC,mBAAa,MAAMD,OAAA;AACxC,MAAA,MAAM,IAAIC,iBAAA;AAAA,QACR;AAAA,UACE,EAAA,EAAI,6BAAA;AAAA,UACJ,QAAQC,iBAAA,CAAY,aAAA;AAAA,UACpB,UAAUC,mBAAA,CAAc,WAAA;AAAA,UACxB,OAAA,EAAS,EAAE,SAAA,EAAW,EAAA;AAAG,SAC3B;AAAA,QACAH;AAAA,OACF;AAAA,IACF;AAAA,EACF;AACF;;;AC/UO,IAAM,aAAA,GAAgB,CAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA","file":"index.cjs","sourcesContent":["import { BaseFilterTranslator } from '@mastra/core/vector/filter';\nimport type {\n VectorFilter,\n OperatorSupport,\n QueryOperator,\n OperatorValueMap,\n LogicalOperatorValueMap,\n BlacklistedRootOperators,\n} from '@mastra/core/vector/filter';\n\ntype ChromaOperatorValueMap = Omit<OperatorValueMap, '$exists' | '$elemMatch' | '$regex' | '$options'>;\n\ntype ChromaLogicalOperatorValueMap = Omit<LogicalOperatorValueMap, '$nor' | '$not'>;\n\ntype ChromaBlacklisted = BlacklistedRootOperators | '$nor' | '$not';\n\nexport type ChromaVectorFilter = VectorFilter<\n keyof ChromaOperatorValueMap,\n ChromaOperatorValueMap,\n ChromaLogicalOperatorValueMap,\n ChromaBlacklisted\n>;\n\ntype ChromaDocumentOperatorValueMap = ChromaOperatorValueMap;\n\ntype ChromaDocumentBlacklisted = Exclude<ChromaBlacklisted, '$contains'>;\n\nexport type ChromaVectorDocumentFilter = VectorFilter<\n keyof ChromaDocumentOperatorValueMap,\n ChromaDocumentOperatorValueMap,\n ChromaLogicalOperatorValueMap,\n ChromaDocumentBlacklisted\n>;\n\n/**\n * Translator for Chroma filter queries.\n * Maintains MongoDB-compatible syntax while ensuring proper validation\n * and normalization of values.\n */\nexport class ChromaFilterTranslator extends BaseFilterTranslator<ChromaVectorFilter> {\n protected override getSupportedOperators(): OperatorSupport {\n return {\n ...BaseFilterTranslator.DEFAULT_OPERATORS,\n logical: ['$and', '$or'],\n array: ['$in', '$nin'],\n element: [],\n regex: [],\n custom: [],\n };\n }\n\n translate(filter?: ChromaVectorFilter): ChromaVectorFilter {\n if (this.isEmpty(filter)) return filter;\n this.validateFilter(filter);\n\n return this.translateNode(filter);\n }\n\n private translateNode(node: ChromaVectorFilter, currentPath: string = ''): any {\n // Handle primitive values and arrays\n if (this.isRegex(node)) {\n throw new Error('Regex is not supported in Chroma');\n }\n if (this.isPrimitive(node)) return this.normalizeComparisonValue(node);\n if (Array.isArray(node)) return { $in: this.normalizeArrayValues(node) };\n\n const entries = Object.entries(node as Record<string, any>);\n const firstEntry = entries[0];\n // Handle single operator case\n if (entries.length === 1 && firstEntry && this.isOperator(firstEntry[0])) {\n const [operator, value] = firstEntry;\n const translated = this.translateOperator(operator, value);\n return this.isLogicalOperator(operator) ? { [operator]: translated } : translated;\n }\n\n // Process each entry\n const result: Record<string, any> = {};\n const multiOperatorConditions: any[] = [];\n\n for (const [key, value] of entries) {\n const newPath = currentPath ? `${currentPath}.${key}` : key;\n\n if (this.isOperator(key)) {\n result[key] = this.translateOperator(key, value);\n continue;\n }\n\n if (typeof value === 'object' && value !== null && !Array.isArray(value)) {\n // Check for multiple operators on same field\n const valueEntries = Object.entries(value);\n if (valueEntries.every(([op]) => this.isOperator(op)) && valueEntries.length > 1) {\n valueEntries.forEach(([op, opValue]) => {\n multiOperatorConditions.push({\n [newPath]: { [op]: this.normalizeComparisonValue(opValue) },\n });\n });\n continue;\n }\n\n // Check if the nested object contains operators\n if (Object.keys(value).length === 0) {\n result[newPath] = this.translateNode(value);\n } else {\n const hasOperators = Object.keys(value).some(k => this.isOperator(k));\n if (hasOperators) {\n // For objects with operators, normalize each operator value\n const normalizedValue: Record<string, any> = {};\n for (const [op, opValue] of Object.entries(value)) {\n normalizedValue[op] = this.isOperator(op) ? this.translateOperator(op, opValue) : opValue;\n }\n result[newPath] = normalizedValue;\n } else {\n // For objects without operators, flatten them\n Object.assign(result, this.translateNode(value, newPath));\n }\n }\n } else {\n result[newPath] = this.translateNode(value);\n }\n }\n\n // If we have multiple operators, return them combined with $and\n if (multiOperatorConditions.length > 0) {\n return { $and: multiOperatorConditions };\n }\n\n // Wrap in $and if there are multiple top-level fields\n if (Object.keys(result).length > 1 && !currentPath) {\n return {\n $and: Object.entries(result).map(([key, value]) => ({ [key]: value })),\n };\n }\n\n return result;\n }\n\n private translateOperator(operator: QueryOperator, value: any): any {\n // Handle logical operators\n if (this.isLogicalOperator(operator)) {\n return Array.isArray(value) ? value.map(item => this.translateNode(item)) : this.translateNode(value);\n }\n\n // Handle comparison and element operators\n return this.normalizeComparisonValue(value);\n }\n}\n","import { MastraError, ErrorDomain, ErrorCategory } from '@mastra/core/error';\nimport { MastraVector } from '@mastra/core/vector';\nimport type {\n QueryResult,\n IndexStats,\n CreateIndexParams,\n UpsertVectorParams,\n QueryVectorParams,\n DescribeIndexParams,\n DeleteIndexParams,\n DeleteVectorParams,\n UpdateVectorParams,\n} from '@mastra/core/vector';\nimport { ChromaClient } from 'chromadb';\nimport type { UpdateRecordsParams, Collection } from 'chromadb';\nimport type { ChromaVectorDocumentFilter, ChromaVectorFilter } from './filter';\nimport { ChromaFilterTranslator } from './filter';\n\ninterface ChromaUpsertVectorParams extends UpsertVectorParams {\n documents?: string[];\n}\n\ninterface ChromaQueryVectorParams extends QueryVectorParams<ChromaVectorFilter> {\n documentFilter?: ChromaVectorDocumentFilter;\n}\n\nexport class ChromaVector extends MastraVector<ChromaVectorFilter> {\n private client: ChromaClient;\n private collections: Map<string, any>;\n\n constructor({\n path,\n auth,\n }: {\n path: string;\n auth?: {\n provider: string;\n credentials: string;\n };\n }) {\n super();\n this.client = new ChromaClient({\n path,\n auth,\n });\n this.collections = new Map();\n }\n\n async getCollection(indexName: string, throwIfNotExists: boolean = true) {\n try {\n const collection = await this.client.getCollection({ name: indexName, embeddingFunction: undefined as any });\n this.collections.set(indexName, collection);\n } catch {\n if (throwIfNotExists) {\n throw new Error(`Index ${indexName} does not exist`);\n }\n return null;\n }\n return this.collections.get(indexName);\n }\n\n private validateVectorDimensions(vectors: number[][], dimension: number): void {\n for (let i = 0; i < vectors.length; i++) {\n if (vectors?.[i]?.length !== dimension) {\n throw new Error(\n `Vector at index ${i} has invalid dimension ${vectors?.[i]?.length}. Expected ${dimension} dimensions.`,\n );\n }\n }\n }\n\n async upsert({ indexName, vectors, metadata, ids, documents }: ChromaUpsertVectorParams): Promise<string[]> {\n try {\n const collection = await this.getCollection(indexName);\n\n const stats = await this.describeIndex({ indexName });\n this.validateVectorDimensions(vectors, stats.dimension);\n const generatedIds = ids || vectors.map(() => crypto.randomUUID());\n const normalizedMetadata = metadata || vectors.map(() => ({}));\n\n await collection.upsert({\n ids: generatedIds,\n embeddings: vectors,\n metadatas: normalizedMetadata,\n documents: documents,\n });\n\n return generatedIds;\n } catch (error: any) {\n if (error instanceof MastraError) throw error;\n throw new MastraError(\n {\n id: 'CHROMA_VECTOR_UPSERT_FAILED',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n private HnswSpaceMap = {\n cosine: 'cosine',\n euclidean: 'l2',\n dotproduct: 'ip',\n l2: 'euclidean',\n ip: 'dotproduct',\n };\n\n async createIndex({ indexName, dimension, metric = 'cosine' }: CreateIndexParams): Promise<void> {\n if (!Number.isInteger(dimension) || dimension <= 0) {\n throw new MastraError({\n id: 'CHROMA_VECTOR_CREATE_INDEX_INVALID_DIMENSION',\n text: 'Dimension must be a positive integer',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.USER,\n details: { dimension },\n });\n }\n const hnswSpace = this.HnswSpaceMap[metric];\n if (!hnswSpace || !['cosine', 'l2', 'ip'].includes(hnswSpace)) {\n throw new MastraError({\n id: 'CHROMA_VECTOR_CREATE_INDEX_INVALID_METRIC',\n text: `Invalid metric: \"${metric}\". Must be one of: cosine, euclidean, dotproduct`,\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.USER,\n details: { metric },\n });\n }\n try {\n await this.client.createCollection({\n name: indexName,\n metadata: {\n dimension,\n 'hnsw:space': hnswSpace,\n },\n });\n } catch (error: any) {\n // Check for 'already exists' error\n const message = error?.message || error?.toString();\n if (message && message.toLowerCase().includes('already exists')) {\n // Fetch collection info and check dimension\n await this.validateExistingIndex(indexName, dimension, metric);\n return;\n }\n throw new MastraError(\n {\n id: 'CHROMA_VECTOR_CREATE_INDEX_FAILED',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n transformFilter(filter?: ChromaVectorFilter) {\n const translator = new ChromaFilterTranslator();\n return translator.translate(filter);\n }\n async query({\n indexName,\n queryVector,\n topK = 10,\n filter,\n includeVector = false,\n documentFilter,\n }: ChromaQueryVectorParams): Promise<QueryResult[]> {\n try {\n const collection = await this.getCollection(indexName, true);\n\n const defaultInclude = ['documents', 'metadatas', 'distances'];\n\n const translatedFilter = this.transformFilter(filter);\n const results = await collection.query({\n queryEmbeddings: [queryVector],\n nResults: topK,\n where: translatedFilter,\n whereDocument: documentFilter,\n include: includeVector ? [...defaultInclude, 'embeddings'] : defaultInclude,\n });\n\n return (results.ids[0] || []).map((id: string, index: number) => ({\n id,\n score: results.distances?.[0]?.[index] || 0,\n metadata: results.metadatas?.[0]?.[index] || {},\n document: results.documents?.[0]?.[index],\n ...(includeVector && { vector: results.embeddings?.[0]?.[index] || [] }),\n }));\n } catch (error: any) {\n if (error instanceof MastraError) throw error;\n throw new MastraError(\n {\n id: 'CHROMA_VECTOR_QUERY_FAILED',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n async listIndexes(): Promise<string[]> {\n try {\n const collections = await this.client.listCollections();\n return collections.map(collection => collection);\n } catch (error: any) {\n throw new MastraError(\n {\n id: 'CHROMA_VECTOR_LIST_INDEXES_FAILED',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.THIRD_PARTY,\n },\n error,\n );\n }\n }\n\n /**\n * Retrieves statistics about a vector index.\n *\n * @param {string} indexName - The name of the index to describe\n * @returns A promise that resolves to the index statistics including dimension, count and metric\n */\n async describeIndex({ indexName }: DescribeIndexParams): Promise<IndexStats> {\n try {\n const collection = await this.getCollection(indexName);\n const count = await collection.count();\n const metadata = collection.metadata;\n\n const hnswSpace = metadata?.['hnsw:space'] as 'cosine' | 'l2' | 'ip';\n\n return {\n dimension: metadata?.dimension || 0,\n count,\n metric: this.HnswSpaceMap[hnswSpace] as 'cosine' | 'euclidean' | 'dotproduct',\n };\n } catch (error: any) {\n if (error instanceof MastraError) throw error;\n throw new MastraError(\n {\n id: 'CHROMA_VECTOR_DESCRIBE_INDEX_FAILED',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n async deleteIndex({ indexName }: DeleteIndexParams): Promise<void> {\n try {\n await this.client.deleteCollection({ name: indexName });\n this.collections.delete(indexName);\n } catch (error: any) {\n throw new MastraError(\n {\n id: 'CHROMA_VECTOR_DELETE_INDEX_FAILED',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n /**\n * Updates a vector by its ID with the provided vector and/or metadata.\n * @param indexName - The name of the index containing the vector.\n * @param id - The ID of the vector to update.\n * @param update - An object containing the vector and/or metadata to update.\n * @param update.vector - An optional array of numbers representing the new vector.\n * @param update.metadata - An optional record containing the new metadata.\n * @returns A promise that resolves when the update is complete.\n * @throws Will throw an error if no updates are provided or if the update operation fails.\n */\n async updateVector({ indexName, id, update }: UpdateVectorParams): Promise<void> {\n if (!update.vector && !update.metadata) {\n throw new MastraError({\n id: 'CHROMA_VECTOR_UPDATE_NO_PAYLOAD',\n text: 'No updates provided for vector',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.USER,\n details: { indexName, id },\n });\n }\n\n try {\n const collection: Collection = await this.getCollection(indexName, true);\n\n const updateOptions: UpdateRecordsParams = { ids: [id] };\n\n if (update?.vector) {\n const stats = await this.describeIndex({ indexName });\n this.validateVectorDimensions([update.vector], stats.dimension);\n updateOptions.embeddings = [update.vector];\n }\n\n if (update?.metadata) {\n updateOptions.metadatas = [update.metadata];\n }\n\n return await collection.update(updateOptions);\n } catch (error: any) {\n if (error instanceof MastraError) throw error;\n throw new MastraError(\n {\n id: 'CHROMA_VECTOR_UPDATE_FAILED',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName, id },\n },\n error,\n );\n }\n }\n\n async deleteVector({ indexName, id }: DeleteVectorParams): Promise<void> {\n try {\n const collection: Collection = await this.getCollection(indexName, true);\n await collection.delete({ ids: [id] });\n } catch (error: any) {\n if (error instanceof MastraError) throw error;\n throw new MastraError(\n {\n id: 'CHROMA_VECTOR_DELETE_FAILED',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName, id },\n },\n error,\n );\n }\n }\n}\n","/**\n * Vector store specific prompt that details supported operators and examples.\n * This prompt helps users construct valid filters for Chroma Vector.\n */\nexport 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}`;\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/vector/filter.ts","../src/vector/index.ts","../src/vector/prompt.ts"],"names":["BaseFilterTranslator","MastraVector","CloudClient","ChromaClient","MastraError","ErrorDomain","ErrorCategory","error"],"mappings":";;;;;;;;AA4BO,IAAM,sBAAA,GAAN,cAAqCA,2BAAA,CAAyC;AAAA,EAChE,qBAAA,GAAyC;AAC1D,IAAA,OAAO;AAAA,MACL,GAAGA,2BAAA,CAAqB,iBAAA;AAAA,MACxB,OAAA,EAAS,CAAC,MAAA,EAAQ,KAAK,CAAA;AAAA,MACvB,KAAA,EAAO,CAAC,KAAA,EAAO,MAAM,CAAA;AAAA,MACrB,SAAS,EAAC;AAAA,MACV,OAAO,EAAC;AAAA,MACR,QAAQ;AAAC,KACX;AAAA,EACF;AAAA,EAEA,UAAU,MAAA,EAAiD;AACzD,IAAA,IAAI,IAAA,CAAK,OAAA,CAAQ,MAAM,CAAA,EAAG,OAAO,MAAA;AACjC,IAAA,IAAA,CAAK,eAAe,MAAM,CAAA;AAE1B,IAAA,OAAO,IAAA,CAAK,cAAc,MAAM,CAAA;AAAA,EAClC;AAAA,EAEQ,aAAA,CAAc,IAAA,EAA0B,WAAA,GAAsB,EAAA,EAAS;AAE7E,IAAA,IAAI,IAAA,CAAK,OAAA,CAAQ,IAAI,CAAA,EAAG;AACtB,MAAA,MAAM,IAAI,MAAM,gEAAgE,CAAA;AAAA,IAClF;AACA,IAAA,IAAI,KAAK,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AA,QACAC;AAAA,OACF;AAAA,IACF;AAAA,EACF;AAAA,EAEA,MAAM,YAAA,CAAa,EAAE,SAAA,EAAW,IAAG,EAAsC;AACvE,IAAA,IAAI;AACF,MAAA,MAAM,aAAyB,MAAM,IAAA,CAAK,aAAA,CAAc,EAAE,WAAW,CAAA;AACrE,MAAA,MAAM,WAAW,MAAA,CAAO,EAAE,KAAK,CAAC,EAAE,GAAG,CAAA;AAAA,IACvC,SAASA,OAAA,EAAY;AACnB,MAAA,IAAIA,OAAA,YAAiBH,mBAAa,MAAMG,OAAA;AACxC,MAAA,MAAM,IAAIH,iBAAA;AAAA,QACR;AAAA,UACE,EAAA,EAAI,6BAAA;AAAA,UACJ,QAAQC,iBAAA,CAAY,aAAA;AAAA,UACpB,UAAUC,mBAAA,CAAc,WAAA;AAAA,UACxB,OAAA,EAAS,EAAE,SAAA,EAAW,EAAA;AAAG,SAC3B;AAAA,QACAC;AAAA,OACF;AAAA,IACF;AAAA,EACF;AACF;;;AC7ZO,IAAM,aAAA,GAAgB,CAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA","file":"index.cjs","sourcesContent":["import { BaseFilterTranslator } from '@mastra/core/vector/filter';\nimport type {\n VectorFilter,\n OperatorSupport,\n QueryOperator,\n OperatorValueMap,\n LogicalOperatorValueMap,\n BlacklistedRootOperators,\n} from '@mastra/core/vector/filter';\n\ntype ChromaOperatorValueMap = Omit<OperatorValueMap, '$exists' | '$elemMatch' | '$regex' | '$options'>;\n\ntype ChromaLogicalOperatorValueMap = Omit<LogicalOperatorValueMap, '$nor' | '$not'>;\n\ntype ChromaBlacklisted = BlacklistedRootOperators | '$nor' | '$not';\n\nexport type ChromaVectorFilter = VectorFilter<\n keyof ChromaOperatorValueMap,\n ChromaOperatorValueMap,\n ChromaLogicalOperatorValueMap,\n ChromaBlacklisted\n>;\n\n/**\n * Translator for Chroma filter queries.\n * Maintains MongoDB-compatible syntax while ensuring proper validation\n * and normalization of values.\n */\nexport class ChromaFilterTranslator extends BaseFilterTranslator<ChromaVectorFilter> {\n protected override getSupportedOperators(): OperatorSupport {\n return {\n ...BaseFilterTranslator.DEFAULT_OPERATORS,\n logical: ['$and', '$or'],\n array: ['$in', '$nin'],\n element: [],\n regex: [],\n custom: [],\n };\n }\n\n translate(filter?: ChromaVectorFilter): ChromaVectorFilter {\n if (this.isEmpty(filter)) return filter;\n this.validateFilter(filter);\n\n return this.translateNode(filter);\n }\n\n private translateNode(node: ChromaVectorFilter, currentPath: string = ''): any {\n // Handle primitive values and arrays\n if (this.isRegex(node)) {\n throw new Error('Regex is supported in Chroma via the `documentFilter` argument');\n }\n if (this.isPrimitive(node)) return this.normalizeComparisonValue(node);\n if (Array.isArray(node)) return { $in: this.normalizeArrayValues(node) };\n\n const entries = Object.entries(node as Record<string, any>);\n const firstEntry = entries[0];\n // Handle single operator case\n if (entries.length === 1 && firstEntry && this.isOperator(firstEntry[0])) {\n const [operator, value] = firstEntry;\n const translated = this.translateOperator(operator, value);\n if (this.isLogicalOperator(operator) && Array.isArray(translated) && translated.length === 1) {\n return translated[0];\n }\n return this.isLogicalOperator(operator) ? { [operator]: translated } : translated;\n }\n\n // Process each entry\n const result: Record<string, any> = {};\n const multiOperatorConditions: any[] = [];\n\n for (const [key, value] of entries) {\n const newPath = currentPath ? `${currentPath}.${key}` : key;\n\n if (this.isOperator(key)) {\n result[key] = this.translateOperator(key, value);\n continue;\n }\n\n if (typeof value === 'object' && value !== null && !Array.isArray(value)) {\n // Check for multiple operators on same field\n const valueEntries = Object.entries(value);\n if (valueEntries.every(([op]) => this.isOperator(op)) && valueEntries.length > 1) {\n valueEntries.forEach(([op, opValue]) => {\n multiOperatorConditions.push({\n [newPath]: { [op]: this.normalizeComparisonValue(opValue) },\n });\n });\n continue;\n }\n\n // Check if the nested object contains operators\n if (Object.keys(value).length === 0) {\n result[newPath] = this.translateNode(value);\n } else {\n const hasOperators = Object.keys(value).some(k => this.isOperator(k));\n if (hasOperators) {\n // For objects with operators, normalize each operator value\n const normalizedValue: Record<string, any> = {};\n for (const [op, opValue] of Object.entries(value)) {\n normalizedValue[op] = this.isOperator(op) ? this.translateOperator(op, opValue) : opValue;\n }\n result[newPath] = normalizedValue;\n } else {\n // For objects without operators, flatten them\n Object.assign(result, this.translateNode(value, newPath));\n }\n }\n } else {\n result[newPath] = this.translateNode(value);\n }\n }\n\n // If we have multiple operators, return them combined with $and\n if (multiOperatorConditions.length > 0) {\n return { $and: multiOperatorConditions };\n }\n\n // Wrap in $and if there are multiple top-level fields\n if (Object.keys(result).length > 1 && !currentPath) {\n return {\n $and: Object.entries(result).map(([key, value]) => ({ [key]: value })),\n };\n }\n\n return result;\n }\n\n private translateOperator(operator: QueryOperator, value: any): any {\n // Handle logical operators\n if (this.isLogicalOperator(operator)) {\n return Array.isArray(value) ? value.map(item => this.translateNode(item)) : this.translateNode(value);\n }\n\n // Handle comparison and element operators\n return this.normalizeComparisonValue(value);\n }\n}\n","import { MastraError, ErrorDomain, ErrorCategory } from '@mastra/core/error';\nimport { MastraVector } from '@mastra/core/vector';\nimport type {\n QueryResult,\n IndexStats,\n CreateIndexParams,\n UpsertVectorParams,\n QueryVectorParams,\n DescribeIndexParams,\n DeleteIndexParams,\n DeleteVectorParams,\n UpdateVectorParams,\n} from '@mastra/core/vector';\nimport { ChromaClient, CloudClient } from 'chromadb';\nimport type { ChromaClientArgs, RecordSet, Where, WhereDocument, Collection, Metadata } from 'chromadb';\nimport type { ChromaVectorFilter } from './filter';\nimport { ChromaFilterTranslator } from './filter';\n\ninterface ChromaUpsertVectorParams extends UpsertVectorParams {\n documents?: string[];\n}\n\ninterface ChromaQueryVectorParams extends QueryVectorParams<ChromaVectorFilter> {\n documentFilter?: WhereDocument | null;\n}\n\ninterface ChromaGetRecordsParams {\n indexName: string;\n ids?: string[];\n filter?: ChromaVectorFilter;\n documentFilter?: WhereDocument | null;\n includeVector?: boolean;\n limit?: number;\n offset?: number;\n}\n\ntype MastraMetadata = {\n dimension?: number;\n};\n\ntype ChromaVectorArgs = ChromaClientArgs & { apiKey?: string };\n\nconst spaceMappings = {\n cosine: 'cosine',\n euclidean: 'l2',\n dotproduct: 'ip',\n l2: 'euclidean',\n ip: 'dotproduct',\n};\n\nexport class ChromaVector extends MastraVector<ChromaVectorFilter> {\n private client: ChromaClient;\n private collections: Map<string, Collection>;\n\n constructor(chromaClientArgs?: ChromaVectorArgs) {\n super();\n if (chromaClientArgs?.apiKey) {\n this.client = new CloudClient({\n apiKey: chromaClientArgs.apiKey,\n tenant: chromaClientArgs.tenant,\n database: chromaClientArgs.database,\n });\n } else {\n this.client = new ChromaClient(chromaClientArgs);\n }\n this.collections = new Map();\n }\n\n async getCollection({ indexName, forceUpdate = false }: { indexName: string; forceUpdate?: boolean }) {\n let collection = this.collections.get(indexName);\n if (forceUpdate || !collection) {\n try {\n collection = await this.client.getCollection({ name: indexName });\n this.collections.set(indexName, collection);\n return collection;\n } catch {\n throw new MastraError({\n id: 'CHROMA_COLLECTION_GET_FAILED',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n });\n }\n }\n return collection;\n }\n\n private validateVectorDimensions(vectors: number[][], dimension: number): void {\n for (let i = 0; i < vectors.length; i++) {\n if (vectors?.[i]?.length !== dimension) {\n throw new Error(\n `Vector at index ${i} has invalid dimension ${vectors?.[i]?.length}. Expected ${dimension} dimensions.`,\n );\n }\n }\n }\n\n async upsert({ indexName, vectors, metadata, ids, documents }: ChromaUpsertVectorParams): Promise<string[]> {\n try {\n const collection = await this.getCollection({ indexName });\n\n const stats = await this.describeIndex({ indexName });\n this.validateVectorDimensions(vectors, stats.dimension);\n const generatedIds = ids || vectors.map(() => crypto.randomUUID());\n\n await collection.upsert({\n ids: generatedIds,\n embeddings: vectors,\n metadatas: metadata,\n documents: documents,\n });\n\n return generatedIds;\n } catch (error: any) {\n if (error instanceof MastraError) throw error;\n throw new MastraError(\n {\n id: 'CHROMA_VECTOR_UPSERT_FAILED',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n async createIndex({ indexName, dimension, metric = 'cosine' }: CreateIndexParams): Promise<void> {\n if (!Number.isInteger(dimension) || dimension <= 0) {\n throw new MastraError({\n id: 'CHROMA_VECTOR_CREATE_INDEX_INVALID_DIMENSION',\n text: 'Dimension must be a positive integer',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.USER,\n details: { dimension },\n });\n }\n\n const hnswSpace = spaceMappings[metric] as 'cosine' | 'l2' | 'ip' | undefined;\n\n if (!hnswSpace || !['cosine', 'l2', 'ip'].includes(hnswSpace)) {\n throw new MastraError({\n id: 'CHROMA_VECTOR_CREATE_INDEX_INVALID_METRIC',\n text: `Invalid metric: \"${metric}\". Must be one of: cosine, euclidean, dotproduct`,\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.USER,\n details: { metric },\n });\n }\n\n try {\n const collection = await this.client.createCollection({\n name: indexName,\n metadata: { dimension },\n configuration: { hnsw: { space: hnswSpace } },\n embeddingFunction: null,\n });\n this.collections.set(indexName, collection);\n } catch (error: any) {\n // Check for 'already exists' error\n const message = error?.message || error?.toString();\n if (message && message.toLowerCase().includes('already exists')) {\n // Fetch collection info and check dimension\n await this.validateExistingIndex(indexName, dimension, metric);\n return;\n }\n throw new MastraError(\n {\n id: 'CHROMA_VECTOR_CREATE_INDEX_FAILED',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n transformFilter(filter?: ChromaVectorFilter) {\n const translator = new ChromaFilterTranslator();\n const translatedFilter = translator.translate(filter);\n return translatedFilter ? (translatedFilter as Where) : undefined;\n }\n\n async query<T extends Metadata = Metadata>({\n indexName,\n queryVector,\n topK = 10,\n filter,\n includeVector = false,\n documentFilter,\n }: ChromaQueryVectorParams): Promise<QueryResult[]> {\n try {\n const collection = await this.getCollection({ indexName });\n\n const defaultInclude: ['documents', 'metadatas', 'distances'] = ['documents', 'metadatas', 'distances'];\n\n const translatedFilter = this.transformFilter(filter);\n const results = await collection.query<T>({\n queryEmbeddings: [queryVector],\n nResults: topK,\n where: translatedFilter ?? undefined,\n whereDocument: documentFilter ?? undefined,\n include: includeVector ? [...defaultInclude, 'embeddings'] : defaultInclude,\n });\n\n return (results.ids[0] || []).map((id: string, index: number) => ({\n id,\n score: results.distances?.[0]?.[index] || 0,\n metadata: results.metadatas?.[0]?.[index] || {},\n document: results.documents?.[0]?.[index] ?? undefined,\n ...(includeVector && { vector: results.embeddings?.[0]?.[index] || [] }),\n }));\n } catch (error: any) {\n if (error instanceof MastraError) throw error;\n throw new MastraError(\n {\n id: 'CHROMA_VECTOR_QUERY_FAILED',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n async get<T extends Metadata = Metadata>({\n indexName,\n ids,\n filter,\n includeVector = false,\n documentFilter,\n offset,\n limit,\n }: ChromaGetRecordsParams) {\n try {\n const collection = await this.getCollection({ indexName });\n\n const defaultInclude: ['documents', 'metadatas'] = ['documents', 'metadatas'];\n const translatedFilter = this.transformFilter(filter);\n\n const result = await collection.get<T>({\n ids,\n where: translatedFilter ?? undefined,\n whereDocument: documentFilter ?? undefined,\n offset,\n limit,\n include: includeVector ? [...defaultInclude, 'embeddings'] : defaultInclude,\n });\n return result.rows();\n } catch (error: any) {\n if (error instanceof MastraError) throw error;\n throw new MastraError(\n {\n id: 'CHROMA_VECTOR_GET_FAILED',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n async listIndexes(): Promise<string[]> {\n try {\n const collections = await this.client.listCollections();\n return collections.map(collection => collection.name);\n } catch (error: any) {\n throw new MastraError(\n {\n id: 'CHROMA_VECTOR_LIST_INDEXES_FAILED',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.THIRD_PARTY,\n },\n error,\n );\n }\n }\n\n /**\n * Retrieves statistics about a vector index.\n *\n * @param {string} indexName - The name of the index to describe\n * @returns A promise that resolves to the index statistics including dimension, count and metric\n */\n async describeIndex({ indexName }: DescribeIndexParams): Promise<IndexStats> {\n try {\n const collection = await this.getCollection({ indexName });\n const count = await collection.count();\n const metadata = collection.metadata as MastraMetadata | undefined;\n const space = collection.configuration.hnsw?.space || collection.configuration.spann?.space || undefined;\n\n return {\n dimension: metadata?.dimension || 0,\n count,\n metric: space ? (spaceMappings[space] as 'cosine' | 'euclidean' | 'dotproduct') : undefined,\n };\n } catch (error: any) {\n if (error instanceof MastraError) throw error;\n throw new MastraError(\n {\n id: 'CHROMA_VECTOR_DESCRIBE_INDEX_FAILED',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n async deleteIndex({ indexName }: DeleteIndexParams): Promise<void> {\n try {\n await this.client.deleteCollection({ name: indexName });\n this.collections.delete(indexName);\n } catch (error: any) {\n throw new MastraError(\n {\n id: 'CHROMA_VECTOR_DELETE_INDEX_FAILED',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n async forkIndex({ indexName, newIndexName }: { indexName: string; newIndexName: string }): Promise<void> {\n try {\n const collection = await this.getCollection({ indexName, forceUpdate: true });\n const forkedCollection = await collection.fork({ name: newIndexName });\n this.collections.set(newIndexName, forkedCollection);\n } catch (error: any) {\n if (error instanceof MastraError) throw error;\n throw new MastraError(\n {\n id: 'CHROMA_INDEX_FORK_FAILED',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n /**\n * Updates a vector by its ID with the provided vector and/or metadata.\n * @param indexName - The name of the index containing the vector.\n * @param id - The ID of the vector to update.\n * @param update - An object containing the vector and/or metadata to update.\n * @param update.vector - An optional array of numbers representing the new vector.\n * @param update.metadata - An optional record containing the new metadata.\n * @returns A promise that resolves when the update is complete.\n * @throws Will throw an error if no updates are provided or if the update operation fails.\n */\n async updateVector({ indexName, id, update }: UpdateVectorParams): Promise<void> {\n if (!update.vector && !update.metadata) {\n throw new MastraError({\n id: 'CHROMA_VECTOR_UPDATE_NO_PAYLOAD',\n text: 'No updates provided for vector',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.USER,\n details: { indexName, id },\n });\n }\n\n try {\n const collection: Collection = await this.getCollection({ indexName });\n\n const updateRecordSet: RecordSet = { ids: [id] };\n\n if (update?.vector) {\n const stats = await this.describeIndex({ indexName });\n this.validateVectorDimensions([update.vector], stats.dimension);\n updateRecordSet.embeddings = [update.vector];\n }\n\n if (update?.metadata) {\n updateRecordSet.metadatas = [update.metadata];\n }\n\n return await collection.update(updateRecordSet);\n } catch (error: any) {\n if (error instanceof MastraError) throw error;\n throw new MastraError(\n {\n id: 'CHROMA_VECTOR_UPDATE_FAILED',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName, id },\n },\n error,\n );\n }\n }\n\n async deleteVector({ indexName, id }: DeleteVectorParams): Promise<void> {\n try {\n const collection: Collection = await this.getCollection({ indexName });\n await collection.delete({ ids: [id] });\n } catch (error: any) {\n if (error instanceof MastraError) throw error;\n throw new MastraError(\n {\n id: 'CHROMA_VECTOR_DELETE_FAILED',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName, id },\n },\n error,\n );\n }\n }\n}\n","/**\n * Vector store specific prompt that details supported operators and examples.\n * This prompt helps users construct valid filters for Chroma Vector.\n */\nexport 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}`;\n"]}
|