@rcrsr/rill-ext-pinecone 0.9.0 → 0.11.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.js +167 -29
- package/package.json +5 -4
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// src/factory.ts
|
|
2
2
|
import { Pinecone } from "@pinecone-database/pinecone";
|
|
3
3
|
import {
|
|
4
|
-
RuntimeError as
|
|
4
|
+
RuntimeError as RuntimeError6,
|
|
5
5
|
emitExtensionEvent as emitExtensionEvent3,
|
|
6
6
|
createVector
|
|
7
7
|
} from "@rcrsr/rill";
|
|
@@ -111,18 +111,156 @@ function assertRequired(value, fieldName) {
|
|
|
111
111
|
// ../../shared/ext-vector/dist/wrapper.js
|
|
112
112
|
import { emitExtensionEvent as emitExtensionEvent2 } from "@rcrsr/rill";
|
|
113
113
|
|
|
114
|
+
// ../../shared/ext-vector/dist/param.js
|
|
115
|
+
import { RuntimeError as RuntimeError4 } from "@rcrsr/rill";
|
|
116
|
+
function validateParamName(name) {
|
|
117
|
+
if (name === "")
|
|
118
|
+
throw new RuntimeError4("RILL-R001", "param name must not be empty");
|
|
119
|
+
if (/\s/.test(name))
|
|
120
|
+
throw new RuntimeError4("RILL-R001", "param name must be a valid identifier");
|
|
121
|
+
}
|
|
122
|
+
function vectorParam(name) {
|
|
123
|
+
validateParamName(name);
|
|
124
|
+
return {
|
|
125
|
+
name,
|
|
126
|
+
type: { type: "vector" },
|
|
127
|
+
defaultValue: void 0,
|
|
128
|
+
annotations: {}
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// ../../shared/ext-param/dist/param.js
|
|
133
|
+
import { RuntimeError as RuntimeError5 } from "@rcrsr/rill";
|
|
134
|
+
function validateParamName2(name) {
|
|
135
|
+
if (name === "") {
|
|
136
|
+
throw new RuntimeError5("RILL-R001", "param name must not be empty");
|
|
137
|
+
}
|
|
138
|
+
if (/\s/.test(name)) {
|
|
139
|
+
throw new RuntimeError5("RILL-R001", "param name must be a valid identifier");
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
function buildAnnotations(desc) {
|
|
143
|
+
if (desc !== void 0) {
|
|
144
|
+
return { description: desc };
|
|
145
|
+
}
|
|
146
|
+
return {};
|
|
147
|
+
}
|
|
148
|
+
var p = {
|
|
149
|
+
/**
|
|
150
|
+
* IR-1: Creates a string parameter descriptor.
|
|
151
|
+
*
|
|
152
|
+
* @param name - Parameter name (must be a valid identifier)
|
|
153
|
+
* @param desc - Optional description
|
|
154
|
+
* @returns RillParam with type 'string'
|
|
155
|
+
*/
|
|
156
|
+
str(name, desc) {
|
|
157
|
+
validateParamName2(name);
|
|
158
|
+
return {
|
|
159
|
+
name,
|
|
160
|
+
type: { type: "string" },
|
|
161
|
+
defaultValue: void 0,
|
|
162
|
+
annotations: buildAnnotations(desc)
|
|
163
|
+
};
|
|
164
|
+
},
|
|
165
|
+
/**
|
|
166
|
+
* IR-2: Creates a number parameter descriptor.
|
|
167
|
+
*
|
|
168
|
+
* @param name - Parameter name (must be a valid identifier)
|
|
169
|
+
* @param desc - Optional description
|
|
170
|
+
* @param def - Optional default value
|
|
171
|
+
* @returns RillParam with type 'number'
|
|
172
|
+
*/
|
|
173
|
+
num(name, desc, def) {
|
|
174
|
+
validateParamName2(name);
|
|
175
|
+
return {
|
|
176
|
+
name,
|
|
177
|
+
type: { type: "number" },
|
|
178
|
+
defaultValue: def,
|
|
179
|
+
annotations: buildAnnotations(desc)
|
|
180
|
+
};
|
|
181
|
+
},
|
|
182
|
+
/**
|
|
183
|
+
* IR-3: Creates a boolean parameter descriptor.
|
|
184
|
+
*
|
|
185
|
+
* @param name - Parameter name (must be a valid identifier)
|
|
186
|
+
* @param desc - Optional description
|
|
187
|
+
* @param def - Optional default value
|
|
188
|
+
* @returns RillParam with type 'bool'
|
|
189
|
+
*/
|
|
190
|
+
bool(name, desc, def) {
|
|
191
|
+
validateParamName2(name);
|
|
192
|
+
return {
|
|
193
|
+
name,
|
|
194
|
+
type: { type: "bool" },
|
|
195
|
+
defaultValue: def,
|
|
196
|
+
annotations: buildAnnotations(desc)
|
|
197
|
+
};
|
|
198
|
+
},
|
|
199
|
+
/**
|
|
200
|
+
* IR-4: Creates a dict parameter descriptor.
|
|
201
|
+
*
|
|
202
|
+
* @param name - Parameter name (must be a valid identifier)
|
|
203
|
+
* @param desc - Optional description
|
|
204
|
+
* @param def - Optional default value
|
|
205
|
+
* @returns RillParam with type 'dict'
|
|
206
|
+
*/
|
|
207
|
+
dict(name, desc, def) {
|
|
208
|
+
validateParamName2(name);
|
|
209
|
+
return {
|
|
210
|
+
name,
|
|
211
|
+
type: { type: "dict" },
|
|
212
|
+
defaultValue: def,
|
|
213
|
+
annotations: buildAnnotations(desc)
|
|
214
|
+
};
|
|
215
|
+
},
|
|
216
|
+
/**
|
|
217
|
+
* IR-5: Creates a list parameter descriptor.
|
|
218
|
+
*
|
|
219
|
+
* @param name - Parameter name (must be a valid identifier)
|
|
220
|
+
* @param itemType - Optional element type; omitted when not provided
|
|
221
|
+
* @param desc - Optional description
|
|
222
|
+
* @returns RillParam with type 'list' (with element if itemType provided)
|
|
223
|
+
*/
|
|
224
|
+
list(name, itemType, desc) {
|
|
225
|
+
validateParamName2(name);
|
|
226
|
+
const type = itemType !== void 0 ? { type: "list", element: itemType } : { type: "list" };
|
|
227
|
+
return {
|
|
228
|
+
name,
|
|
229
|
+
type,
|
|
230
|
+
defaultValue: void 0,
|
|
231
|
+
annotations: buildAnnotations(desc)
|
|
232
|
+
};
|
|
233
|
+
},
|
|
234
|
+
/**
|
|
235
|
+
* IR-6: Creates a callable parameter descriptor.
|
|
236
|
+
*
|
|
237
|
+
* @param name - Parameter name (must be a valid identifier)
|
|
238
|
+
* @param desc - Optional description
|
|
239
|
+
* @returns RillParam with type 'closure'
|
|
240
|
+
*/
|
|
241
|
+
callable(name, desc) {
|
|
242
|
+
validateParamName2(name);
|
|
243
|
+
return {
|
|
244
|
+
name,
|
|
245
|
+
type: { type: "closure" },
|
|
246
|
+
defaultValue: void 0,
|
|
247
|
+
annotations: buildAnnotations(desc)
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
|
|
114
252
|
// src/factory.ts
|
|
115
253
|
function mapPineconeError(error) {
|
|
116
254
|
if (error instanceof Error) {
|
|
117
255
|
const message = error.message;
|
|
118
256
|
if (message.toLowerCase().includes("authentication")) {
|
|
119
|
-
return new
|
|
257
|
+
return new RuntimeError6(
|
|
120
258
|
"RILL-R004",
|
|
121
259
|
"pinecone: authentication failed (401)"
|
|
122
260
|
);
|
|
123
261
|
}
|
|
124
262
|
if (message.toLowerCase().includes("index") && message.toLowerCase().includes("not found")) {
|
|
125
|
-
return new
|
|
263
|
+
return new RuntimeError6("RILL-R004", "pinecone: collection not found");
|
|
126
264
|
}
|
|
127
265
|
}
|
|
128
266
|
return mapVectorError("pinecone", error);
|
|
@@ -157,9 +295,9 @@ function createPineconeExtension(config) {
|
|
|
157
295
|
// IR-1: pinecone::upsert
|
|
158
296
|
upsert: {
|
|
159
297
|
params: [
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
298
|
+
p.str("id"),
|
|
299
|
+
vectorParam("vector"),
|
|
300
|
+
p.dict("metadata", void 0, {})
|
|
163
301
|
],
|
|
164
302
|
fn: async (args, ctx) => {
|
|
165
303
|
checkDisposed2();
|
|
@@ -191,11 +329,11 @@ function createPineconeExtension(config) {
|
|
|
191
329
|
);
|
|
192
330
|
},
|
|
193
331
|
description: "Insert or update single vector with metadata",
|
|
194
|
-
returnType: "dict"
|
|
332
|
+
returnType: { type: "dict" }
|
|
195
333
|
},
|
|
196
334
|
// IR-2: pinecone::upsert_batch
|
|
197
335
|
upsert_batch: {
|
|
198
|
-
params: [
|
|
336
|
+
params: [p.list("items")],
|
|
199
337
|
fn: async (args, ctx) => {
|
|
200
338
|
const startTime = Date.now();
|
|
201
339
|
try {
|
|
@@ -276,13 +414,13 @@ function createPineconeExtension(config) {
|
|
|
276
414
|
}
|
|
277
415
|
},
|
|
278
416
|
description: "Batch insert/update vectors",
|
|
279
|
-
returnType: "dict"
|
|
417
|
+
returnType: { type: "dict" }
|
|
280
418
|
},
|
|
281
419
|
// IR-3: pinecone::search
|
|
282
420
|
search: {
|
|
283
421
|
params: [
|
|
284
|
-
|
|
285
|
-
|
|
422
|
+
vectorParam("vector"),
|
|
423
|
+
p.dict("options", void 0, {})
|
|
286
424
|
],
|
|
287
425
|
fn: async (args, ctx) => {
|
|
288
426
|
checkDisposed2();
|
|
@@ -348,11 +486,11 @@ function createPineconeExtension(config) {
|
|
|
348
486
|
}
|
|
349
487
|
},
|
|
350
488
|
description: "Search k nearest neighbors",
|
|
351
|
-
returnType: "list"
|
|
489
|
+
returnType: { type: "list" }
|
|
352
490
|
},
|
|
353
491
|
// IR-4: pinecone::get
|
|
354
492
|
get: {
|
|
355
|
-
params: [
|
|
493
|
+
params: [p.str("id")],
|
|
356
494
|
fn: async (args, ctx) => {
|
|
357
495
|
checkDisposed2();
|
|
358
496
|
const id = args[0];
|
|
@@ -365,12 +503,12 @@ function createPineconeExtension(config) {
|
|
|
365
503
|
const index = client.Index(factoryIndex);
|
|
366
504
|
const response = await index.namespace(factoryNamespace).fetch({ ids: [id] });
|
|
367
505
|
if (!response.records || response.records[id] === void 0) {
|
|
368
|
-
throw new
|
|
506
|
+
throw new RuntimeError6("RILL-R004", "pinecone: id not found");
|
|
369
507
|
}
|
|
370
508
|
const record = response.records[id];
|
|
371
509
|
const vectorData = record.values;
|
|
372
510
|
if (!vectorData || !Array.isArray(vectorData)) {
|
|
373
|
-
throw new
|
|
511
|
+
throw new RuntimeError6(
|
|
374
512
|
"RILL-R004",
|
|
375
513
|
"pinecone: invalid vector format"
|
|
376
514
|
);
|
|
@@ -386,11 +524,11 @@ function createPineconeExtension(config) {
|
|
|
386
524
|
);
|
|
387
525
|
},
|
|
388
526
|
description: "Fetch vector by ID",
|
|
389
|
-
returnType: "dict"
|
|
527
|
+
returnType: { type: "dict" }
|
|
390
528
|
},
|
|
391
529
|
// IR-5: pinecone::delete
|
|
392
530
|
delete: {
|
|
393
|
-
params: [
|
|
531
|
+
params: [p.str("id")],
|
|
394
532
|
fn: async (args, ctx) => {
|
|
395
533
|
checkDisposed2();
|
|
396
534
|
const id = args[0];
|
|
@@ -411,11 +549,11 @@ function createPineconeExtension(config) {
|
|
|
411
549
|
);
|
|
412
550
|
},
|
|
413
551
|
description: "Delete vector by ID",
|
|
414
|
-
returnType: "dict"
|
|
552
|
+
returnType: { type: "dict" }
|
|
415
553
|
},
|
|
416
554
|
// IR-6: pinecone::delete_batch
|
|
417
555
|
delete_batch: {
|
|
418
|
-
params: [
|
|
556
|
+
params: [p.list("ids")],
|
|
419
557
|
fn: async (args, ctx) => {
|
|
420
558
|
const startTime = Date.now();
|
|
421
559
|
try {
|
|
@@ -468,7 +606,7 @@ function createPineconeExtension(config) {
|
|
|
468
606
|
}
|
|
469
607
|
},
|
|
470
608
|
description: "Batch delete vectors",
|
|
471
|
-
returnType: "dict"
|
|
609
|
+
returnType: { type: "dict" }
|
|
472
610
|
},
|
|
473
611
|
// IR-7: pinecone::count
|
|
474
612
|
count: {
|
|
@@ -489,13 +627,13 @@ function createPineconeExtension(config) {
|
|
|
489
627
|
);
|
|
490
628
|
},
|
|
491
629
|
description: "Return total vector count in collection",
|
|
492
|
-
returnType: "number"
|
|
630
|
+
returnType: { type: "number" }
|
|
493
631
|
},
|
|
494
632
|
// IR-8: pinecone::create_collection
|
|
495
633
|
create_collection: {
|
|
496
634
|
params: [
|
|
497
|
-
|
|
498
|
-
|
|
635
|
+
p.str("name"),
|
|
636
|
+
p.dict("options", void 0, {})
|
|
499
637
|
],
|
|
500
638
|
fn: async (args, ctx) => {
|
|
501
639
|
checkDisposed2();
|
|
@@ -504,7 +642,7 @@ function createPineconeExtension(config) {
|
|
|
504
642
|
const dimensions = options["dimensions"];
|
|
505
643
|
const distance = options["distance"] ?? "cosine";
|
|
506
644
|
if (!dimensions || typeof dimensions !== "number" || dimensions <= 0) {
|
|
507
|
-
throw new
|
|
645
|
+
throw new RuntimeError6(
|
|
508
646
|
"RILL-R004",
|
|
509
647
|
"pinecone: dimensions must be a positive integer"
|
|
510
648
|
);
|
|
@@ -542,11 +680,11 @@ function createPineconeExtension(config) {
|
|
|
542
680
|
);
|
|
543
681
|
},
|
|
544
682
|
description: "Create new vector collection",
|
|
545
|
-
returnType: "dict"
|
|
683
|
+
returnType: { type: "dict" }
|
|
546
684
|
},
|
|
547
685
|
// IR-9: pinecone::delete_collection
|
|
548
686
|
delete_collection: {
|
|
549
|
-
params: [
|
|
687
|
+
params: [p.str("name")],
|
|
550
688
|
fn: async (args, ctx) => {
|
|
551
689
|
checkDisposed2();
|
|
552
690
|
const name = args[0];
|
|
@@ -565,7 +703,7 @@ function createPineconeExtension(config) {
|
|
|
565
703
|
);
|
|
566
704
|
},
|
|
567
705
|
description: "Delete vector collection",
|
|
568
|
-
returnType: "dict"
|
|
706
|
+
returnType: { type: "dict" }
|
|
569
707
|
},
|
|
570
708
|
// IR-10: pinecone::list_collections
|
|
571
709
|
list_collections: {
|
|
@@ -585,7 +723,7 @@ function createPineconeExtension(config) {
|
|
|
585
723
|
);
|
|
586
724
|
},
|
|
587
725
|
description: "List all collection names",
|
|
588
|
-
returnType: "list"
|
|
726
|
+
returnType: { type: "list" }
|
|
589
727
|
},
|
|
590
728
|
// IR-11: pinecone::describe
|
|
591
729
|
describe: {
|
|
@@ -622,7 +760,7 @@ function createPineconeExtension(config) {
|
|
|
622
760
|
);
|
|
623
761
|
},
|
|
624
762
|
description: "Describe configured collection",
|
|
625
|
-
returnType: "dict"
|
|
763
|
+
returnType: { type: "dict" }
|
|
626
764
|
}
|
|
627
765
|
};
|
|
628
766
|
result.dispose = dispose2;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rcrsr/rill-ext-pinecone",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "rill extension for Pinecone vector database integration",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Andre Bremer",
|
|
@@ -17,10 +17,10 @@
|
|
|
17
17
|
"scripting"
|
|
18
18
|
],
|
|
19
19
|
"peerDependencies": {
|
|
20
|
-
"@rcrsr/rill": "^0.
|
|
20
|
+
"@rcrsr/rill": "^0.11.0"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@rcrsr/rill": "^0.
|
|
23
|
+
"@rcrsr/rill": "^0.11.0",
|
|
24
24
|
"@types/node": "^25.3.0",
|
|
25
25
|
"dts-bundle-generator": "^9.5.1",
|
|
26
26
|
"tsup": "^8.5.1",
|
|
@@ -43,7 +43,8 @@
|
|
|
43
43
|
"access": "public"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@pinecone-database/pinecone": "^7.1.0"
|
|
46
|
+
"@pinecone-database/pinecone": "^7.1.0",
|
|
47
|
+
"@rcrsr/rill-ext-param-shared": "^0.0.1"
|
|
47
48
|
},
|
|
48
49
|
"scripts": {
|
|
49
50
|
"build": "tsup && dts-bundle-generator --config dts-bundle-generator.config.cjs",
|