@mastra/chroma 1.0.1 → 1.0.2-alpha.0
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 +9 -0
- package/LICENSE.md +15 -0
- package/dist/docs/SKILL.md +4 -4
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/docs-rag-retrieval.md +19 -16
- package/dist/docs/references/docs-rag-vector-databases.md +13 -13
- package/dist/docs/references/reference-vectors-chroma.md +62 -62
- package/package.json +14 -13
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @mastra/chroma
|
|
2
2
|
|
|
3
|
+
## 1.0.2-alpha.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Security remediation for the 2026-06-17 "easy-day-js" supply-chain incident. Patch bump to publish clean versions and move the `latest` dist-tag forward, superseding the compromised versions that declared the malicious `easy-day-js` dependency. ([#18056](https://github.com/mastra-ai/mastra/pull/18056))
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`77a2351`](https://github.com/mastra-ai/mastra/commit/77a2351ee79296e360bce822cb3391f7cfd6489d)]:
|
|
10
|
+
- @mastra/core@1.43.1-alpha.0
|
|
11
|
+
|
|
3
12
|
## 1.0.1
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
package/LICENSE.md
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
Portions of this software are licensed as follows:
|
|
2
|
+
|
|
3
|
+
- All content that resides under any directory named "ee/" within this
|
|
4
|
+
repository, including but not limited to:
|
|
5
|
+
- `packages/core/src/auth/ee/`
|
|
6
|
+
- `packages/server/src/server/auth/ee/`
|
|
7
|
+
is licensed under the license defined in `ee/LICENSE`.
|
|
8
|
+
|
|
9
|
+
- All third-party components incorporated into the Mastra Software are
|
|
10
|
+
licensed under the original license provided by the owner of the
|
|
11
|
+
applicable component.
|
|
12
|
+
|
|
13
|
+
- Content outside of the above-mentioned directories or restrictions is
|
|
14
|
+
available under the "Apache License 2.0" as defined below.
|
|
15
|
+
|
|
1
16
|
# Apache License 2.0
|
|
2
17
|
|
|
3
18
|
Copyright (c) 2025 Kepler Software, Inc.
|
package/dist/docs/SKILL.md
CHANGED
|
@@ -3,7 +3,7 @@ name: mastra-chroma
|
|
|
3
3
|
description: Documentation for @mastra/chroma. Use when working with @mastra/chroma APIs, configuration, or implementation.
|
|
4
4
|
metadata:
|
|
5
5
|
package: "@mastra/chroma"
|
|
6
|
-
version: "1.0.
|
|
6
|
+
version: "1.0.2-alpha.0"
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
## When to use
|
|
@@ -16,12 +16,12 @@ Read the individual reference documents for detailed explanations and code examp
|
|
|
16
16
|
|
|
17
17
|
### Docs
|
|
18
18
|
|
|
19
|
-
- [Retrieval,
|
|
20
|
-
- [Storing
|
|
19
|
+
- [Retrieval, semantic search, reranking](references/docs-rag-retrieval.md) - Guide on retrieval processes in Mastra's RAG systems, including semantic search, filtering, and re-ranking.
|
|
20
|
+
- [Storing embeddings in a vector database](references/docs-rag-vector-databases.md) - Guide on vector storage options in Mastra, including embedded and dedicated vector databases for similarity search.
|
|
21
21
|
|
|
22
22
|
### Reference
|
|
23
23
|
|
|
24
|
-
- [Reference: Chroma
|
|
24
|
+
- [Reference: Chroma vector store](references/reference-vectors-chroma.md) - Documentation for the ChromaVector class in Mastra, which provides vector search using ChromaDB.
|
|
25
25
|
|
|
26
26
|
|
|
27
27
|
Read [assets/SOURCE_MAP.json](assets/SOURCE_MAP.json) for source code references.
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
# Retrieval in RAG
|
|
1
|
+
# Retrieval in RAG systems
|
|
2
2
|
|
|
3
3
|
After storing embeddings, you need to retrieve relevant chunks to answer user queries.
|
|
4
4
|
|
|
5
5
|
Mastra provides flexible retrieval options with support for semantic search, filtering, and re-ranking.
|
|
6
6
|
|
|
7
|
-
## How
|
|
7
|
+
## How retrieval works
|
|
8
8
|
|
|
9
9
|
1. The user's query is converted to an embedding using the same model used for document embeddings
|
|
10
10
|
2. This embedding is compared to stored embeddings using vector similarity
|
|
@@ -14,7 +14,7 @@ Mastra provides flexible retrieval options with support for semantic search, fil
|
|
|
14
14
|
- Re-ranked for better relevance
|
|
15
15
|
- Processed through a knowledge graph
|
|
16
16
|
|
|
17
|
-
## Basic
|
|
17
|
+
## Basic retrieval
|
|
18
18
|
|
|
19
19
|
The simplest approach is direct semantic search. This method uses vector similarity to find chunks that are semantically similar to the query:
|
|
20
20
|
|
|
@@ -63,7 +63,7 @@ Results include both the text content and a similarity score:
|
|
|
63
63
|
]
|
|
64
64
|
```
|
|
65
65
|
|
|
66
|
-
## Advanced
|
|
66
|
+
## Advanced retrieval options
|
|
67
67
|
|
|
68
68
|
### Metadata Filtering
|
|
69
69
|
|
|
@@ -272,7 +272,7 @@ import { PGVECTOR_PROMPT } from '@mastra/pg'
|
|
|
272
272
|
export const ragAgent = new Agent({
|
|
273
273
|
id: 'rag-agent',
|
|
274
274
|
name: 'RAG Agent',
|
|
275
|
-
model: 'openai/gpt-5.
|
|
275
|
+
model: 'openai/gpt-5.5',
|
|
276
276
|
instructions: `
|
|
277
277
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
278
278
|
${PGVECTOR_PROMPT}
|
|
@@ -289,7 +289,7 @@ import { PINECONE_PROMPT } from '@mastra/pinecone'
|
|
|
289
289
|
export const ragAgent = new Agent({
|
|
290
290
|
id: 'rag-agent',
|
|
291
291
|
name: 'RAG Agent',
|
|
292
|
-
model: 'openai/gpt-5.
|
|
292
|
+
model: 'openai/gpt-5.5',
|
|
293
293
|
instructions: `
|
|
294
294
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
295
295
|
${PINECONE_PROMPT}
|
|
@@ -306,7 +306,7 @@ import { QDRANT_PROMPT } from '@mastra/qdrant'
|
|
|
306
306
|
export const ragAgent = new Agent({
|
|
307
307
|
id: 'rag-agent',
|
|
308
308
|
name: 'RAG Agent',
|
|
309
|
-
model: 'openai/gpt-5.
|
|
309
|
+
model: 'openai/gpt-5.5',
|
|
310
310
|
instructions: `
|
|
311
311
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
312
312
|
${QDRANT_PROMPT}
|
|
@@ -323,7 +323,7 @@ import { CHROMA_PROMPT } from '@mastra/chroma'
|
|
|
323
323
|
export const ragAgent = new Agent({
|
|
324
324
|
id: 'rag-agent',
|
|
325
325
|
name: 'RAG Agent',
|
|
326
|
-
model: 'openai/gpt-5.
|
|
326
|
+
model: 'openai/gpt-5.5',
|
|
327
327
|
instructions: `
|
|
328
328
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
329
329
|
${CHROMA_PROMPT}
|
|
@@ -340,7 +340,7 @@ import { ASTRA_PROMPT } from '@mastra/astra'
|
|
|
340
340
|
export const ragAgent = new Agent({
|
|
341
341
|
id: 'rag-agent',
|
|
342
342
|
name: 'RAG Agent',
|
|
343
|
-
model: 'openai/gpt-5.
|
|
343
|
+
model: 'openai/gpt-5.5',
|
|
344
344
|
instructions: `
|
|
345
345
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
346
346
|
${ASTRA_PROMPT}
|
|
@@ -357,7 +357,7 @@ import { LIBSQL_PROMPT } from '@mastra/libsql'
|
|
|
357
357
|
export const ragAgent = new Agent({
|
|
358
358
|
id: 'rag-agent',
|
|
359
359
|
name: 'RAG Agent',
|
|
360
|
-
model: 'openai/gpt-5.
|
|
360
|
+
model: 'openai/gpt-5.5',
|
|
361
361
|
instructions: `
|
|
362
362
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
363
363
|
${LIBSQL_PROMPT}
|
|
@@ -374,7 +374,7 @@ import { UPSTASH_PROMPT } from '@mastra/upstash'
|
|
|
374
374
|
export const ragAgent = new Agent({
|
|
375
375
|
id: 'rag-agent',
|
|
376
376
|
name: 'RAG Agent',
|
|
377
|
-
model: 'openai/gpt-5.
|
|
377
|
+
model: 'openai/gpt-5.5',
|
|
378
378
|
instructions: `
|
|
379
379
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
380
380
|
${UPSTASH_PROMPT}
|
|
@@ -391,7 +391,7 @@ import { VECTORIZE_PROMPT } from '@mastra/vectorize'
|
|
|
391
391
|
export const ragAgent = new Agent({
|
|
392
392
|
id: 'rag-agent',
|
|
393
393
|
name: 'RAG Agent',
|
|
394
|
-
model: 'openai/gpt-5.
|
|
394
|
+
model: 'openai/gpt-5.5',
|
|
395
395
|
instructions: `
|
|
396
396
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
397
397
|
${VECTORIZE_PROMPT}
|
|
@@ -408,7 +408,7 @@ import { MONGODB_PROMPT } from '@mastra/mongodb'
|
|
|
408
408
|
export const ragAgent = new Agent({
|
|
409
409
|
id: 'rag-agent',
|
|
410
410
|
name: 'RAG Agent',
|
|
411
|
-
model: 'openai/gpt-5.
|
|
411
|
+
model: 'openai/gpt-5.5',
|
|
412
412
|
instructions: `
|
|
413
413
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
414
414
|
${MONGODB_PROMPT}
|
|
@@ -425,7 +425,7 @@ import { OPENSEARCH_PROMPT } from '@mastra/opensearch'
|
|
|
425
425
|
export const ragAgent = new Agent({
|
|
426
426
|
id: 'rag-agent',
|
|
427
427
|
name: 'RAG Agent',
|
|
428
|
-
model: 'openai/gpt-5.
|
|
428
|
+
model: 'openai/gpt-5.5',
|
|
429
429
|
instructions: `
|
|
430
430
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
431
431
|
${OPENSEARCH_PROMPT}
|
|
@@ -442,7 +442,7 @@ import { S3VECTORS_PROMPT } from '@mastra/s3vectors'
|
|
|
442
442
|
export const ragAgent = new Agent({
|
|
443
443
|
id: 'rag-agent',
|
|
444
444
|
name: 'RAG Agent',
|
|
445
|
-
model: 'openai/gpt-5.
|
|
445
|
+
model: 'openai/gpt-5.5',
|
|
446
446
|
instructions: `
|
|
447
447
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
448
448
|
${S3VECTORS_PROMPT}
|
|
@@ -472,7 +472,10 @@ const initialResults = await pgVector.query({
|
|
|
472
472
|
})
|
|
473
473
|
|
|
474
474
|
// Create a relevance scorer
|
|
475
|
-
const relevanceProvider = new MastraAgentRelevanceScorer(
|
|
475
|
+
const relevanceProvider = new MastraAgentRelevanceScorer(
|
|
476
|
+
'relevance-scorer',
|
|
477
|
+
'openai/gpt-5.5',
|
|
478
|
+
)
|
|
476
479
|
|
|
477
480
|
// Re-rank the results
|
|
478
481
|
const rerankedResults = await rerank({
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
# Storing
|
|
1
|
+
# Storing embeddings in a vector database
|
|
2
2
|
|
|
3
3
|
After generating embeddings, you need to store them in a database that supports vector similarity search. Mastra provides a consistent interface for storing and querying embeddings across various vector databases.
|
|
4
4
|
|
|
5
|
-
## Supported
|
|
5
|
+
## Supported databases
|
|
6
6
|
|
|
7
7
|
**MongoDB**:
|
|
8
8
|
|
|
@@ -234,7 +234,7 @@ await store.upsert({
|
|
|
234
234
|
})
|
|
235
235
|
```
|
|
236
236
|
|
|
237
|
-
**
|
|
237
|
+
**Elasticsearch**:
|
|
238
238
|
|
|
239
239
|
```ts
|
|
240
240
|
import { ElasticSearchVector } from '@mastra/elasticsearch'
|
|
@@ -337,7 +337,7 @@ await store.upsert({
|
|
|
337
337
|
})
|
|
338
338
|
```
|
|
339
339
|
|
|
340
|
-
## Using
|
|
340
|
+
## Using vector storage
|
|
341
341
|
|
|
342
342
|
Once initialized, all vector stores share the same interface for creating indexes, upserting embeddings, and querying.
|
|
343
343
|
|
|
@@ -355,11 +355,11 @@ await store.createIndex({
|
|
|
355
355
|
|
|
356
356
|
The dimension size must match the output dimension of your chosen embedding model. Common dimension sizes are:
|
|
357
357
|
|
|
358
|
-
- OpenAI text-embedding-3-small
|
|
359
|
-
- Cohere embed-multilingual-v3
|
|
360
|
-
- Google gemini-embedding-001
|
|
358
|
+
- `OpenAI text-embedding-3-small`: 1536 dimensions (or custom, e.g., 256)
|
|
359
|
+
- `Cohere embed-multilingual-v3`: 1024 dimensions
|
|
360
|
+
- `Google gemini-embedding-001`: 768 dimensions (or custom)
|
|
361
361
|
|
|
362
|
-
> **Warning:** Index dimensions
|
|
362
|
+
> **Warning:** Index dimensions can't be changed after creation. To use a different model, delete and recreate the index with the new dimension size.
|
|
363
363
|
|
|
364
364
|
### Naming Rules for Databases
|
|
365
365
|
|
|
@@ -490,7 +490,7 @@ Index names must:
|
|
|
490
490
|
- Example: `My_Index` is not valid (contains uppercase letters)
|
|
491
491
|
- Example: `_myindex` is not valid (begins with underscore)
|
|
492
492
|
|
|
493
|
-
**
|
|
493
|
+
**Elasticsearch**:
|
|
494
494
|
|
|
495
495
|
Index names must:
|
|
496
496
|
|
|
@@ -543,7 +543,7 @@ The upsert operation:
|
|
|
543
543
|
- Creates new vectors if they don't exist
|
|
544
544
|
- Automatically handles batching for large datasets
|
|
545
545
|
|
|
546
|
-
## Adding
|
|
546
|
+
## Adding metadata
|
|
547
547
|
|
|
548
548
|
Vector stores support rich metadata (any JSON-serializable fields) for filtering and organization. Since metadata is stored with no fixed schema, use consistent field naming to avoid unexpected query results.
|
|
549
549
|
|
|
@@ -581,9 +581,9 @@ Key metadata considerations:
|
|
|
581
581
|
- Only include fields you plan to filter or sort by - extra fields add overhead
|
|
582
582
|
- Add timestamps (e.g., 'createdAt', 'lastUpdated') to track content freshness
|
|
583
583
|
|
|
584
|
-
## Deleting
|
|
584
|
+
## Deleting vectors
|
|
585
585
|
|
|
586
|
-
When building RAG applications, you often need to clean up stale vectors when documents are deleted or updated. Mastra provides the `deleteVectors` method that supports deleting vectors by metadata filters, making it
|
|
586
|
+
When building RAG applications, you often need to clean up stale vectors when documents are deleted or updated. Mastra provides the `deleteVectors` method that supports deleting vectors by metadata filters, making it straightforward to remove all embeddings associated with a specific document.
|
|
587
587
|
|
|
588
588
|
### Delete by Metadata Filter
|
|
589
589
|
|
|
@@ -637,7 +637,7 @@ await store.deleteVectors({
|
|
|
637
637
|
})
|
|
638
638
|
```
|
|
639
639
|
|
|
640
|
-
## Best
|
|
640
|
+
## Best practices
|
|
641
641
|
|
|
642
642
|
- Create indexes before bulk insertions
|
|
643
643
|
- Use batch operations for large insertions (the upsert method handles batching automatically)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Chroma
|
|
1
|
+
# Chroma vector store
|
|
2
2
|
|
|
3
3
|
The ChromaVector class provides vector search using [Chroma](https://docs.trychroma.com/docs/overview/getting-started), an open-source embedding database. It offers efficient vector search with metadata filtering and hybrid search capabilities.
|
|
4
4
|
|
|
@@ -10,27 +10,27 @@ The ChromaVector class provides vector search using [Chroma](https://docs.trychr
|
|
|
10
10
|
>
|
|
11
11
|
> [Get started with Chroma Cloud](https://trychroma.com/signup)
|
|
12
12
|
|
|
13
|
-
## Constructor
|
|
13
|
+
## Constructor options
|
|
14
14
|
|
|
15
|
-
**host
|
|
15
|
+
**host** (`string`): The host address of the Chroma server. Defaults to 'localhost'
|
|
16
16
|
|
|
17
|
-
**port
|
|
17
|
+
**port** (`number`): The port number of the Chroma server. Defaults to 8000
|
|
18
18
|
|
|
19
|
-
**ssl
|
|
19
|
+
**ssl** (`boolean`): Whether to use SSL/HTTPS for connections. Defaults to false
|
|
20
20
|
|
|
21
|
-
**apiKey
|
|
21
|
+
**apiKey** (`string`): A Chroma Cloud API key
|
|
22
22
|
|
|
23
|
-
**tenant
|
|
23
|
+
**tenant** (`string`): The tenant name in the Chroma server to connect to. Defaults to 'default\_tenant' for single-node Chroma. Auto-resolved for Chroma Cloud users based on the provided API key
|
|
24
24
|
|
|
25
|
-
**database
|
|
25
|
+
**database** (`string`): The database name to connect to. Defaults to 'default\_database' for single-node Chroma. Auto-resolved for Chroma Cloud users based on the provided API key
|
|
26
26
|
|
|
27
|
-
**headers
|
|
27
|
+
**headers** (`Record<string, any>`): Additional HTTP headers to send with requests
|
|
28
28
|
|
|
29
|
-
**fetchOptions
|
|
29
|
+
**fetchOptions** (`RequestInit`): Additional fetch options for HTTP requests
|
|
30
30
|
|
|
31
|
-
## Running a Chroma
|
|
31
|
+
## Running a Chroma server
|
|
32
32
|
|
|
33
|
-
If you are a Chroma Cloud user,
|
|
33
|
+
If you are a Chroma Cloud user, provide the `ChromaVector` constructor your API key, tenant, and database name.
|
|
34
34
|
|
|
35
35
|
When you install the `@mastra/chroma` package, you get access to the [Chroma CLI](https://docs.trychroma.com/docs/cli/db), which can set these as environment variables for you: `chroma db connect [DB-NAME] --env-file`.
|
|
36
36
|
|
|
@@ -42,37 +42,37 @@ Otherwise, you have several options for setting up your single-node Chroma serve
|
|
|
42
42
|
|
|
43
43
|
## Methods
|
|
44
44
|
|
|
45
|
-
### createIndex()
|
|
45
|
+
### `createIndex()`
|
|
46
46
|
|
|
47
|
-
**indexName
|
|
47
|
+
**indexName** (`string`): Name of the index to create
|
|
48
48
|
|
|
49
|
-
**dimension
|
|
49
|
+
**dimension** (`number`): Vector dimension (must match your embedding model)
|
|
50
50
|
|
|
51
|
-
**metric
|
|
51
|
+
**metric** (`'cosine' | 'euclidean' | 'dotproduct'`): Distance metric for similarity search (Default: `cosine`)
|
|
52
52
|
|
|
53
|
-
### forkIndex()
|
|
53
|
+
### `forkIndex()`
|
|
54
54
|
|
|
55
55
|
Note: Forking is only supported on Chroma Cloud, or if you deploy your own OSS **distributed** Chroma.
|
|
56
56
|
|
|
57
|
-
`forkIndex` lets you fork an existing Chroma index instantly. Operations on the forked index
|
|
57
|
+
`forkIndex` lets you fork an existing Chroma index instantly. Operations on the forked index don't affect the original one. Learn more on the [Chroma docs](https://docs.trychroma.com/cloud/collection-forking).
|
|
58
58
|
|
|
59
|
-
**indexName
|
|
59
|
+
**indexName** (`string`): Name of the index to fork
|
|
60
60
|
|
|
61
|
-
**newIndexName
|
|
61
|
+
**newIndexName** (`string`): The name of the forked index
|
|
62
62
|
|
|
63
|
-
### upsert()
|
|
63
|
+
### `upsert()`
|
|
64
64
|
|
|
65
|
-
**indexName
|
|
65
|
+
**indexName** (`string`): Name of the index to upsert into
|
|
66
66
|
|
|
67
|
-
**vectors
|
|
67
|
+
**vectors** (`number[][]`): Array of embedding vectors
|
|
68
68
|
|
|
69
|
-
**metadata
|
|
69
|
+
**metadata** (`Record<string, any>[]`): Metadata for each vector
|
|
70
70
|
|
|
71
|
-
**ids
|
|
71
|
+
**ids** (`string[]`): Optional vector IDs (auto-generated if not provided)
|
|
72
72
|
|
|
73
|
-
**documents
|
|
73
|
+
**documents** (`string[]`): Chroma-specific: Original text documents associated with the vectors
|
|
74
74
|
|
|
75
|
-
### query()
|
|
75
|
+
### `query()`
|
|
76
76
|
|
|
77
77
|
Query an index using a `queryVector`. Returns an array of semantically similar records in order of distance from the `queryVector`. Each record has the shape:
|
|
78
78
|
|
|
@@ -88,19 +88,19 @@ Query an index using a `queryVector`. Returns an array of semantically similar r
|
|
|
88
88
|
|
|
89
89
|
You can also provide the shape of your metadata to a `query` call for type inference: `query<T>()`.
|
|
90
90
|
|
|
91
|
-
**indexName
|
|
91
|
+
**indexName** (`string`): Name of the index to query
|
|
92
92
|
|
|
93
|
-
**queryVector
|
|
93
|
+
**queryVector** (`number[]`): Query vector to find similar vectors
|
|
94
94
|
|
|
95
|
-
**topK
|
|
95
|
+
**topK** (`number`): Number of results to return (Default: `10`)
|
|
96
96
|
|
|
97
|
-
**filter
|
|
97
|
+
**filter** (`Record<string, any>`): Metadata filters for the query
|
|
98
98
|
|
|
99
|
-
**includeVector
|
|
99
|
+
**includeVector** (`boolean`): Whether to include vectors in the results (Default: `false`)
|
|
100
100
|
|
|
101
|
-
**documentFilter
|
|
101
|
+
**documentFilter** (`Record<string, any>`): Chroma-specific: Filter to apply on the document content
|
|
102
102
|
|
|
103
|
-
### get()
|
|
103
|
+
### `get()`
|
|
104
104
|
|
|
105
105
|
Get records from your Chroma index by IDs, metadata, and document filters. It returns an array of records of the shape:
|
|
106
106
|
|
|
@@ -115,27 +115,27 @@ Get records from your Chroma index by IDs, metadata, and document filters. It re
|
|
|
115
115
|
|
|
116
116
|
You can also provide the shape of your metadata to a `get` call for type inference: `get<T>()`.
|
|
117
117
|
|
|
118
|
-
**indexName
|
|
118
|
+
**indexName** (`string`): Name of the index to query
|
|
119
119
|
|
|
120
|
-
**ids
|
|
120
|
+
**ids** (`string[]`): A list of record IDs to return. If not provided, all records are returned.
|
|
121
121
|
|
|
122
|
-
**filter
|
|
122
|
+
**filter** (`Record<string, any>`): Metadata filters.
|
|
123
123
|
|
|
124
|
-
**includeVector
|
|
124
|
+
**includeVector** (`boolean`): Whether to include vectors in the results (Default: `false`)
|
|
125
125
|
|
|
126
|
-
**documentFilter
|
|
126
|
+
**documentFilter** (`Record<string, any>`): Chroma-specific: Filter to apply on the document content
|
|
127
127
|
|
|
128
|
-
**limit
|
|
128
|
+
**limit** (`number`): The maximum number of records to return (Default: `100`)
|
|
129
129
|
|
|
130
|
-
**offset
|
|
130
|
+
**offset** (`number`): Offset for returning records. Use with \`limit\` to paginate results.
|
|
131
131
|
|
|
132
|
-
### listIndexes()
|
|
132
|
+
### `listIndexes()`
|
|
133
133
|
|
|
134
134
|
Returns an array of index names as strings.
|
|
135
135
|
|
|
136
|
-
### describeIndex()
|
|
136
|
+
### `describeIndex()`
|
|
137
137
|
|
|
138
|
-
**indexName
|
|
138
|
+
**indexName** (`string`): Name of the index to describe
|
|
139
139
|
|
|
140
140
|
Returns:
|
|
141
141
|
|
|
@@ -147,27 +147,27 @@ interface IndexStats {
|
|
|
147
147
|
}
|
|
148
148
|
```
|
|
149
149
|
|
|
150
|
-
### deleteIndex()
|
|
150
|
+
### `deleteIndex()`
|
|
151
151
|
|
|
152
|
-
**indexName
|
|
152
|
+
**indexName** (`string`): Name of the index to delete
|
|
153
153
|
|
|
154
|
-
### updateVector()
|
|
154
|
+
### `updateVector()`
|
|
155
155
|
|
|
156
156
|
Update a single vector by ID or by metadata filter. Either `id` or `filter` must be provided, but not both.
|
|
157
157
|
|
|
158
|
-
**indexName
|
|
158
|
+
**indexName** (`string`): Name of the index containing the vector to update
|
|
159
159
|
|
|
160
|
-
**id
|
|
160
|
+
**id** (`string`): ID of the vector to update (mutually exclusive with filter)
|
|
161
161
|
|
|
162
|
-
**filter
|
|
162
|
+
**filter** (`Record<string, any>`): Metadata filter to identify vector(s) to update (mutually exclusive with id)
|
|
163
163
|
|
|
164
|
-
**update
|
|
164
|
+
**update** (`object`): Update parameters
|
|
165
165
|
|
|
166
166
|
The `update` object can contain:
|
|
167
167
|
|
|
168
|
-
**vector
|
|
168
|
+
**vector** (`number[]`): New vector to replace the existing one
|
|
169
169
|
|
|
170
|
-
**metadata
|
|
170
|
+
**metadata** (`Record<string, any>`): New metadata to replace the existing metadata
|
|
171
171
|
|
|
172
172
|
Example:
|
|
173
173
|
|
|
@@ -187,21 +187,21 @@ await vectorStore.updateVector({
|
|
|
187
187
|
})
|
|
188
188
|
```
|
|
189
189
|
|
|
190
|
-
### deleteVector()
|
|
190
|
+
### `deleteVector()`
|
|
191
191
|
|
|
192
|
-
**indexName
|
|
192
|
+
**indexName** (`string`): Name of the index containing the vector to delete
|
|
193
193
|
|
|
194
|
-
**id
|
|
194
|
+
**id** (`string`): ID of the vector to delete
|
|
195
195
|
|
|
196
|
-
### deleteVectors()
|
|
196
|
+
### `deleteVectors()`
|
|
197
197
|
|
|
198
198
|
Delete multiple vectors by IDs or by metadata filter. This method enables bulk deletion and source-based vector management. Either `ids` or `filter` must be provided, but not both.
|
|
199
199
|
|
|
200
|
-
**indexName
|
|
200
|
+
**indexName** (`string`): Name of the index containing the vectors to delete
|
|
201
201
|
|
|
202
|
-
**ids
|
|
202
|
+
**ids** (`string[]`): Array of vector IDs to delete (mutually exclusive with filter)
|
|
203
203
|
|
|
204
|
-
**filter
|
|
204
|
+
**filter** (`Record<string, any>`): Metadata filter to identify vectors to delete (mutually exclusive with ids)
|
|
205
205
|
|
|
206
206
|
Example:
|
|
207
207
|
|
|
@@ -227,7 +227,7 @@ await vectorStore.deleteVectors({
|
|
|
227
227
|
})
|
|
228
228
|
```
|
|
229
229
|
|
|
230
|
-
## Response
|
|
230
|
+
## Response types
|
|
231
231
|
|
|
232
232
|
Query results are returned in this format:
|
|
233
233
|
|
|
@@ -241,7 +241,7 @@ interface QueryResult {
|
|
|
241
241
|
}
|
|
242
242
|
```
|
|
243
243
|
|
|
244
|
-
## Error
|
|
244
|
+
## Error handling
|
|
245
245
|
|
|
246
246
|
The store throws typed errors that can be caught:
|
|
247
247
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/chroma",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2-alpha.0",
|
|
4
4
|
"description": "Chroma vector store provider for Mastra",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -20,20 +20,21 @@
|
|
|
20
20
|
},
|
|
21
21
|
"license": "Apache-2.0",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"chromadb": "^3.
|
|
23
|
+
"chromadb": "^3.3.3"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@types/node": "22.19.
|
|
27
|
-
"@vitest/coverage-v8": "4.
|
|
28
|
-
"@vitest/ui": "4.
|
|
29
|
-
"eslint": "^
|
|
26
|
+
"@types/node": "22.19.21",
|
|
27
|
+
"@vitest/coverage-v8": "4.1.8",
|
|
28
|
+
"@vitest/ui": "4.1.8",
|
|
29
|
+
"eslint": "^10.4.1",
|
|
30
30
|
"tsup": "^8.5.1",
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"@internal/
|
|
35
|
-
"@internal/
|
|
36
|
-
"@
|
|
31
|
+
"tsx": "^4.22.4",
|
|
32
|
+
"typescript": "^6.0.3",
|
|
33
|
+
"vitest": "4.1.8",
|
|
34
|
+
"@internal/lint": "0.0.105",
|
|
35
|
+
"@internal/storage-test-utils": "0.0.101",
|
|
36
|
+
"@internal/types-builder": "0.0.80",
|
|
37
|
+
"@mastra/core": "1.43.1-alpha.0"
|
|
37
38
|
},
|
|
38
39
|
"peerDependencies": {
|
|
39
40
|
"@mastra/core": ">=1.0.0-0 <2.0.0-0"
|
|
@@ -57,7 +58,7 @@
|
|
|
57
58
|
"scripts": {
|
|
58
59
|
"build:lib": "tsup --silent --config tsup.config.ts",
|
|
59
60
|
"build:watch": "tsup --watch --silent --config tsup.config.ts",
|
|
60
|
-
"pretest": "docker compose up -d",
|
|
61
|
+
"pretest": "docker compose up -d --wait",
|
|
61
62
|
"posttest": "docker compose down -v",
|
|
62
63
|
"test": "vitest run",
|
|
63
64
|
"lint": "eslint ."
|