@rcrsr/rill-ext-pinecone 0.8.6 → 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/README.md +7 -204
- package/dist/index.d.ts +2 -1
- package/dist/index.js +195 -46
- package/package.json +11 -10
package/README.md
CHANGED
|
@@ -39,213 +39,16 @@ const result = await execute(parse(script), ctx);
|
|
|
39
39
|
dispose?.();
|
|
40
40
|
```
|
|
41
41
|
|
|
42
|
-
##
|
|
43
|
-
|
|
44
|
-
All vector database extensions share identical function signatures. Swap `pinecone::` for `qdrant::` or `chroma::` with no script changes.
|
|
45
|
-
|
|
46
|
-
### pinecone::upsert(id, vector, metadata?)
|
|
47
|
-
|
|
48
|
-
Insert or update a single vector with metadata.
|
|
49
|
-
|
|
50
|
-
```rill
|
|
51
|
-
pinecone::upsert("doc-1", $embedding, [title: "Example", page: 1]) => $result
|
|
52
|
-
$result.id -> log # "doc-1"
|
|
53
|
-
$result.success -> log # true
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
**Idempotent.** Duplicate ID overwrites existing vector.
|
|
57
|
-
|
|
58
|
-
### pinecone::upsert_batch(items)
|
|
59
|
-
|
|
60
|
-
Batch insert or update vectors. Processes sequentially; halts on first failure.
|
|
61
|
-
|
|
62
|
-
```rill
|
|
63
|
-
pinecone::upsert_batch([
|
|
64
|
-
[id: "doc-1", vector: $v1, metadata: [title: "First"]],
|
|
65
|
-
[id: "doc-2", vector: $v2, metadata: [title: "Second"]]
|
|
66
|
-
]) => $result
|
|
67
|
-
$result.succeeded -> log # 2
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
Returns `{ succeeded }` on success. Returns `{ succeeded, failed, error }` on failure.
|
|
71
|
-
|
|
72
|
-
### pinecone::search(vector, options?)
|
|
73
|
-
|
|
74
|
-
Search for k nearest neighbors.
|
|
75
|
-
|
|
76
|
-
```rill
|
|
77
|
-
pinecone::search($embedding, [k: 5, score_threshold: 0.8]) => $results
|
|
78
|
-
$results -> each { "{.id}: {.score}" -> log }
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
| Option | Type | Default | Description |
|
|
82
|
-
|--------|------|---------|-------------|
|
|
83
|
-
| `k` | number | `10` | Max results to return |
|
|
84
|
-
| `filter` | dict | `{}` | Metadata filter conditions |
|
|
85
|
-
| `score_threshold` | number | (none) | Exclude results below threshold |
|
|
86
|
-
|
|
87
|
-
Returns `[{ id, score, metadata }]`. Empty results return `[]`.
|
|
88
|
-
|
|
89
|
-
### pinecone::get(id)
|
|
90
|
-
|
|
91
|
-
Fetch a vector by ID.
|
|
92
|
-
|
|
93
|
-
```rill
|
|
94
|
-
pinecone::get("doc-1") => $point
|
|
95
|
-
$point.id -> log # "doc-1"
|
|
96
|
-
$point.metadata -> log # [title: "Example", page: 1]
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
Returns `{ id, vector, metadata }`. Halts with error if ID not found.
|
|
100
|
-
|
|
101
|
-
### pinecone::delete(id)
|
|
102
|
-
|
|
103
|
-
Delete a vector by ID.
|
|
104
|
-
|
|
105
|
-
```rill
|
|
106
|
-
pinecone::delete("doc-1") => $result
|
|
107
|
-
$result.deleted -> log # true
|
|
108
|
-
```
|
|
109
|
-
|
|
110
|
-
Returns `{ id, deleted }`. Halts with error if ID not found.
|
|
111
|
-
|
|
112
|
-
### pinecone::delete_batch(ids)
|
|
113
|
-
|
|
114
|
-
Batch delete vectors. Processes sequentially; halts on first failure.
|
|
115
|
-
|
|
116
|
-
```rill
|
|
117
|
-
pinecone::delete_batch(["doc-1", "doc-2", "doc-3"]) => $result
|
|
118
|
-
$result.succeeded -> log # 3
|
|
119
|
-
```
|
|
120
|
-
|
|
121
|
-
Returns `{ succeeded }` on success. Returns `{ succeeded, failed, error }` on failure.
|
|
122
|
-
|
|
123
|
-
### pinecone::count()
|
|
124
|
-
|
|
125
|
-
Count vectors in the index.
|
|
126
|
-
|
|
127
|
-
```rill
|
|
128
|
-
pinecone::count() -> log # 42
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
Returns a number.
|
|
132
|
-
|
|
133
|
-
### pinecone::create_collection(name, options?)
|
|
134
|
-
|
|
135
|
-
Create a new collection.
|
|
136
|
-
|
|
137
|
-
```rill
|
|
138
|
-
pinecone::create_collection("my_vectors", [dimensions: 384, distance: "cosine"]) => $result
|
|
139
|
-
$result.created -> log # true
|
|
140
|
-
```
|
|
141
|
-
|
|
142
|
-
| Option | Type | Default | Description |
|
|
143
|
-
|--------|------|---------|-------------|
|
|
144
|
-
| `dimensions` | number | (none) | Vector dimension size |
|
|
145
|
-
| `distance` | string | `"cosine"` | `"cosine"`, `"euclidean"`, or `"dot"` |
|
|
146
|
-
|
|
147
|
-
Returns `{ name, created }`. **Not idempotent** — halts if collection exists.
|
|
148
|
-
|
|
149
|
-
### pinecone::delete_collection(id)
|
|
150
|
-
|
|
151
|
-
Delete a collection.
|
|
152
|
-
|
|
153
|
-
```rill
|
|
154
|
-
pinecone::delete_collection("old_vectors") => $result
|
|
155
|
-
$result.deleted -> log # true
|
|
156
|
-
```
|
|
157
|
-
|
|
158
|
-
Returns `{ name, deleted }`. **Not idempotent** — halts if collection not found.
|
|
159
|
-
|
|
160
|
-
### pinecone::list_collections()
|
|
161
|
-
|
|
162
|
-
List all collection names.
|
|
163
|
-
|
|
164
|
-
```rill
|
|
165
|
-
pinecone::list_collections() -> log # ["my_vectors", "archive"]
|
|
166
|
-
```
|
|
167
|
-
|
|
168
|
-
Returns a list of strings.
|
|
169
|
-
|
|
170
|
-
### pinecone::describe()
|
|
171
|
-
|
|
172
|
-
Describe the configured index.
|
|
173
|
-
|
|
174
|
-
```rill
|
|
175
|
-
pinecone::describe() => $info
|
|
176
|
-
$info.name -> log # "my-index"
|
|
177
|
-
$info.count -> log # 42
|
|
178
|
-
$info.dimensions -> log # 384
|
|
179
|
-
$info.distance -> log # "cosine"
|
|
180
|
-
```
|
|
181
|
-
|
|
182
|
-
Returns `{ name, count, dimensions, distance }`.
|
|
183
|
-
|
|
184
|
-
## Configuration
|
|
185
|
-
|
|
186
|
-
```typescript
|
|
187
|
-
const ext = createPineconeExtension({
|
|
188
|
-
apiKey: process.env.PINECONE_API_KEY!,
|
|
189
|
-
index: 'my-index',
|
|
190
|
-
namespace: 'production',
|
|
191
|
-
timeout: 30000,
|
|
192
|
-
});
|
|
193
|
-
```
|
|
194
|
-
|
|
195
|
-
| Option | Type | Default | Description |
|
|
196
|
-
|--------|------|---------|-------------|
|
|
197
|
-
| `apiKey` | string | required | Pinecone API key |
|
|
198
|
-
| `index` | string | required | Index name |
|
|
199
|
-
| `namespace` | string | `''` | Namespace for partitioning |
|
|
200
|
-
| `timeout` | number | `30000` | Request timeout in ms |
|
|
201
|
-
|
|
202
|
-
## Error Handling
|
|
203
|
-
|
|
204
|
-
All errors use `RuntimeError('RILL-R004', 'pinecone: <message>')` and halt script execution.
|
|
205
|
-
|
|
206
|
-
| Condition | Message |
|
|
207
|
-
|-----------|---------|
|
|
208
|
-
| HTTP 401 | `pinecone: authentication failed (401)` |
|
|
209
|
-
| Collection not found | `pinecone: collection not found` |
|
|
210
|
-
| Rate limit (429) | `pinecone: rate limit exceeded` |
|
|
211
|
-
| Timeout | `pinecone: request timeout` |
|
|
212
|
-
| Dimension mismatch | `pinecone: dimension mismatch (expected N, got M)` |
|
|
213
|
-
| Collection exists | `pinecone: collection already exists` |
|
|
214
|
-
| ID not found | `pinecone: id not found` |
|
|
215
|
-
| After dispose | `pinecone: operation cancelled` |
|
|
216
|
-
| Other | `pinecone: <error message>` |
|
|
217
|
-
|
|
218
|
-
## Cloud Setup
|
|
219
|
-
|
|
220
|
-
Create a free account at [pinecone.io](https://www.pinecone.io). Find your API key in the Pinecone Console under **API Keys**.
|
|
221
|
-
|
|
222
|
-
```bash
|
|
223
|
-
pinecone index create my-index \
|
|
224
|
-
--dimension 384 \
|
|
225
|
-
--metric cosine \
|
|
226
|
-
--cloud aws \
|
|
227
|
-
--region us-east-1
|
|
228
|
-
```
|
|
229
|
-
|
|
230
|
-
Free tier includes 1 serverless index, 2GB storage, 10K vectors per namespace. See [Pinecone Pricing](https://www.pinecone.io/pricing/) for current limits.
|
|
231
|
-
|
|
232
|
-
## Lifecycle
|
|
233
|
-
|
|
234
|
-
```typescript
|
|
235
|
-
const ext = createPineconeExtension({ ... });
|
|
236
|
-
// ... use extension ...
|
|
237
|
-
await ext.dispose?.();
|
|
238
|
-
```
|
|
42
|
+
## Documentation
|
|
239
43
|
|
|
240
|
-
|
|
44
|
+
See [full documentation](docs/extension-vectordb-pinecone.md) for configuration, functions, error handling, and cloud setup.
|
|
241
45
|
|
|
242
|
-
##
|
|
46
|
+
## Related
|
|
243
47
|
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
| [Pinecone Documentation](https://docs.pinecone.io) | Official Pinecone docs |
|
|
48
|
+
- [rill](https://github.com/rcrsr/rill) — Core language runtime
|
|
49
|
+
- [Extensions Guide](https://github.com/rcrsr/rill/blob/main/docs/integration-extensions.md) — Extension contract and patterns
|
|
50
|
+
- [Host API Reference](https://github.com/rcrsr/rill/blob/main/docs/ref-host-api.md) — Runtime context and host functions
|
|
51
|
+
- [Pinecone Documentation](https://docs.pinecone.io) — Official Pinecone docs
|
|
249
52
|
|
|
250
53
|
## License
|
|
251
54
|
|
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 Pinecone extension.
|
|
@@ -84,5 +84,6 @@ export type PineconeExtensionConfig = PineconeConfig;
|
|
|
84
84
|
*/
|
|
85
85
|
export declare function createPineconeExtension(config: PineconeConfig): ExtensionResult;
|
|
86
86
|
export declare const VERSION = "0.0.1";
|
|
87
|
+
export declare const configSchema: ExtensionConfigSchema;
|
|
87
88
|
|
|
88
89
|
export {};
|
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();
|
|
@@ -174,13 +312,15 @@ function createPineconeExtension(config) {
|
|
|
174
312
|
{ id },
|
|
175
313
|
async () => {
|
|
176
314
|
const index = client.Index(factoryIndex);
|
|
177
|
-
await index.namespace(factoryNamespace).upsert(
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
315
|
+
await index.namespace(factoryNamespace).upsert({
|
|
316
|
+
records: [
|
|
317
|
+
{
|
|
318
|
+
id,
|
|
319
|
+
values: Array.from(vector.data),
|
|
320
|
+
metadata
|
|
321
|
+
}
|
|
322
|
+
]
|
|
323
|
+
});
|
|
184
324
|
return {
|
|
185
325
|
id,
|
|
186
326
|
success: true
|
|
@@ -189,11 +329,11 @@ function createPineconeExtension(config) {
|
|
|
189
329
|
);
|
|
190
330
|
},
|
|
191
331
|
description: "Insert or update single vector with metadata",
|
|
192
|
-
returnType: "dict"
|
|
332
|
+
returnType: { type: "dict" }
|
|
193
333
|
},
|
|
194
334
|
// IR-2: pinecone::upsert_batch
|
|
195
335
|
upsert_batch: {
|
|
196
|
-
params: [
|
|
336
|
+
params: [p.list("items")],
|
|
197
337
|
fn: async (args, ctx) => {
|
|
198
338
|
const startTime = Date.now();
|
|
199
339
|
try {
|
|
@@ -224,13 +364,15 @@ function createPineconeExtension(config) {
|
|
|
224
364
|
const metadataArg = item["metadata"] ?? {};
|
|
225
365
|
const metadata = convertMetadata(metadataArg);
|
|
226
366
|
try {
|
|
227
|
-
await index.namespace(factoryNamespace).upsert(
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
367
|
+
await index.namespace(factoryNamespace).upsert({
|
|
368
|
+
records: [
|
|
369
|
+
{
|
|
370
|
+
id,
|
|
371
|
+
values: Array.from(vector.data),
|
|
372
|
+
metadata
|
|
373
|
+
}
|
|
374
|
+
]
|
|
375
|
+
});
|
|
234
376
|
succeeded++;
|
|
235
377
|
} catch (error) {
|
|
236
378
|
const rillError = mapPineconeError(error);
|
|
@@ -272,13 +414,13 @@ function createPineconeExtension(config) {
|
|
|
272
414
|
}
|
|
273
415
|
},
|
|
274
416
|
description: "Batch insert/update vectors",
|
|
275
|
-
returnType: "dict"
|
|
417
|
+
returnType: { type: "dict" }
|
|
276
418
|
},
|
|
277
419
|
// IR-3: pinecone::search
|
|
278
420
|
search: {
|
|
279
421
|
params: [
|
|
280
|
-
|
|
281
|
-
|
|
422
|
+
vectorParam("vector"),
|
|
423
|
+
p.dict("options", void 0, {})
|
|
282
424
|
],
|
|
283
425
|
fn: async (args, ctx) => {
|
|
284
426
|
checkDisposed2();
|
|
@@ -344,11 +486,11 @@ function createPineconeExtension(config) {
|
|
|
344
486
|
}
|
|
345
487
|
},
|
|
346
488
|
description: "Search k nearest neighbors",
|
|
347
|
-
returnType: "list"
|
|
489
|
+
returnType: { type: "list" }
|
|
348
490
|
},
|
|
349
491
|
// IR-4: pinecone::get
|
|
350
492
|
get: {
|
|
351
|
-
params: [
|
|
493
|
+
params: [p.str("id")],
|
|
352
494
|
fn: async (args, ctx) => {
|
|
353
495
|
checkDisposed2();
|
|
354
496
|
const id = args[0];
|
|
@@ -359,14 +501,14 @@ function createPineconeExtension(config) {
|
|
|
359
501
|
{ id },
|
|
360
502
|
async () => {
|
|
361
503
|
const index = client.Index(factoryIndex);
|
|
362
|
-
const response = await index.namespace(factoryNamespace).fetch([id]);
|
|
504
|
+
const response = await index.namespace(factoryNamespace).fetch({ ids: [id] });
|
|
363
505
|
if (!response.records || response.records[id] === void 0) {
|
|
364
|
-
throw new
|
|
506
|
+
throw new RuntimeError6("RILL-R004", "pinecone: id not found");
|
|
365
507
|
}
|
|
366
508
|
const record = response.records[id];
|
|
367
509
|
const vectorData = record.values;
|
|
368
510
|
if (!vectorData || !Array.isArray(vectorData)) {
|
|
369
|
-
throw new
|
|
511
|
+
throw new RuntimeError6(
|
|
370
512
|
"RILL-R004",
|
|
371
513
|
"pinecone: invalid vector format"
|
|
372
514
|
);
|
|
@@ -382,11 +524,11 @@ function createPineconeExtension(config) {
|
|
|
382
524
|
);
|
|
383
525
|
},
|
|
384
526
|
description: "Fetch vector by ID",
|
|
385
|
-
returnType: "dict"
|
|
527
|
+
returnType: { type: "dict" }
|
|
386
528
|
},
|
|
387
529
|
// IR-5: pinecone::delete
|
|
388
530
|
delete: {
|
|
389
|
-
params: [
|
|
531
|
+
params: [p.str("id")],
|
|
390
532
|
fn: async (args, ctx) => {
|
|
391
533
|
checkDisposed2();
|
|
392
534
|
const id = args[0];
|
|
@@ -398,7 +540,7 @@ function createPineconeExtension(config) {
|
|
|
398
540
|
async () => {
|
|
399
541
|
const index = client.Index(factoryIndex);
|
|
400
542
|
const ns = factoryNamespace || "";
|
|
401
|
-
await index.namespace(ns).deleteOne(id);
|
|
543
|
+
await index.namespace(ns).deleteOne({ id });
|
|
402
544
|
return {
|
|
403
545
|
id,
|
|
404
546
|
deleted: true
|
|
@@ -407,11 +549,11 @@ function createPineconeExtension(config) {
|
|
|
407
549
|
);
|
|
408
550
|
},
|
|
409
551
|
description: "Delete vector by ID",
|
|
410
|
-
returnType: "dict"
|
|
552
|
+
returnType: { type: "dict" }
|
|
411
553
|
},
|
|
412
554
|
// IR-6: pinecone::delete_batch
|
|
413
555
|
delete_batch: {
|
|
414
|
-
params: [
|
|
556
|
+
params: [p.list("ids")],
|
|
415
557
|
fn: async (args, ctx) => {
|
|
416
558
|
const startTime = Date.now();
|
|
417
559
|
try {
|
|
@@ -422,7 +564,7 @@ function createPineconeExtension(config) {
|
|
|
422
564
|
for (let i = 0; i < ids.length; i++) {
|
|
423
565
|
const id = ids[i];
|
|
424
566
|
try {
|
|
425
|
-
await index.namespace(factoryNamespace).deleteOne(id);
|
|
567
|
+
await index.namespace(factoryNamespace).deleteOne({ id });
|
|
426
568
|
succeeded++;
|
|
427
569
|
} catch (error) {
|
|
428
570
|
const rillError = mapPineconeError(error);
|
|
@@ -464,7 +606,7 @@ function createPineconeExtension(config) {
|
|
|
464
606
|
}
|
|
465
607
|
},
|
|
466
608
|
description: "Batch delete vectors",
|
|
467
|
-
returnType: "dict"
|
|
609
|
+
returnType: { type: "dict" }
|
|
468
610
|
},
|
|
469
611
|
// IR-7: pinecone::count
|
|
470
612
|
count: {
|
|
@@ -485,13 +627,13 @@ function createPineconeExtension(config) {
|
|
|
485
627
|
);
|
|
486
628
|
},
|
|
487
629
|
description: "Return total vector count in collection",
|
|
488
|
-
returnType: "number"
|
|
630
|
+
returnType: { type: "number" }
|
|
489
631
|
},
|
|
490
632
|
// IR-8: pinecone::create_collection
|
|
491
633
|
create_collection: {
|
|
492
634
|
params: [
|
|
493
|
-
|
|
494
|
-
|
|
635
|
+
p.str("name"),
|
|
636
|
+
p.dict("options", void 0, {})
|
|
495
637
|
],
|
|
496
638
|
fn: async (args, ctx) => {
|
|
497
639
|
checkDisposed2();
|
|
@@ -500,7 +642,7 @@ function createPineconeExtension(config) {
|
|
|
500
642
|
const dimensions = options["dimensions"];
|
|
501
643
|
const distance = options["distance"] ?? "cosine";
|
|
502
644
|
if (!dimensions || typeof dimensions !== "number" || dimensions <= 0) {
|
|
503
|
-
throw new
|
|
645
|
+
throw new RuntimeError6(
|
|
504
646
|
"RILL-R004",
|
|
505
647
|
"pinecone: dimensions must be a positive integer"
|
|
506
648
|
);
|
|
@@ -538,11 +680,11 @@ function createPineconeExtension(config) {
|
|
|
538
680
|
);
|
|
539
681
|
},
|
|
540
682
|
description: "Create new vector collection",
|
|
541
|
-
returnType: "dict"
|
|
683
|
+
returnType: { type: "dict" }
|
|
542
684
|
},
|
|
543
685
|
// IR-9: pinecone::delete_collection
|
|
544
686
|
delete_collection: {
|
|
545
|
-
params: [
|
|
687
|
+
params: [p.str("name")],
|
|
546
688
|
fn: async (args, ctx) => {
|
|
547
689
|
checkDisposed2();
|
|
548
690
|
const name = args[0];
|
|
@@ -561,7 +703,7 @@ function createPineconeExtension(config) {
|
|
|
561
703
|
);
|
|
562
704
|
},
|
|
563
705
|
description: "Delete vector collection",
|
|
564
|
-
returnType: "dict"
|
|
706
|
+
returnType: { type: "dict" }
|
|
565
707
|
},
|
|
566
708
|
// IR-10: pinecone::list_collections
|
|
567
709
|
list_collections: {
|
|
@@ -581,7 +723,7 @@ function createPineconeExtension(config) {
|
|
|
581
723
|
);
|
|
582
724
|
},
|
|
583
725
|
description: "List all collection names",
|
|
584
|
-
returnType: "list"
|
|
726
|
+
returnType: { type: "list" }
|
|
585
727
|
},
|
|
586
728
|
// IR-11: pinecone::describe
|
|
587
729
|
describe: {
|
|
@@ -618,7 +760,7 @@ function createPineconeExtension(config) {
|
|
|
618
760
|
);
|
|
619
761
|
},
|
|
620
762
|
description: "Describe configured collection",
|
|
621
|
-
returnType: "dict"
|
|
763
|
+
returnType: { type: "dict" }
|
|
622
764
|
}
|
|
623
765
|
};
|
|
624
766
|
result.dispose = dispose2;
|
|
@@ -627,7 +769,14 @@ function createPineconeExtension(config) {
|
|
|
627
769
|
|
|
628
770
|
// src/index.ts
|
|
629
771
|
var VERSION = "0.0.1";
|
|
772
|
+
var configSchema = {
|
|
773
|
+
apiKey: { type: "string", required: true, secret: true },
|
|
774
|
+
index: { type: "string", required: true },
|
|
775
|
+
namespace: { type: "string" },
|
|
776
|
+
timeout: { type: "number" }
|
|
777
|
+
};
|
|
630
778
|
export {
|
|
631
779
|
VERSION,
|
|
780
|
+
configSchema,
|
|
632
781
|
createPineconeExtension
|
|
633
782
|
};
|
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,14 +17,14 @@
|
|
|
17
17
|
"scripting"
|
|
18
18
|
],
|
|
19
19
|
"peerDependencies": {
|
|
20
|
-
"@rcrsr/rill": "^0.
|
|
20
|
+
"@rcrsr/rill": "^0.11.0"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@
|
|
23
|
+
"@rcrsr/rill": "^0.11.0",
|
|
24
|
+
"@types/node": "^25.3.0",
|
|
24
25
|
"dts-bundle-generator": "^9.5.1",
|
|
25
|
-
"tsup": "^8.5.
|
|
26
|
-
"undici-types": "^7.
|
|
27
|
-
"@rcrsr/rill": "^0.8.6",
|
|
26
|
+
"tsup": "^8.5.1",
|
|
27
|
+
"undici-types": "^7.22.0",
|
|
28
28
|
"@rcrsr/rill-ext-vector-shared": "^0.0.1"
|
|
29
29
|
},
|
|
30
30
|
"files": [
|
|
@@ -32,18 +32,19 @@
|
|
|
32
32
|
],
|
|
33
33
|
"repository": {
|
|
34
34
|
"type": "git",
|
|
35
|
-
"url": "git+https://github.com/rcrsr/rill.git",
|
|
35
|
+
"url": "git+https://github.com/rcrsr/rill-ext.git",
|
|
36
36
|
"directory": "packages/ext/vectordb-pinecone"
|
|
37
37
|
},
|
|
38
|
-
"homepage": "https://
|
|
38
|
+
"homepage": "https://github.com/rcrsr/rill-ext/tree/main/packages/ext/vectordb-pinecone#readme",
|
|
39
39
|
"bugs": {
|
|
40
|
-
"url": "https://github.com/rcrsr/rill/issues"
|
|
40
|
+
"url": "https://github.com/rcrsr/rill-ext/issues"
|
|
41
41
|
},
|
|
42
42
|
"publishConfig": {
|
|
43
43
|
"access": "public"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@pinecone-database/pinecone": "^
|
|
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",
|