@rcrsr/rill-ext-chroma 0.8.5 → 0.9.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/README.md +7 -221
- package/dist/index.d.ts +2 -1
- package/dist/index.js +8 -1
- package/package.json +11 -11
package/README.md
CHANGED
|
@@ -38,230 +38,16 @@ const result = await execute(parse(script), ctx);
|
|
|
38
38
|
dispose?.();
|
|
39
39
|
```
|
|
40
40
|
|
|
41
|
-
##
|
|
42
|
-
|
|
43
|
-
All vector database extensions share identical function signatures. Swap `chroma::` for `qdrant::` or `pinecone::` with no script changes.
|
|
44
|
-
|
|
45
|
-
### chroma::upsert(id, vector, metadata?)
|
|
46
|
-
|
|
47
|
-
Insert or update a single vector with metadata.
|
|
48
|
-
|
|
49
|
-
```rill
|
|
50
|
-
chroma::upsert("doc-1", $embedding, [title: "Example", page: 1]) => $result
|
|
51
|
-
$result.id -> log # "doc-1"
|
|
52
|
-
$result.success -> log # true
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
**Idempotent.** Duplicate ID overwrites existing vector.
|
|
56
|
-
|
|
57
|
-
### chroma::upsert_batch(items)
|
|
58
|
-
|
|
59
|
-
Batch insert or update vectors. Processes sequentially; halts on first failure.
|
|
60
|
-
|
|
61
|
-
```rill
|
|
62
|
-
chroma::upsert_batch([
|
|
63
|
-
[id: "doc-1", vector: $v1, metadata: [title: "First"]],
|
|
64
|
-
[id: "doc-2", vector: $v2, metadata: [title: "Second"]]
|
|
65
|
-
]) => $result
|
|
66
|
-
$result.succeeded -> log # 2
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
Returns `{ succeeded }` on success. Returns `{ succeeded, failed, error }` on failure.
|
|
70
|
-
|
|
71
|
-
### chroma::search(vector, options?)
|
|
72
|
-
|
|
73
|
-
Search for k nearest neighbors.
|
|
74
|
-
|
|
75
|
-
```rill
|
|
76
|
-
chroma::search($embedding, [k: 5, score_threshold: 0.8]) => $results
|
|
77
|
-
$results -> each { "{.id}: {.score}" -> log }
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
| Option | Type | Default | Description |
|
|
81
|
-
|--------|------|---------|-------------|
|
|
82
|
-
| `k` | number | `10` | Max results to return |
|
|
83
|
-
| `filter` | dict | `{}` | Metadata filter conditions |
|
|
84
|
-
| `score_threshold` | number | (none) | Exclude results below threshold |
|
|
85
|
-
|
|
86
|
-
Returns `[{ id, score, metadata }]`. Empty results return `[]`.
|
|
87
|
-
|
|
88
|
-
### chroma::get(id)
|
|
89
|
-
|
|
90
|
-
Fetch a vector by ID.
|
|
91
|
-
|
|
92
|
-
```rill
|
|
93
|
-
chroma::get("doc-1") => $point
|
|
94
|
-
$point.id -> log # "doc-1"
|
|
95
|
-
$point.metadata -> log # [title: "Example", page: 1]
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
Returns `{ id, vector, metadata }`. Halts with error if ID not found.
|
|
99
|
-
|
|
100
|
-
### chroma::delete(id)
|
|
101
|
-
|
|
102
|
-
Delete a vector by ID.
|
|
103
|
-
|
|
104
|
-
```rill
|
|
105
|
-
chroma::delete("doc-1") => $result
|
|
106
|
-
$result.deleted -> log # true
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
Returns `{ id, deleted }`. Halts with error if ID not found.
|
|
110
|
-
|
|
111
|
-
### chroma::delete_batch(ids)
|
|
112
|
-
|
|
113
|
-
Batch delete vectors. Processes sequentially; halts on first failure.
|
|
114
|
-
|
|
115
|
-
```rill
|
|
116
|
-
chroma::delete_batch(["doc-1", "doc-2", "doc-3"]) => $result
|
|
117
|
-
$result.succeeded -> log # 3
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
Returns `{ succeeded }` on success. Returns `{ succeeded, failed, error }` on failure.
|
|
121
|
-
|
|
122
|
-
### chroma::count()
|
|
123
|
-
|
|
124
|
-
Count vectors in the collection.
|
|
125
|
-
|
|
126
|
-
```rill
|
|
127
|
-
chroma::count() -> log # 42
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
Returns a number.
|
|
131
|
-
|
|
132
|
-
### chroma::create_collection(name, options?)
|
|
133
|
-
|
|
134
|
-
Create a new collection.
|
|
135
|
-
|
|
136
|
-
```rill
|
|
137
|
-
chroma::create_collection("my_vectors", [dimensions: 384, distance: "cosine"]) => $result
|
|
138
|
-
$result.created -> log # true
|
|
139
|
-
```
|
|
140
|
-
|
|
141
|
-
| Option | Type | Default | Description |
|
|
142
|
-
|--------|------|---------|-------------|
|
|
143
|
-
| `dimensions` | number | (none) | Vector dimension size |
|
|
144
|
-
| `distance` | string | `"cosine"` | `"cosine"`, `"euclidean"`, or `"dot"` |
|
|
145
|
-
|
|
146
|
-
Returns `{ name, created }`. **Not idempotent** — halts if collection exists.
|
|
147
|
-
|
|
148
|
-
### chroma::delete_collection(id)
|
|
149
|
-
|
|
150
|
-
Delete a collection.
|
|
151
|
-
|
|
152
|
-
```rill
|
|
153
|
-
chroma::delete_collection("old_vectors") => $result
|
|
154
|
-
$result.deleted -> log # true
|
|
155
|
-
```
|
|
156
|
-
|
|
157
|
-
Returns `{ name, deleted }`. **Not idempotent** — halts if collection not found.
|
|
158
|
-
|
|
159
|
-
### chroma::list_collections()
|
|
160
|
-
|
|
161
|
-
List all collection names.
|
|
162
|
-
|
|
163
|
-
```rill
|
|
164
|
-
chroma::list_collections() -> log # ["my_vectors", "archive"]
|
|
165
|
-
```
|
|
166
|
-
|
|
167
|
-
Returns a list of strings.
|
|
168
|
-
|
|
169
|
-
### chroma::describe()
|
|
170
|
-
|
|
171
|
-
Describe the configured collection.
|
|
172
|
-
|
|
173
|
-
```rill
|
|
174
|
-
chroma::describe() => $info
|
|
175
|
-
$info.name -> log # "my_vectors"
|
|
176
|
-
$info.count -> log # 42
|
|
177
|
-
$info.dimensions -> log # 384
|
|
178
|
-
$info.distance -> log # "cosine"
|
|
179
|
-
```
|
|
180
|
-
|
|
181
|
-
Returns `{ name, count, dimensions, distance }`.
|
|
182
|
-
|
|
183
|
-
## Configuration
|
|
184
|
-
|
|
185
|
-
```typescript
|
|
186
|
-
const ext = createChromaExtension({
|
|
187
|
-
url: 'http://localhost:8000',
|
|
188
|
-
collection: 'my_vectors',
|
|
189
|
-
embeddingFunction: 'openai',
|
|
190
|
-
timeout: 30000,
|
|
191
|
-
});
|
|
192
|
-
```
|
|
193
|
-
|
|
194
|
-
| Option | Type | Default | Description |
|
|
195
|
-
|--------|------|---------|-------------|
|
|
196
|
-
| `url` | string | undefined | ChromaDB API endpoint (undefined uses embedded mode) |
|
|
197
|
-
| `collection` | string | required | Default collection name |
|
|
198
|
-
| `embeddingFunction` | string | undefined | Embedding function name |
|
|
199
|
-
| `timeout` | number | SDK default | Request timeout in ms |
|
|
200
|
-
|
|
201
|
-
## Error Handling
|
|
202
|
-
|
|
203
|
-
All errors use `RuntimeError('RILL-R004', 'chroma: <message>')` and halt script execution.
|
|
204
|
-
|
|
205
|
-
| Condition | Message |
|
|
206
|
-
|-----------|---------|
|
|
207
|
-
| HTTP 401 | `chroma: authentication failed (401)` |
|
|
208
|
-
| Collection not found | `chroma: collection not found` |
|
|
209
|
-
| Rate limit (429) | `chroma: rate limit exceeded` |
|
|
210
|
-
| Timeout | `chroma: request timeout` |
|
|
211
|
-
| Dimension mismatch | `chroma: dimension mismatch (expected N, got M)` |
|
|
212
|
-
| Collection exists | `chroma: collection already exists` |
|
|
213
|
-
| ID not found | `chroma: id not found` |
|
|
214
|
-
| After dispose | `chroma: operation cancelled` |
|
|
215
|
-
| Other | `chroma: <error message>` |
|
|
216
|
-
|
|
217
|
-
## Local Setup
|
|
218
|
-
|
|
219
|
-
### Embedded Mode (default)
|
|
220
|
-
|
|
221
|
-
ChromaDB runs in-process without an external server:
|
|
222
|
-
|
|
223
|
-
```typescript
|
|
224
|
-
const ext = createChromaExtension({
|
|
225
|
-
collection: 'test_collection',
|
|
226
|
-
});
|
|
227
|
-
```
|
|
228
|
-
|
|
229
|
-
No Docker or server setup required.
|
|
230
|
-
|
|
231
|
-
### HTTP Server Mode
|
|
232
|
-
|
|
233
|
-
Run ChromaDB with Docker:
|
|
234
|
-
|
|
235
|
-
```bash
|
|
236
|
-
docker run -p 8000:8000 chromadb/chroma
|
|
237
|
-
```
|
|
238
|
-
|
|
239
|
-
Verify: `curl http://localhost:8000/api/v1`
|
|
240
|
-
|
|
241
|
-
```typescript
|
|
242
|
-
const ext = createChromaExtension({
|
|
243
|
-
url: 'http://localhost:8000',
|
|
244
|
-
collection: 'test_collection',
|
|
245
|
-
});
|
|
246
|
-
```
|
|
247
|
-
|
|
248
|
-
## Lifecycle
|
|
249
|
-
|
|
250
|
-
```typescript
|
|
251
|
-
const ext = createChromaExtension({ ... });
|
|
252
|
-
// ... use extension ...
|
|
253
|
-
await ext.dispose?.();
|
|
254
|
-
```
|
|
41
|
+
## Documentation
|
|
255
42
|
|
|
256
|
-
|
|
43
|
+
See [full documentation](docs/extension-vectordb-chroma.md) for configuration, functions, error handling, and local setup.
|
|
257
44
|
|
|
258
|
-
##
|
|
45
|
+
## Related
|
|
259
46
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
| [ChromaDB Documentation](https://docs.trychroma.com) | Official ChromaDB docs |
|
|
47
|
+
- [rill](https://github.com/rcrsr/rill) — Core language runtime
|
|
48
|
+
- [Extensions Guide](https://github.com/rcrsr/rill/blob/main/docs/integration-extensions.md) — Extension contract and patterns
|
|
49
|
+
- [Host API Reference](https://github.com/rcrsr/rill/blob/main/docs/ref-host-api.md) — Runtime context and host functions
|
|
50
|
+
- [ChromaDB Documentation](https://docs.trychroma.com) — Official ChromaDB docs
|
|
265
51
|
|
|
266
52
|
## License
|
|
267
53
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Generated by dts-bundle-generator v9.5.1
|
|
2
2
|
|
|
3
|
-
import { ExtensionResult } from '@rcrsr/rill';
|
|
3
|
+
import { ExtensionConfigSchema, ExtensionResult } from '@rcrsr/rill';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Type definitions for ChromaDB extension.
|
|
@@ -88,6 +88,7 @@ export type ChromaExtensionConfig = ChromaConfig;
|
|
|
88
88
|
* ```
|
|
89
89
|
*/
|
|
90
90
|
export declare function createChromaExtension(config: ChromaConfig): ExtensionResult;
|
|
91
|
+
export declare const configSchema: ExtensionConfigSchema;
|
|
91
92
|
export declare const CHROMA_EXTENSION_VERSION = "0.0.1";
|
|
92
93
|
|
|
93
94
|
export {};
|
package/dist/index.js
CHANGED
|
@@ -565,7 +565,7 @@ function createChromaExtension(config) {
|
|
|
565
565
|
const startTime = Date.now();
|
|
566
566
|
try {
|
|
567
567
|
checkDisposed(disposalState, "chroma");
|
|
568
|
-
const names = await client.listCollections();
|
|
568
|
+
const names = (await client.listCollections()).map((c) => c.name);
|
|
569
569
|
const duration = Date.now() - startTime;
|
|
570
570
|
emitExtensionEvent3(ctx, {
|
|
571
571
|
event: "chroma:list_collections",
|
|
@@ -636,8 +636,15 @@ function createChromaExtension(config) {
|
|
|
636
636
|
}
|
|
637
637
|
|
|
638
638
|
// src/index.ts
|
|
639
|
+
var configSchema = {
|
|
640
|
+
url: { type: "string" },
|
|
641
|
+
collection: { type: "string", required: true },
|
|
642
|
+
embeddingFunction: { type: "string" },
|
|
643
|
+
timeout: { type: "number" }
|
|
644
|
+
};
|
|
639
645
|
var CHROMA_EXTENSION_VERSION = "0.0.1";
|
|
640
646
|
export {
|
|
641
647
|
CHROMA_EXTENSION_VERSION,
|
|
648
|
+
configSchema,
|
|
642
649
|
createChromaExtension
|
|
643
650
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rcrsr/rill-ext-chroma",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "rill extension for ChromaDB vector database integration",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Andre Bremer",
|
|
@@ -18,14 +18,14 @@
|
|
|
18
18
|
"scripting"
|
|
19
19
|
],
|
|
20
20
|
"peerDependencies": {
|
|
21
|
-
"@rcrsr/rill": "^0.
|
|
21
|
+
"@rcrsr/rill": "^0.9.0"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@
|
|
24
|
+
"@rcrsr/rill": "^0.9.0",
|
|
25
|
+
"@types/node": "^25.3.0",
|
|
25
26
|
"dts-bundle-generator": "^9.5.1",
|
|
26
|
-
"tsup": "^8.5.
|
|
27
|
-
"undici-types": "^7.
|
|
28
|
-
"@rcrsr/rill": "^0.8.5",
|
|
27
|
+
"tsup": "^8.5.1",
|
|
28
|
+
"undici-types": "^7.22.0",
|
|
29
29
|
"@rcrsr/rill-ext-vector-shared": "^0.0.1"
|
|
30
30
|
},
|
|
31
31
|
"files": [
|
|
@@ -33,18 +33,18 @@
|
|
|
33
33
|
],
|
|
34
34
|
"repository": {
|
|
35
35
|
"type": "git",
|
|
36
|
-
"url": "git+https://github.com/rcrsr/rill.git",
|
|
37
|
-
"directory": "packages/ext/chroma"
|
|
36
|
+
"url": "git+https://github.com/rcrsr/rill-ext.git",
|
|
37
|
+
"directory": "packages/ext/vectordb-chroma"
|
|
38
38
|
},
|
|
39
|
-
"homepage": "https://
|
|
39
|
+
"homepage": "https://github.com/rcrsr/rill-ext/tree/main/packages/ext/vectordb-chroma#readme",
|
|
40
40
|
"bugs": {
|
|
41
|
-
"url": "https://github.com/rcrsr/rill/issues"
|
|
41
|
+
"url": "https://github.com/rcrsr/rill-ext/issues"
|
|
42
42
|
},
|
|
43
43
|
"publishConfig": {
|
|
44
44
|
"access": "public"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"chromadb": "^
|
|
47
|
+
"chromadb": "^3.3.1"
|
|
48
48
|
},
|
|
49
49
|
"scripts": {
|
|
50
50
|
"build": "tsup && dts-bundle-generator --config dts-bundle-generator.config.cjs",
|