@mastra/chroma 1.0.0-beta.3 → 1.0.0-beta.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.
@@ -0,0 +1,189 @@
1
+ # Vectors API Reference
2
+
3
+ > API reference for vectors - 1 entries
4
+
5
+
6
+ ---
7
+
8
+ ## Reference: Chroma Vector Store
9
+
10
+ > Documentation for the ChromaVector class in Mastra, which provides vector search using ChromaDB.
11
+
12
+ The ChromaVector class provides vector search using [Chroma](https://docs.trychroma.com/docs/overview/getting-started), an open-source embedding database.
13
+ It offers efficient vector search with metadata filtering and hybrid search capabilities.
14
+
15
+ > **Note:**
16
+
17
+ <b>Chroma Cloud</b>
18
+
19
+ Chroma Cloud powers serverless vector and full-text search. It's extremely fast, cost-effective, scalable and painless. Create a DB and try it out in under 30 seconds with $5 of free credits.
20
+
21
+ [Get started with Chroma Cloud](https://trychroma.com/signup)
22
+
23
+ ## Constructor Options
24
+
25
+ ## Running a Chroma Server
26
+
27
+ If you are a Chroma Cloud user, simply provide the `ChromaVector` constructor your API key, tenant, and database name.
28
+
29
+ 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`.
30
+
31
+ Otherwise, you have several options for setting up your single-node Chroma server:
32
+
33
+ - Run one locally using the Chroma CLI: `chroma run`. You can find more configuration options on the [Chroma docs](https://docs.trychroma.com/docs/cli/run).
34
+ - Run on [Docker](https://docs.trychroma.com/guides/deploy/docker) using the official Chroma image.
35
+ - Deploy your own Chroma server on your provider of choice. Chroma offers example templates for [AWS](https://docs.trychroma.com/guides/deploy/aws), [Azure](https://docs.trychroma.com/guides/deploy/azure), and [GCP](https://docs.trychroma.com/guides/deploy/gcp).
36
+
37
+ ## Methods
38
+
39
+ ### createIndex()
40
+
41
+ ### forkIndex()
42
+
43
+ Note: Forking is only supported on Chroma Cloud, or if you deploy your own OSS **distributed** Chroma.
44
+
45
+ `forkIndex` lets you fork an existing Chroma index instantly. Operations on the forked index do not affect the original one. Learn more on the [Chroma docs](https://docs.trychroma.com/cloud/collection-forking).
46
+
47
+ ### upsert()
48
+
49
+ ### query()
50
+
51
+ 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:
52
+
53
+ ```typescript
54
+ {
55
+ id: string;
56
+ score: number;
57
+ document?: string;
58
+ metadata?: Record<string, string | number | boolean>;
59
+ embedding?: number[]
60
+ }
61
+ ```
62
+
63
+ You can also provide the shape of your metadata to a `query` call for type inference: `query<T>()`.
64
+
65
+ ### get()
66
+
67
+ Get records from your Chroma index by IDs, metadata, and document filters. It returns an array of records of the shape:
68
+
69
+ ```typescript
70
+ {
71
+ id: string;
72
+ document?: string;
73
+ metadata?: Record<string, string | number | boolean>;
74
+ embedding?: number[]
75
+ }
76
+ ```
77
+
78
+ You can also provide the shape of your metadata to a `get` call for type inference: `get<T>()`.
79
+
80
+ ### listIndexes()
81
+
82
+ Returns an array of index names as strings.
83
+
84
+ ### describeIndex()
85
+
86
+ Returns:
87
+
88
+ ```typescript
89
+ interface IndexStats {
90
+ dimension: number;
91
+ count: number;
92
+ metric: "cosine" | "euclidean" | "dotproduct";
93
+ }
94
+ ```
95
+
96
+ ### deleteIndex()
97
+
98
+ ### updateVector()
99
+
100
+ Update a single vector by ID or by metadata filter. Either `id` or `filter` must be provided, but not both.
101
+
102
+ The `update` object can contain:
103
+
104
+ Example:
105
+
106
+ ```typescript
107
+ // Update by ID
108
+ await vectorStore.updateVector({
109
+ indexName: 'docs',
110
+ id: 'vec_123',
111
+ update: { metadata: { status: 'reviewed' } }
112
+ });
113
+
114
+ // Update by filter
115
+ await vectorStore.updateVector({
116
+ indexName: 'docs',
117
+ filter: { source_id: 'manual.pdf' },
118
+ update: { metadata: { version: 2 } }
119
+ });
120
+ ```
121
+
122
+ ### deleteVector()
123
+
124
+ ### deleteVectors()
125
+
126
+ 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.
127
+
128
+ Example:
129
+
130
+ ```typescript
131
+ // Delete all chunks from a document
132
+ await vectorStore.deleteVectors({
133
+ indexName: 'docs',
134
+ filter: { source_id: 'manual.pdf' }
135
+ });
136
+
137
+ // Delete multiple vectors by ID
138
+ await vectorStore.deleteVectors({
139
+ indexName: 'docs',
140
+ ids: ['vec_1', 'vec_2', 'vec_3']
141
+ });
142
+
143
+ // Delete old temporary documents
144
+ await vectorStore.deleteVectors({
145
+ indexName: 'docs',
146
+ filter: {
147
+ $and: [
148
+ { bucket: 'temp' },
149
+ { indexed_at: { $lt: '2025-01-01' } }
150
+ ]
151
+ }
152
+ });
153
+ ```
154
+
155
+ ## Response Types
156
+
157
+ Query results are returned in this format:
158
+
159
+ ```typescript
160
+ interface QueryResult {
161
+ id: string;
162
+ score: number;
163
+ metadata: Record<string, any>;
164
+ document?: string; // Chroma-specific: Original document if it was stored
165
+ vector?: number[]; // Only included if includeVector is true
166
+ }
167
+ ```
168
+
169
+ ## Error Handling
170
+
171
+ The store throws typed errors that can be caught:
172
+
173
+ ```typescript
174
+ try {
175
+ await store.query({
176
+ indexName: "index_name",
177
+ queryVector: queryVector,
178
+ });
179
+ } catch (error) {
180
+ if (error instanceof VectorStoreError) {
181
+ console.log(error.code); // 'connection_failed' | 'invalid_dimension' | etc
182
+ console.log(error.details); // Additional error context
183
+ }
184
+ }
185
+ ```
186
+
187
+ ## Related
188
+
189
+ - [Metadata Filters](../rag/metadata-filters)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/chroma",
3
- "version": "1.0.0-beta.3",
3
+ "version": "1.0.0-beta.4",
4
4
  "description": "Chroma vector store provider for Mastra",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -23,18 +23,17 @@
23
23
  "chromadb": "^3.1.6"
24
24
  },
25
25
  "devDependencies": {
26
- "@microsoft/api-extractor": "^7.52.8",
27
26
  "@types/node": "22.13.17",
28
27
  "@vitest/coverage-v8": "4.0.12",
29
28
  "@vitest/ui": "4.0.12",
30
29
  "eslint": "^9.37.0",
31
30
  "tsup": "^8.5.0",
32
- "typescript": "^5.8.3",
33
- "vitest": "4.0.12",
31
+ "typescript": "^5.9.3",
32
+ "vitest": "4.0.16",
34
33
  "@internal/lint": "0.0.53",
35
34
  "@internal/storage-test-utils": "0.0.49",
36
- "@mastra/core": "1.0.0-beta.11",
37
- "@internal/types-builder": "0.0.28"
35
+ "@internal/types-builder": "0.0.28",
36
+ "@mastra/core": "1.0.0-beta.20"
38
37
  },
39
38
  "peerDependencies": {
40
39
  "@mastra/core": ">=1.0.0-0 <2.0.0-0"
@@ -56,7 +55,8 @@
56
55
  "node": ">=22.13.0"
57
56
  },
58
57
  "scripts": {
59
- "build": "tsup --silent --config tsup.config.ts",
58
+ "build:lib": "tsup --silent --config tsup.config.ts",
59
+ "build:docs": "pnpx tsx ../../scripts/generate-package-docs.ts stores/chroma",
60
60
  "build:watch": "tsup --watch --silent --config tsup.config.ts",
61
61
  "pretest": "docker compose up -d",
62
62
  "posttest": "docker compose down -v",