@rcrsr/rill-ext-chroma 0.11.0 → 0.16.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/dist/index.d.ts +3 -2
- package/dist/index.js +62 -43
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Generated by dts-bundle-generator v9.5.1
|
|
2
2
|
|
|
3
|
-
import { ExtensionConfigSchema, ExtensionResult } from '@rcrsr/rill';
|
|
3
|
+
import { ExtensionConfigSchema, ExtensionManifest, ExtensionResult } from '@rcrsr/rill';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Type definitions for ChromaDB extension.
|
|
@@ -88,7 +88,8 @@ export type ChromaExtensionConfig = ChromaConfig;
|
|
|
88
88
|
* ```
|
|
89
89
|
*/
|
|
90
90
|
export declare function createChromaExtension(config: ChromaConfig): ExtensionResult;
|
|
91
|
+
export declare const VERSION: string;
|
|
91
92
|
export declare const configSchema: ExtensionConfigSchema;
|
|
92
|
-
export declare const
|
|
93
|
+
export declare const extensionManifest: ExtensionManifest;
|
|
93
94
|
|
|
94
95
|
export {};
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
import { createRequire } from "module";
|
|
3
|
+
|
|
1
4
|
// src/factory.ts
|
|
2
5
|
import { ChromaClient } from "chromadb";
|
|
3
6
|
import {
|
|
4
7
|
RuntimeError as RuntimeError6,
|
|
5
8
|
emitExtensionEvent as emitExtensionEvent3,
|
|
6
|
-
createVector
|
|
9
|
+
createVector,
|
|
10
|
+
rillTypeToTypeValue
|
|
7
11
|
} from "@rcrsr/rill";
|
|
8
12
|
|
|
9
13
|
// ../../shared/ext-vector/dist/errors.js
|
|
@@ -178,13 +182,15 @@ var p = {
|
|
|
178
182
|
* @param name - Parameter name (must be a valid identifier)
|
|
179
183
|
* @param desc - Optional description
|
|
180
184
|
* @param def - Optional default value
|
|
181
|
-
* @
|
|
185
|
+
* @param fields - Optional structural field definitions (RillFieldDef with type and optional defaultValue)
|
|
186
|
+
* @returns RillParam with type 'dict' (with fields if provided)
|
|
182
187
|
*/
|
|
183
|
-
dict(name, desc, def) {
|
|
188
|
+
dict(name, desc, def, fields) {
|
|
184
189
|
validateParamName2(name);
|
|
190
|
+
const type = fields !== void 0 ? { type: "dict", fields } : { type: "dict" };
|
|
185
191
|
return {
|
|
186
192
|
name,
|
|
187
|
-
type
|
|
193
|
+
type,
|
|
188
194
|
defaultValue: def,
|
|
189
195
|
annotations: buildAnnotations(desc)
|
|
190
196
|
};
|
|
@@ -247,9 +253,9 @@ function createChromaExtension(config) {
|
|
|
247
253
|
const startTime = Date.now();
|
|
248
254
|
try {
|
|
249
255
|
checkDisposed(disposalState, "chroma");
|
|
250
|
-
const id = args[
|
|
251
|
-
const vector = args[
|
|
252
|
-
const metadata = args[
|
|
256
|
+
const id = args["id"];
|
|
257
|
+
const vector = args["vector"];
|
|
258
|
+
const metadata = args["metadata"] ?? {};
|
|
253
259
|
const collection = await client.getOrCreateCollection({
|
|
254
260
|
name: factoryCollection
|
|
255
261
|
});
|
|
@@ -282,8 +288,8 @@ function createChromaExtension(config) {
|
|
|
282
288
|
throw rillError;
|
|
283
289
|
}
|
|
284
290
|
},
|
|
285
|
-
description: "Insert or update single vector with metadata",
|
|
286
|
-
returnType: { type: "dict" }
|
|
291
|
+
annotations: { description: "Insert or update single vector with metadata" },
|
|
292
|
+
returnType: rillTypeToTypeValue({ type: "dict", fields: { id: { type: { type: "string" } }, success: { type: { type: "bool" } } } })
|
|
287
293
|
},
|
|
288
294
|
// IR-2: chroma::upsert_batch
|
|
289
295
|
upsert_batch: {
|
|
@@ -292,7 +298,7 @@ function createChromaExtension(config) {
|
|
|
292
298
|
const startTime = Date.now();
|
|
293
299
|
try {
|
|
294
300
|
checkDisposed(disposalState, "chroma");
|
|
295
|
-
const items = args[
|
|
301
|
+
const items = args["items"];
|
|
296
302
|
let succeeded = 0;
|
|
297
303
|
const collection = await client.getOrCreateCollection({
|
|
298
304
|
name: factoryCollection
|
|
@@ -367,21 +373,24 @@ function createChromaExtension(config) {
|
|
|
367
373
|
throw rillError;
|
|
368
374
|
}
|
|
369
375
|
},
|
|
370
|
-
description: "Batch insert/update vectors",
|
|
371
|
-
returnType: { type: "dict" }
|
|
376
|
+
annotations: { description: "Batch insert/update vectors" },
|
|
377
|
+
returnType: rillTypeToTypeValue({ type: "dict", fields: { succeeded: { type: { type: "number" } }, failed: { type: { type: "string" } }, error: { type: { type: "string" } } } })
|
|
372
378
|
},
|
|
373
379
|
// IR-3: chroma::search
|
|
374
380
|
search: {
|
|
375
381
|
params: [
|
|
376
382
|
vectorParam("vector"),
|
|
377
|
-
p.dict("options", void 0, {}
|
|
383
|
+
p.dict("options", void 0, {}, {
|
|
384
|
+
k: { type: { type: "number" }, defaultValue: 10 },
|
|
385
|
+
filter: { type: { type: "dict" }, defaultValue: {} }
|
|
386
|
+
})
|
|
378
387
|
],
|
|
379
388
|
fn: async (args, ctx) => {
|
|
380
389
|
const startTime = Date.now();
|
|
381
390
|
try {
|
|
382
391
|
checkDisposed(disposalState, "chroma");
|
|
383
|
-
const vector = args[
|
|
384
|
-
const options = args[
|
|
392
|
+
const vector = args["vector"];
|
|
393
|
+
const options = args["options"] ?? {};
|
|
385
394
|
const k = typeof options["k"] === "number" ? options["k"] : 10;
|
|
386
395
|
const filter = options["filter"] ?? {};
|
|
387
396
|
const collection = await client.getOrCreateCollection({
|
|
@@ -421,8 +430,8 @@ function createChromaExtension(config) {
|
|
|
421
430
|
throw rillError;
|
|
422
431
|
}
|
|
423
432
|
},
|
|
424
|
-
description: "Search k nearest neighbors",
|
|
425
|
-
returnType: { type: "list" }
|
|
433
|
+
annotations: { description: "Search k nearest neighbors" },
|
|
434
|
+
returnType: rillTypeToTypeValue({ type: "list", element: { type: "dict", fields: { id: { type: { type: "string" } }, score: { type: { type: "number" } }, metadata: { type: { type: "dict" } } } } })
|
|
426
435
|
},
|
|
427
436
|
// IR-4: chroma::get
|
|
428
437
|
get: {
|
|
@@ -431,7 +440,7 @@ function createChromaExtension(config) {
|
|
|
431
440
|
const startTime = Date.now();
|
|
432
441
|
try {
|
|
433
442
|
checkDisposed(disposalState, "chroma");
|
|
434
|
-
const id = args[
|
|
443
|
+
const id = args["id"];
|
|
435
444
|
const collection = await client.getOrCreateCollection({
|
|
436
445
|
name: factoryCollection
|
|
437
446
|
});
|
|
@@ -476,8 +485,8 @@ function createChromaExtension(config) {
|
|
|
476
485
|
throw rillError;
|
|
477
486
|
}
|
|
478
487
|
},
|
|
479
|
-
description: "Fetch vector by ID",
|
|
480
|
-
returnType: { type: "dict" }
|
|
488
|
+
annotations: { description: "Fetch vector by ID" },
|
|
489
|
+
returnType: rillTypeToTypeValue({ type: "dict", fields: { id: { type: { type: "string" } }, vector: { type: { type: "vector" } }, metadata: { type: { type: "dict" } } } })
|
|
481
490
|
},
|
|
482
491
|
// IR-5: chroma::delete
|
|
483
492
|
delete: {
|
|
@@ -486,7 +495,7 @@ function createChromaExtension(config) {
|
|
|
486
495
|
const startTime = Date.now();
|
|
487
496
|
try {
|
|
488
497
|
checkDisposed(disposalState, "chroma");
|
|
489
|
-
const id = args[
|
|
498
|
+
const id = args["id"];
|
|
490
499
|
const collection = await client.getOrCreateCollection({
|
|
491
500
|
name: factoryCollection
|
|
492
501
|
});
|
|
@@ -517,8 +526,8 @@ function createChromaExtension(config) {
|
|
|
517
526
|
throw rillError;
|
|
518
527
|
}
|
|
519
528
|
},
|
|
520
|
-
description: "Delete vector by ID",
|
|
521
|
-
returnType: { type: "dict" }
|
|
529
|
+
annotations: { description: "Delete vector by ID" },
|
|
530
|
+
returnType: rillTypeToTypeValue({ type: "dict", fields: { id: { type: { type: "string" } }, deleted: { type: { type: "bool" } } } })
|
|
522
531
|
},
|
|
523
532
|
// IR-6: chroma::delete_batch
|
|
524
533
|
delete_batch: {
|
|
@@ -527,7 +536,7 @@ function createChromaExtension(config) {
|
|
|
527
536
|
const startTime = Date.now();
|
|
528
537
|
try {
|
|
529
538
|
checkDisposed(disposalState, "chroma");
|
|
530
|
-
const ids = args[
|
|
539
|
+
const ids = args["ids"];
|
|
531
540
|
let succeeded = 0;
|
|
532
541
|
const collection = await client.getOrCreateCollection({
|
|
533
542
|
name: factoryCollection
|
|
@@ -579,8 +588,8 @@ function createChromaExtension(config) {
|
|
|
579
588
|
throw rillError;
|
|
580
589
|
}
|
|
581
590
|
},
|
|
582
|
-
description: "Batch delete vectors",
|
|
583
|
-
returnType: { type: "dict" }
|
|
591
|
+
annotations: { description: "Batch delete vectors" },
|
|
592
|
+
returnType: rillTypeToTypeValue({ type: "dict", fields: { succeeded: { type: { type: "number" } }, failed: { type: { type: "string" } }, error: { type: { type: "string" } } } })
|
|
584
593
|
},
|
|
585
594
|
// IR-7: chroma::count
|
|
586
595
|
count: {
|
|
@@ -613,21 +622,23 @@ function createChromaExtension(config) {
|
|
|
613
622
|
throw rillError;
|
|
614
623
|
}
|
|
615
624
|
},
|
|
616
|
-
description: "Return total vector count in collection",
|
|
617
|
-
returnType: { type: "number" }
|
|
625
|
+
annotations: { description: "Return total vector count in collection" },
|
|
626
|
+
returnType: rillTypeToTypeValue({ type: "number" })
|
|
618
627
|
},
|
|
619
628
|
// IR-8: chroma::create_collection
|
|
620
629
|
create_collection: {
|
|
621
630
|
params: [
|
|
622
631
|
p.str("name"),
|
|
623
|
-
p.dict("options", void 0, {}
|
|
632
|
+
p.dict("options", void 0, {}, {
|
|
633
|
+
metadata: { type: { type: "dict" }, defaultValue: {} }
|
|
634
|
+
})
|
|
624
635
|
],
|
|
625
636
|
fn: async (args, ctx) => {
|
|
626
637
|
const startTime = Date.now();
|
|
627
638
|
try {
|
|
628
639
|
checkDisposed(disposalState, "chroma");
|
|
629
|
-
const name = args[
|
|
630
|
-
const options = args[
|
|
640
|
+
const name = args["name"];
|
|
641
|
+
const options = args["options"] ?? {};
|
|
631
642
|
const metadata = options["metadata"] ?? {};
|
|
632
643
|
await client.createCollection({
|
|
633
644
|
name,
|
|
@@ -657,8 +668,8 @@ function createChromaExtension(config) {
|
|
|
657
668
|
throw rillError;
|
|
658
669
|
}
|
|
659
670
|
},
|
|
660
|
-
description: "Create new vector collection",
|
|
661
|
-
returnType: { type: "dict" }
|
|
671
|
+
annotations: { description: "Create new vector collection" },
|
|
672
|
+
returnType: rillTypeToTypeValue({ type: "dict", fields: { name: { type: { type: "string" } }, created: { type: { type: "bool" } } } })
|
|
662
673
|
},
|
|
663
674
|
// IR-9: chroma::delete_collection
|
|
664
675
|
delete_collection: {
|
|
@@ -667,7 +678,7 @@ function createChromaExtension(config) {
|
|
|
667
678
|
const startTime = Date.now();
|
|
668
679
|
try {
|
|
669
680
|
checkDisposed(disposalState, "chroma");
|
|
670
|
-
const name = args[
|
|
681
|
+
const name = args["name"];
|
|
671
682
|
await client.deleteCollection({ name });
|
|
672
683
|
const result2 = {
|
|
673
684
|
name,
|
|
@@ -693,8 +704,8 @@ function createChromaExtension(config) {
|
|
|
693
704
|
throw rillError;
|
|
694
705
|
}
|
|
695
706
|
},
|
|
696
|
-
description: "Delete vector collection",
|
|
697
|
-
returnType: { type: "dict" }
|
|
707
|
+
annotations: { description: "Delete vector collection" },
|
|
708
|
+
returnType: rillTypeToTypeValue({ type: "dict", fields: { name: { type: { type: "string" } }, deleted: { type: { type: "bool" } } } })
|
|
698
709
|
},
|
|
699
710
|
// IR-10: chroma::list_collections
|
|
700
711
|
list_collections: {
|
|
@@ -724,8 +735,8 @@ function createChromaExtension(config) {
|
|
|
724
735
|
throw rillError;
|
|
725
736
|
}
|
|
726
737
|
},
|
|
727
|
-
description: "List all collection names",
|
|
728
|
-
returnType: { type: "list" }
|
|
738
|
+
annotations: { description: "List all collection names" },
|
|
739
|
+
returnType: rillTypeToTypeValue({ type: "list", element: { type: "string" } })
|
|
729
740
|
},
|
|
730
741
|
// IR-11: chroma::describe
|
|
731
742
|
describe: {
|
|
@@ -762,8 +773,8 @@ function createChromaExtension(config) {
|
|
|
762
773
|
throw rillError;
|
|
763
774
|
}
|
|
764
775
|
},
|
|
765
|
-
description: "Describe configured collection",
|
|
766
|
-
returnType: { type: "dict" }
|
|
776
|
+
annotations: { description: "Describe configured collection" },
|
|
777
|
+
returnType: rillTypeToTypeValue({ type: "dict", fields: { name: { type: { type: "string" } }, count: { type: { type: "number" } } } })
|
|
767
778
|
}
|
|
768
779
|
};
|
|
769
780
|
result.dispose = async () => {
|
|
@@ -774,15 +785,23 @@ function createChromaExtension(config) {
|
|
|
774
785
|
}
|
|
775
786
|
|
|
776
787
|
// src/index.ts
|
|
788
|
+
var _require = createRequire(import.meta.url);
|
|
789
|
+
var _pkg = _require("../package.json");
|
|
790
|
+
var VERSION = _pkg.version;
|
|
777
791
|
var configSchema = {
|
|
778
792
|
url: { type: "string" },
|
|
779
793
|
collection: { type: "string", required: true },
|
|
780
794
|
embeddingFunction: { type: "string" },
|
|
781
795
|
timeout: { type: "number" }
|
|
782
796
|
};
|
|
783
|
-
var
|
|
797
|
+
var extensionManifest = {
|
|
798
|
+
factory: createChromaExtension,
|
|
799
|
+
configSchema,
|
|
800
|
+
version: VERSION
|
|
801
|
+
};
|
|
784
802
|
export {
|
|
785
|
-
|
|
803
|
+
VERSION,
|
|
786
804
|
configSchema,
|
|
787
|
-
createChromaExtension
|
|
805
|
+
createChromaExtension,
|
|
806
|
+
extensionManifest
|
|
788
807
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rcrsr/rill-ext-chroma",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0",
|
|
4
4
|
"description": "rill extension for ChromaDB vector database integration",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Andre Bremer",
|
|
@@ -18,10 +18,10 @@
|
|
|
18
18
|
"scripting"
|
|
19
19
|
],
|
|
20
20
|
"peerDependencies": {
|
|
21
|
-
"@rcrsr/rill": "
|
|
21
|
+
"@rcrsr/rill": "~0.16.0"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@rcrsr/rill": "
|
|
24
|
+
"@rcrsr/rill": "~0.16.0",
|
|
25
25
|
"@types/node": "^25.3.0",
|
|
26
26
|
"dts-bundle-generator": "^9.5.1",
|
|
27
27
|
"tsup": "^8.5.1",
|