@absolutejs/rag-pinecone 0.0.2 → 0.0.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.
- package/dist/index.d.ts +6 -38
- package/dist/index.js +35 -34
- package/dist/index.js.map +3 -3
- package/package.json +7 -6
package/dist/index.d.ts
CHANGED
|
@@ -1,30 +1,9 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Index, IndexModel, RecordMetadata } from '@pinecone-database/pinecone';
|
|
2
|
+
import type { RAGBackendCapabilities, RAGCollection, RAGVectorStore } from '@absolutejs/rag/adapter-kit';
|
|
2
3
|
export declare const ABSOLUTE_PINECONE_RAG_PACKAGE_NAME = "@absolutejs/rag-pinecone";
|
|
3
4
|
export declare const PINECONE_DISTANCE_METRICS: readonly ["cosine", "euclidean", "dotproduct"];
|
|
4
5
|
export type PineconeDistanceMetric = 'cosine' | 'euclidean' | 'dotproduct';
|
|
5
|
-
|
|
6
|
-
upsert: (records: unknown[]) => Promise<unknown>;
|
|
7
|
-
query: (input: Record<string, unknown>) => Promise<{
|
|
8
|
-
matches?: Array<{
|
|
9
|
-
id: string;
|
|
10
|
-
score?: number;
|
|
11
|
-
values?: number[];
|
|
12
|
-
metadata?: Record<string, unknown>;
|
|
13
|
-
}>;
|
|
14
|
-
}>;
|
|
15
|
-
fetch: (ids: string[]) => Promise<{
|
|
16
|
-
records?: Record<string, unknown>;
|
|
17
|
-
}>;
|
|
18
|
-
deleteMany: (input: string[] | Record<string, unknown>) => Promise<unknown>;
|
|
19
|
-
deleteAll: () => Promise<unknown>;
|
|
20
|
-
describeIndexStats: () => Promise<{
|
|
21
|
-
totalRecordCount?: number;
|
|
22
|
-
namespaces?: Record<string, {
|
|
23
|
-
recordCount?: number;
|
|
24
|
-
}>;
|
|
25
|
-
}>;
|
|
26
|
-
namespace?: (namespace: string) => PineconeIndexClient;
|
|
27
|
-
};
|
|
6
|
+
type PineconeIndexClient = Index<RecordMetadata>;
|
|
28
7
|
export type PineconeRAGVectorConfig = {
|
|
29
8
|
provider: 'pinecone';
|
|
30
9
|
dimensions: number;
|
|
@@ -64,18 +43,6 @@ export type PineconePodSpec = {
|
|
|
64
43
|
};
|
|
65
44
|
};
|
|
66
45
|
export type PineconeIndexSpec = PineconeServerlessSpec | PineconePodSpec;
|
|
67
|
-
export type PineconeIndexDescription = {
|
|
68
|
-
name: string;
|
|
69
|
-
dimension: number;
|
|
70
|
-
metric: PineconeDistanceMetric;
|
|
71
|
-
host?: string;
|
|
72
|
-
spec?: PineconeIndexSpec;
|
|
73
|
-
status?: {
|
|
74
|
-
ready?: boolean;
|
|
75
|
-
state?: string;
|
|
76
|
-
};
|
|
77
|
-
deletionProtection?: 'enabled' | 'disabled';
|
|
78
|
-
};
|
|
79
46
|
export type DescribePineconeIndexOptions = {
|
|
80
47
|
apiKey?: string;
|
|
81
48
|
indexName: string;
|
|
@@ -93,10 +60,11 @@ export type EnsurePineconeIndexOptions = {
|
|
|
93
60
|
};
|
|
94
61
|
export type EnsurePineconeIndexResult = {
|
|
95
62
|
created: boolean;
|
|
96
|
-
description:
|
|
63
|
+
description: IndexModel | undefined;
|
|
97
64
|
};
|
|
98
65
|
export declare const createPineconeStore: (options: PineconeRAGOptions) => RAGVectorStore;
|
|
99
|
-
export declare const describePineconeIndex: (options: DescribePineconeIndexOptions) => Promise<
|
|
66
|
+
export declare const describePineconeIndex: (options: DescribePineconeIndexOptions) => Promise<IndexModel | undefined>;
|
|
100
67
|
export declare const ensurePineconeIndex: (options: EnsurePineconeIndexOptions) => Promise<EnsurePineconeIndexResult>;
|
|
101
68
|
export declare const createPineconeRAGCollection: (options: PineconeRAGOptions) => RAGCollection;
|
|
102
69
|
export declare const createPineconeRAG: (options: PineconeRAGOptions) => PineconeRAG;
|
|
70
|
+
export type { CreateIndexOptions, Index, IndexModel, PineconeRecord, QueryResponse, RecordMetadata, ScoredPineconeRecord } from '@pinecone-database/pinecone';
|
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
createRAGCollection,
|
|
7
7
|
createRAGVector,
|
|
8
8
|
normalizeVector
|
|
9
|
-
} from "@absolutejs/rag";
|
|
9
|
+
} from "@absolutejs/rag/adapter-kit";
|
|
10
10
|
var ABSOLUTE_PINECONE_RAG_PACKAGE_NAME = "@absolutejs/rag-pinecone";
|
|
11
11
|
var PINECONE_DISTANCE_METRICS = [
|
|
12
12
|
"cosine",
|
|
@@ -58,7 +58,7 @@ var resolveIndexClientFactory = (options) => {
|
|
|
58
58
|
const namespace = typeof options.namespace === "string" && options.namespace.length > 0 ? options.namespace : undefined;
|
|
59
59
|
let cached;
|
|
60
60
|
const applyNamespace = (idx) => {
|
|
61
|
-
if (!namespace
|
|
61
|
+
if (!namespace)
|
|
62
62
|
return idx;
|
|
63
63
|
return idx.namespace(namespace);
|
|
64
64
|
};
|
|
@@ -291,16 +291,14 @@ var createPineconeStore = (options) => {
|
|
|
291
291
|
const query = async (input) => {
|
|
292
292
|
const client = await getClient();
|
|
293
293
|
const filter = translateFilter(input.filter);
|
|
294
|
-
const
|
|
294
|
+
const result = await client.query({
|
|
295
295
|
vector: normalizeVector(input.queryVector),
|
|
296
296
|
topK: input.topK,
|
|
297
297
|
includeMetadata: true,
|
|
298
|
-
includeValues: false
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
const result = await client.query(queryInput);
|
|
303
|
-
const matches = Array.isArray(result?.matches) ? result.matches : [];
|
|
298
|
+
includeValues: false,
|
|
299
|
+
...filter ? { filter } : {}
|
|
300
|
+
});
|
|
301
|
+
const matches = Array.isArray(result.matches) ? result.matches : [];
|
|
304
302
|
return matches.map((match) => extractQueryResult(match, vector.distanceMetric));
|
|
305
303
|
};
|
|
306
304
|
const count = async (input = {}) => {
|
|
@@ -309,29 +307,27 @@ var createPineconeStore = (options) => {
|
|
|
309
307
|
let total = 0;
|
|
310
308
|
for (const batch of chunkArray(input.chunkIds, PINECONE_FETCH_BATCH_SIZE)) {
|
|
311
309
|
const response = await client.fetch(batch);
|
|
312
|
-
total += Object.keys(response
|
|
310
|
+
total += Object.keys(response.records ?? {}).length;
|
|
313
311
|
}
|
|
314
312
|
return total;
|
|
315
313
|
}
|
|
316
314
|
if (isObjectRecord(input.filter) && Object.keys(input.filter).length > 0) {
|
|
317
315
|
const filter = translateFilter(input.filter);
|
|
318
316
|
const probeVector = new Array(vector.dimensions).fill(0);
|
|
319
|
-
const
|
|
317
|
+
const result = await client.query({
|
|
320
318
|
vector: probeVector,
|
|
321
319
|
topK: PINECONE_FILTERED_COUNT_TOPK,
|
|
322
320
|
includeMetadata: false,
|
|
323
|
-
includeValues: false
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
const result = await client.query(queryInput);
|
|
328
|
-
return Array.isArray(result?.matches) ? result.matches.length : 0;
|
|
321
|
+
includeValues: false,
|
|
322
|
+
...filter ? { filter } : {}
|
|
323
|
+
});
|
|
324
|
+
return Array.isArray(result.matches) ? result.matches.length : 0;
|
|
329
325
|
}
|
|
330
326
|
const stats = await client.describeIndexStats();
|
|
331
327
|
if (namespace) {
|
|
332
|
-
return stats
|
|
328
|
+
return stats.namespaces?.[namespace]?.recordCount ?? 0;
|
|
333
329
|
}
|
|
334
|
-
return stats
|
|
330
|
+
return stats.totalRecordCount ?? 0;
|
|
335
331
|
};
|
|
336
332
|
const remove = async (input = {}) => {
|
|
337
333
|
const client = await getClient();
|
|
@@ -352,7 +348,7 @@ var createPineconeStore = (options) => {
|
|
|
352
348
|
return 0;
|
|
353
349
|
const counted = await count({ filter: input.filter });
|
|
354
350
|
try {
|
|
355
|
-
await client.deleteMany(
|
|
351
|
+
await client.deleteMany(filter);
|
|
356
352
|
} catch (error) {
|
|
357
353
|
if (!isPineconeNotFound(error))
|
|
358
354
|
throw error;
|
|
@@ -391,17 +387,20 @@ var DEFAULT_INDEX_READY_POLL_MS = 1500;
|
|
|
391
387
|
var DEFAULT_SERVERLESS_SPEC = {
|
|
392
388
|
serverless: { cloud: "aws", region: "us-east-1" }
|
|
393
389
|
};
|
|
390
|
+
var readNumberProperty = (source, key) => {
|
|
391
|
+
const value = source[key];
|
|
392
|
+
return typeof value === "number" ? value : undefined;
|
|
393
|
+
};
|
|
394
394
|
var isPineconeNotFound = (error) => {
|
|
395
|
-
if (!error)
|
|
395
|
+
if (!isObjectRecord(error))
|
|
396
396
|
return false;
|
|
397
|
-
const
|
|
398
|
-
const status = err.status ?? err.statusCode ?? err.response?.status ?? undefined;
|
|
397
|
+
const status = readNumberProperty(error, "status") ?? readNumberProperty(error, "statusCode") ?? (isObjectRecord(error.response) ? readNumberProperty(error.response, "status") : undefined);
|
|
399
398
|
if (status === 404)
|
|
400
399
|
return true;
|
|
401
|
-
const name =
|
|
400
|
+
const name = typeof error.name === "string" ? error.name : "";
|
|
402
401
|
if (name === "PineconeNotFoundError")
|
|
403
402
|
return true;
|
|
404
|
-
const message =
|
|
403
|
+
const message = typeof error.message === "string" ? error.message.toLowerCase() : "";
|
|
405
404
|
return message.includes("not found") || message.includes("does not exist") || message.includes("404");
|
|
406
405
|
};
|
|
407
406
|
var resolveProvisioningClient = async (options) => {
|
|
@@ -419,12 +418,12 @@ var waitForIndexReady = async (pc, indexName, timeoutMs, pollIntervalMs) => {
|
|
|
419
418
|
const deadline = Date.now() + timeoutMs;
|
|
420
419
|
for (;; ) {
|
|
421
420
|
const description = await pc.describeIndex(indexName);
|
|
422
|
-
const status = description
|
|
423
|
-
const ready = status
|
|
421
|
+
const status = description.status;
|
|
422
|
+
const ready = status.ready === true || status.state === "Ready" || status.state === "ScalingUp";
|
|
424
423
|
if (ready)
|
|
425
424
|
return description;
|
|
426
425
|
if (Date.now() >= deadline) {
|
|
427
|
-
throw new Error(`${PKG}: index "${indexName}" did not become ready within ${timeoutMs}ms (last state: ${status
|
|
426
|
+
throw new Error(`${PKG}: index "${indexName}" did not become ready within ${timeoutMs}ms (last state: ${status.state ?? "unknown"})`);
|
|
428
427
|
}
|
|
429
428
|
await new Promise((resolve) => setTimeout(resolve, pollIntervalMs));
|
|
430
429
|
}
|
|
@@ -439,6 +438,7 @@ var describePineconeIndex = async (options) => {
|
|
|
439
438
|
throw error;
|
|
440
439
|
}
|
|
441
440
|
};
|
|
441
|
+
var toCreateIndexSpec = (spec) => ("serverless" in spec) ? { serverless: spec.serverless } : { pod: spec.pod };
|
|
442
442
|
var ensurePineconeIndex = async (options) => {
|
|
443
443
|
if (!Number.isInteger(options.dimensions) || options.dimensions <= 0) {
|
|
444
444
|
throw new Error(`${PKG}: dimensions must be a positive integer (received ${String(options.dimensions)})`);
|
|
@@ -460,25 +460,26 @@ var ensurePineconeIndex = async (options) => {
|
|
|
460
460
|
}
|
|
461
461
|
if (existing) {
|
|
462
462
|
if (existing.dimension !== options.dimensions) {
|
|
463
|
-
throw new Error(`${PKG}: index "${options.indexName}" already exists with dimension=${existing.dimension}, but ${options.dimensions} was requested`);
|
|
463
|
+
throw new Error(`${PKG}: index "${options.indexName}" already exists with dimension=${String(existing.dimension)}, but ${options.dimensions} was requested`);
|
|
464
464
|
}
|
|
465
465
|
if (existing.metric && existing.metric !== metric) {
|
|
466
466
|
throw new Error(`${PKG}: index "${options.indexName}" already exists with metric="${existing.metric}", but "${metric}" was requested`);
|
|
467
467
|
}
|
|
468
|
-
if (shouldWait && existing.status
|
|
468
|
+
if (shouldWait && existing.status.ready !== true) {
|
|
469
469
|
const description2 = await waitForIndexReady(pc, options.indexName, timeoutMs, pollIntervalMs);
|
|
470
470
|
return { created: false, description: description2 };
|
|
471
471
|
}
|
|
472
472
|
return { created: false, description: existing };
|
|
473
473
|
}
|
|
474
|
-
const spec = options.spec ?? DEFAULT_SERVERLESS_SPEC;
|
|
475
|
-
|
|
474
|
+
const spec = toCreateIndexSpec(options.spec ?? DEFAULT_SERVERLESS_SPEC);
|
|
475
|
+
const createOptions = {
|
|
476
476
|
name: options.indexName,
|
|
477
477
|
dimension: options.dimensions,
|
|
478
478
|
metric,
|
|
479
479
|
spec,
|
|
480
480
|
...options.deletionProtection ? { deletionProtection: options.deletionProtection } : {}
|
|
481
|
-
}
|
|
481
|
+
};
|
|
482
|
+
await pc.createIndex(createOptions);
|
|
482
483
|
if (!shouldWait) {
|
|
483
484
|
let description2;
|
|
484
485
|
try {
|
|
@@ -514,5 +515,5 @@ export {
|
|
|
514
515
|
ABSOLUTE_PINECONE_RAG_PACKAGE_NAME
|
|
515
516
|
};
|
|
516
517
|
|
|
517
|
-
//# debugId=
|
|
518
|
+
//# debugId=DE0CBE49A367C19C64756E2164756E21
|
|
518
519
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"import type {\n\tRAGBackendCapabilities,\n\tRAGCollection,\n\tRAGQueryInput,\n\tRAGQueryResult,\n\tRAGUpsertInput,\n\tRAGVectorStore\n} from '@absolutejs/rag';\nimport {\n\tcreateRAGCollection,\n\tcreateRAGVector,\n\tnormalizeVector\n} from '@absolutejs/rag';\n\nexport const ABSOLUTE_PINECONE_RAG_PACKAGE_NAME = '@absolutejs/rag-pinecone';\n\nexport const PINECONE_DISTANCE_METRICS = [\n\t'cosine',\n\t'euclidean',\n\t'dotproduct'\n] as const;\n\nexport type PineconeDistanceMetric = 'cosine' | 'euclidean' | 'dotproduct';\n\nexport type PineconeIndexClient = {\n\tupsert: (records: unknown[]) => Promise<unknown>;\n\tquery: (input: Record<string, unknown>) => Promise<{\n\t\tmatches?: Array<{\n\t\t\tid: string;\n\t\t\tscore?: number;\n\t\t\tvalues?: number[];\n\t\t\tmetadata?: Record<string, unknown>;\n\t\t}>;\n\t}>;\n\tfetch: (ids: string[]) => Promise<{\n\t\trecords?: Record<string, unknown>;\n\t}>;\n\tdeleteMany: (input: string[] | Record<string, unknown>) => Promise<unknown>;\n\tdeleteAll: () => Promise<unknown>;\n\tdescribeIndexStats: () => Promise<{\n\t\ttotalRecordCount?: number;\n\t\tnamespaces?: Record<string, { recordCount?: number }>;\n\t}>;\n\tnamespace?: (namespace: string) => PineconeIndexClient;\n};\n\nexport type PineconeRAGVectorConfig = {\n\tprovider: 'pinecone';\n\tdimensions: number;\n\tdistanceMetric?: PineconeDistanceMetric;\n};\n\nexport type PineconeRAGOptions = {\n\tapiKey?: string;\n\tindexName?: string;\n\tindexHost?: string;\n\tnamespace?: string;\n\tclient?: PineconeIndexClient;\n\tvector: PineconeRAGVectorConfig;\n\tembedding?: RAGVectorStore['embed'];\n};\n\nexport type PineconeRAG = {\n\tstore: RAGVectorStore;\n\tcollection: RAGCollection;\n\tgetCapabilities: () => RAGBackendCapabilities | undefined;\n};\n\nexport type PineconeServerlessSpec = {\n\tserverless: {\n\t\tcloud: 'aws' | 'gcp' | 'azure';\n\t\tregion: string;\n\t};\n};\n\nexport type PineconePodSpec = {\n\tpod: {\n\t\tenvironment: string;\n\t\tpodType: string;\n\t\tpods?: number;\n\t\treplicas?: number;\n\t\tshards?: number;\n\t\tmetadataConfig?: { indexed?: string[] };\n\t\tsourceCollection?: string;\n\t};\n};\n\nexport type PineconeIndexSpec = PineconeServerlessSpec | PineconePodSpec;\n\nexport type PineconeIndexDescription = {\n\tname: string;\n\tdimension: number;\n\tmetric: PineconeDistanceMetric;\n\thost?: string;\n\tspec?: PineconeIndexSpec;\n\tstatus?: { ready?: boolean; state?: string };\n\tdeletionProtection?: 'enabled' | 'disabled';\n};\n\nexport type DescribePineconeIndexOptions = {\n\tapiKey?: string;\n\tindexName: string;\n};\n\nexport type EnsurePineconeIndexOptions = {\n\tapiKey?: string;\n\tindexName: string;\n\tdimensions: number;\n\tmetric?: PineconeDistanceMetric;\n\tspec?: PineconeIndexSpec;\n\tdeletionProtection?: 'enabled' | 'disabled';\n\twaitUntilReady?: boolean;\n\twaitTimeoutMs?: number;\n\tpollIntervalMs?: number;\n};\n\nexport type EnsurePineconeIndexResult = {\n\tcreated: boolean;\n\tdescription: PineconeIndexDescription | undefined;\n};\n\ntype ResolvedPineconeVectorConfig = {\n\tprovider: 'pinecone';\n\tdimensions: number;\n\tdistanceMetric: PineconeDistanceMetric;\n};\n\ntype MetadataValue = string | number | boolean | string[];\n\ntype PineconeRecord = {\n\tid: string;\n\tvalues: number[];\n\tmetadata: Record<string, MetadataValue>;\n};\n\ntype PineconeQueryMatch = {\n\tid: string;\n\tscore?: number;\n\tvalues?: number[];\n\tmetadata?: Record<string, unknown>;\n};\n\ntype PineconeFilter = Record<string, unknown>;\n\nconst PKG = ABSOLUTE_PINECONE_RAG_PACKAGE_NAME;\nconst DEFAULT_DIMENSIONS = 1536;\nconst DEFAULT_DISTANCE_METRIC: PineconeDistanceMetric = 'cosine';\nconst PINECONE_UPSERT_BATCH_SIZE = 100;\nconst PINECONE_FETCH_BATCH_SIZE = 1000;\nconst PINECONE_FILTERED_COUNT_TOPK = 10000;\nconst RESERVED_METADATA_KEYS = new Set(['chunkId', 'text', 'title', 'source']);\n\nconst isObjectRecord = (value: unknown): value is Record<string, unknown> =>\n\tBoolean(value) && typeof value === 'object' && !Array.isArray(value);\n\nconst isOperatorRecord = (value: unknown): value is Record<string, unknown> =>\n\tisObjectRecord(value) &&\n\tObject.keys(value).length > 0 &&\n\tObject.keys(value).every((key) => key.startsWith('$'));\n\nconst chunkArray = <T>(input: readonly T[], size: number): T[][] => {\n\tconst out: T[][] = [];\n\tfor (let i = 0; i < input.length; i += size) {\n\t\tout.push(input.slice(i, i + size));\n\t}\n\n\treturn out;\n};\n\nconst resolveVectorConfig = (\n\toptions: Partial<PineconeRAGOptions>\n): ResolvedPineconeVectorConfig => {\n\tconst vector = options?.vector;\n\tif (!vector || vector.provider !== 'pinecone') {\n\t\tthrow new Error(\n\t\t\t`${PKG}: Pinecone RAG requires vector.provider = \"pinecone\"`\n\t\t);\n\t}\n\tconst dimensions = vector.dimensions ?? DEFAULT_DIMENSIONS;\n\tif (!Number.isInteger(dimensions) || dimensions <= 0) {\n\t\tthrow new Error(\n\t\t\t`${PKG}: vector.dimensions must be a positive integer (received ${String(\n\t\t\t\tdimensions\n\t\t\t)})`\n\t\t);\n\t}\n\tconst distanceMetric = vector.distanceMetric ?? DEFAULT_DISTANCE_METRIC;\n\tif (!PINECONE_DISTANCE_METRICS.includes(distanceMetric)) {\n\t\tthrow new Error(\n\t\t\t`${PKG}: unsupported distanceMetric \"${distanceMetric}\". Allowed: ${PINECONE_DISTANCE_METRICS.join(\n\t\t\t\t', '\n\t\t\t)}`\n\t\t);\n\t}\n\n\treturn { provider: 'pinecone', dimensions, distanceMetric };\n};\n\ntype PineconeSDKModule = {\n\tPinecone: new (config: { apiKey: string }) => {\n\t\tindex: (name: string, host?: string) => PineconeIndexClient;\n\t\tcreateIndex: (input: Record<string, unknown>) => Promise<unknown>;\n\t\tdescribeIndex: (name: string) => Promise<PineconeIndexDescription>;\n\t};\n};\n\nlet pineconeModulePromise: Promise<PineconeSDKModule> | undefined;\nconst loadPineconeSDK = (): Promise<PineconeSDKModule> => {\n\tif (!pineconeModulePromise) {\n\t\tpineconeModulePromise = (\n\t\t\timport('@pinecone-database/pinecone') as Promise<unknown> as Promise<PineconeSDKModule>\n\t\t).catch((error: unknown) => {\n\t\t\tpineconeModulePromise = undefined;\n\t\t\tthrow new Error(\n\t\t\t\t`${PKG}: failed to load @pinecone-database/pinecone — install it as a dependency. (${\n\t\t\t\t\terror instanceof Error ? error.message : String(error)\n\t\t\t\t})`\n\t\t\t);\n\t\t});\n\t}\n\n\treturn pineconeModulePromise;\n};\n\nconst resolveIndexClientFactory = (\n\toptions: PineconeRAGOptions\n): (() => Promise<PineconeIndexClient>) => {\n\tconst namespace =\n\t\ttypeof options.namespace === 'string' && options.namespace.length > 0\n\t\t\t? options.namespace\n\t\t\t: undefined;\n\n\tlet cached: PineconeIndexClient | undefined;\n\n\tconst applyNamespace = (idx: PineconeIndexClient): PineconeIndexClient => {\n\t\tif (!namespace || typeof idx.namespace !== 'function') return idx;\n\n\t\treturn idx.namespace(namespace);\n\t};\n\n\tif (options.client) {\n\t\tconst injectedClient = options.client;\n\n\t\treturn async () => {\n\t\t\tif (cached) return cached;\n\t\t\tcached = applyNamespace(injectedClient);\n\n\t\t\treturn cached;\n\t\t};\n\t}\n\n\tconst indexName = options.indexName;\n\tif (typeof indexName !== 'string' || indexName.length === 0) {\n\t\tthrow new Error(\n\t\t\t`${PKG}: indexName is required when client is not provided`\n\t\t);\n\t}\n\tconst apiKey = options.apiKey ?? process.env.PINECONE_API_KEY;\n\tif (!apiKey) {\n\t\tthrow new Error(\n\t\t\t`${PKG}: missing Pinecone apiKey (pass options.apiKey or set PINECONE_API_KEY)`\n\t\t);\n\t}\n\n\treturn async () => {\n\t\tif (cached) return cached;\n\t\tconst { Pinecone } = await loadPineconeSDK();\n\t\tconst pc = new Pinecone({ apiKey });\n\t\tconst baseIndex = options.indexHost\n\t\t\t? pc.index(indexName, options.indexHost)\n\t\t\t: pc.index(indexName);\n\t\tcached = applyNamespace(baseIndex);\n\n\t\treturn cached;\n\t};\n};\n\nconst sanitizeMetadataValue = (value: unknown): MetadataValue | undefined => {\n\tif (value === null || value === undefined) return undefined;\n\tif (typeof value === 'string' || typeof value === 'boolean') return value;\n\tif (typeof value === 'number') {\n\t\treturn Number.isFinite(value) ? value : undefined;\n\t}\n\tif (Array.isArray(value)) {\n\t\tconst strings: string[] = [];\n\t\tfor (const entry of value) {\n\t\t\tif (entry === null || entry === undefined) continue;\n\t\t\tif (typeof entry === 'string') {\n\t\t\t\tstrings.push(entry);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (typeof entry === 'number' && Number.isFinite(entry)) {\n\t\t\t\tstrings.push(String(entry));\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (typeof entry === 'boolean') {\n\t\t\t\tstrings.push(String(entry));\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\n\t\treturn strings;\n\t}\n\tif (typeof value === 'object') {\n\t\ttry {\n\t\t\treturn JSON.stringify(value);\n\t\t} catch {\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\treturn undefined;\n};\n\nconst sanitizeMetadata = (\n\tmetadata: unknown\n): Record<string, MetadataValue> => {\n\tif (!isObjectRecord(metadata)) return {};\n\tconst out: Record<string, MetadataValue> = {};\n\tfor (const [key, value] of Object.entries(metadata)) {\n\t\tif (RESERVED_METADATA_KEYS.has(key)) continue;\n\t\tconst sanitized = sanitizeMetadataValue(value);\n\t\tif (sanitized === undefined) continue;\n\t\tout[key] = sanitized;\n\t}\n\n\treturn out;\n};\n\nconst translateOperatorFilter = (\n\tfield: string,\n\toperatorRecord: Record<string, unknown>\n): PineconeFilter | undefined => {\n\tconst direct: Record<string, unknown> = {};\n\tconst expanded: PineconeFilter[] = [];\n\tfor (const [op, value] of Object.entries(operatorRecord)) {\n\t\tswitch (op) {\n\t\t\tcase '$eq':\n\t\t\tcase '$ne':\n\t\t\tcase '$gt':\n\t\t\tcase '$gte':\n\t\t\tcase '$lt':\n\t\t\tcase '$lte':\n\t\t\t\tdirect[op] = value;\n\t\t\t\tbreak;\n\t\t\tcase '$in':\n\t\t\t\tif (Array.isArray(value)) direct.$in = value;\n\t\t\t\tbreak;\n\t\t\tcase '$exists':\n\t\t\t\tdirect.$exists = Boolean(value);\n\t\t\t\tbreak;\n\t\t\tcase '$contains':\n\t\t\t\tdirect.$in = [value];\n\t\t\t\tbreak;\n\t\t\tcase '$containsAny':\n\t\t\t\tif (Array.isArray(value)) direct.$in = value;\n\t\t\t\tbreak;\n\t\t\tcase '$containsAll':\n\t\t\t\tif (Array.isArray(value)) {\n\t\t\t\t\tfor (const entry of value) {\n\t\t\t\t\t\texpanded.push({ [field]: { $in: [entry] } });\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthrow new Error(`${PKG}: unsupported filter operator \"${op}\"`);\n\t\t}\n\t}\n\tif (expanded.length === 0) {\n\t\treturn Object.keys(direct).length > 0 ? { [field]: direct } : undefined;\n\t}\n\tif (Object.keys(direct).length === 0) {\n\t\treturn expanded.length === 1 ? expanded[0] : { $and: expanded };\n\t}\n\n\treturn { $and: [{ [field]: direct }, ...expanded] };\n};\n\nconst translateFilter = (filter: unknown): PineconeFilter | undefined => {\n\tif (!isObjectRecord(filter) || Object.keys(filter).length === 0) {\n\t\treturn undefined;\n\t}\n\tconst clauses: PineconeFilter[] = [];\n\tfor (const [key, value] of Object.entries(filter)) {\n\t\tif (key === '$and' || key === '$or') {\n\t\t\tif (!Array.isArray(value)) continue;\n\t\t\tconst subs = value\n\t\t\t\t.map((entry) => translateFilter(entry))\n\t\t\t\t.filter(\n\t\t\t\t\t(entry): entry is PineconeFilter => entry !== undefined\n\t\t\t\t);\n\t\t\tif (subs.length > 0) clauses.push({ [key]: subs });\n\t\t\tcontinue;\n\t\t}\n\t\tif (key === '$not') {\n\t\t\tthrow new Error(`${PKG}: $not is not supported by Pinecone`);\n\t\t}\n\t\tif (key.includes('.')) {\n\t\t\tthrow new Error(\n\t\t\t\t`${PKG}: nested key paths (\"${key}\") are not supported by Pinecone (metadata is flat)`\n\t\t\t);\n\t\t}\n\t\tif (isOperatorRecord(value)) {\n\t\t\tconst translated = translateOperatorFilter(key, value);\n\t\t\tif (translated) clauses.push(translated);\n\t\t\tcontinue;\n\t\t}\n\t\tclauses.push({ [key]: { $eq: value } });\n\t}\n\tif (clauses.length === 0) return undefined;\n\tif (clauses.length === 1) return clauses[0];\n\n\treturn { $and: clauses };\n};\n\nconst scoreForMetric = (\n\trawScore: unknown,\n\tdistanceMetric: PineconeDistanceMetric\n): number => {\n\tif (typeof rawScore !== 'number' || !Number.isFinite(rawScore)) return 0;\n\tswitch (distanceMetric) {\n\t\tcase 'euclidean':\n\t\t\treturn 1 / (1 + Math.abs(rawScore));\n\t\tcase 'dotproduct':\n\t\tcase 'cosine':\n\t\tdefault:\n\t\t\treturn rawScore;\n\t}\n};\n\nconst buildPineconeRecord = (\n\tchunk: RAGUpsertInput['chunks'][number],\n\tvalues: number[]\n): PineconeRecord => {\n\tconst metadata: Record<string, MetadataValue> = {\n\t\t...sanitizeMetadata(chunk.metadata),\n\t\tchunkId: chunk.chunkId,\n\t\ttext: chunk.text\n\t};\n\tif (chunk.title) metadata.title = chunk.title;\n\tif (chunk.source) metadata.source = chunk.source;\n\n\treturn { id: chunk.chunkId, values, metadata };\n};\n\nconst extractQueryResult = (\n\tmatch: PineconeQueryMatch,\n\tdistanceMetric: PineconeDistanceMetric\n): RAGQueryResult => {\n\tconst meta = isObjectRecord(match.metadata) ? match.metadata : {};\n\tconst userMetadata: Record<string, unknown> = {};\n\tfor (const [key, value] of Object.entries(meta)) {\n\t\tif (RESERVED_METADATA_KEYS.has(key)) continue;\n\t\tuserMetadata[key] = value;\n\t}\n\tconst chunkId =\n\t\ttypeof meta.chunkId === 'string' ? meta.chunkId : String(match.id);\n\tconst chunkText = typeof meta.text === 'string' ? meta.text : '';\n\n\treturn {\n\t\tchunkId,\n\t\tchunkText,\n\t\ttitle: typeof meta.title === 'string' ? meta.title : undefined,\n\t\tsource: typeof meta.source === 'string' ? meta.source : undefined,\n\t\tmetadata:\n\t\t\tObject.keys(userMetadata).length > 0 ? userMetadata : undefined,\n\t\tscore: scoreForMetric(match.score, distanceMetric)\n\t};\n};\n\nexport const createPineconeStore = (\n\toptions: PineconeRAGOptions\n): RAGVectorStore => {\n\tconst vector = resolveVectorConfig(options ?? {});\n\tconst namespace =\n\t\ttypeof options.namespace === 'string' && options.namespace.length > 0\n\t\t\t? options.namespace\n\t\t\t: undefined;\n\tconst getClient = resolveIndexClientFactory(options ?? {});\n\n\tconst embed: RAGVectorStore['embed'] = async (input) => {\n\t\tif (typeof options.embedding === 'function') {\n\t\t\tconst result = await options.embedding(input);\n\n\t\t\treturn normalizeVector(result);\n\t\t}\n\n\t\treturn normalizeVector([\n\t\t\t...createRAGVector(input.text, vector.dimensions)\n\t\t]);\n\t};\n\n\tconst upsert = async (input: RAGUpsertInput): Promise<void> => {\n\t\tif (!input?.chunks || input.chunks.length === 0) return;\n\t\tconst client = await getClient();\n\t\tconst records = await Promise.all(\n\t\t\tinput.chunks.map(async (chunk) => {\n\t\t\t\tconst values =\n\t\t\t\t\tArray.isArray(chunk.embedding) && chunk.embedding.length > 0\n\t\t\t\t\t\t? normalizeVector(chunk.embedding)\n\t\t\t\t\t\t: await embed({ text: chunk.text });\n\n\t\t\t\treturn buildPineconeRecord(chunk, values);\n\t\t\t})\n\t\t);\n\t\tfor (const batch of chunkArray(records, PINECONE_UPSERT_BATCH_SIZE)) {\n\t\t\tawait client.upsert(batch);\n\t\t}\n\t};\n\n\tconst query = async (input: RAGQueryInput): Promise<RAGQueryResult[]> => {\n\t\tconst client = await getClient();\n\t\tconst filter = translateFilter(input.filter);\n\t\tconst queryInput: Record<string, unknown> = {\n\t\t\tvector: normalizeVector(input.queryVector),\n\t\t\ttopK: input.topK,\n\t\t\tincludeMetadata: true,\n\t\t\tincludeValues: false\n\t\t};\n\t\tif (filter) queryInput.filter = filter;\n\t\tconst result = await client.query(queryInput);\n\t\tconst matches = Array.isArray(result?.matches) ? result.matches : [];\n\n\t\treturn matches.map((match) =>\n\t\t\textractQueryResult(match, vector.distanceMetric)\n\t\t);\n\t};\n\n\tconst count = async (\n\t\tinput: { chunkIds?: string[]; filter?: Record<string, unknown> } = {}\n\t): Promise<number> => {\n\t\tconst client = await getClient();\n\t\tif (Array.isArray(input.chunkIds) && input.chunkIds.length > 0) {\n\t\t\tlet total = 0;\n\t\t\tfor (const batch of chunkArray(\n\t\t\t\tinput.chunkIds,\n\t\t\t\tPINECONE_FETCH_BATCH_SIZE\n\t\t\t)) {\n\t\t\t\tconst response = await client.fetch(batch);\n\t\t\t\ttotal += Object.keys(response?.records ?? {}).length;\n\t\t\t}\n\n\t\t\treturn total;\n\t\t}\n\t\tif (\n\t\t\tisObjectRecord(input.filter) &&\n\t\t\tObject.keys(input.filter).length > 0\n\t\t) {\n\t\t\tconst filter = translateFilter(input.filter);\n\t\t\tconst probeVector = new Array(vector.dimensions).fill(0);\n\t\t\tconst queryInput: Record<string, unknown> = {\n\t\t\t\tvector: probeVector,\n\t\t\t\ttopK: PINECONE_FILTERED_COUNT_TOPK,\n\t\t\t\tincludeMetadata: false,\n\t\t\t\tincludeValues: false\n\t\t\t};\n\t\t\tif (filter) queryInput.filter = filter;\n\t\t\tconst result = await client.query(queryInput);\n\n\t\t\treturn Array.isArray(result?.matches) ? result.matches.length : 0;\n\t\t}\n\t\tconst stats = await client.describeIndexStats();\n\t\tif (namespace) {\n\t\t\treturn stats?.namespaces?.[namespace]?.recordCount ?? 0;\n\t\t}\n\n\t\treturn stats?.totalRecordCount ?? 0;\n\t};\n\n\tconst remove = async (\n\t\tinput: { chunkIds?: string[]; filter?: Record<string, unknown> } = {}\n\t): Promise<number> => {\n\t\tconst client = await getClient();\n\t\tif (Array.isArray(input.chunkIds) && input.chunkIds.length > 0) {\n\t\t\tfor (const batch of chunkArray(\n\t\t\t\tinput.chunkIds,\n\t\t\t\tPINECONE_FETCH_BATCH_SIZE\n\t\t\t)) {\n\t\t\t\ttry {\n\t\t\t\t\tawait client.deleteMany(batch);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tif (!isPineconeNotFound(error)) throw error;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn input.chunkIds.length;\n\t\t}\n\t\tif (\n\t\t\tisObjectRecord(input.filter) &&\n\t\t\tObject.keys(input.filter).length > 0\n\t\t) {\n\t\t\tconst filter = translateFilter(input.filter);\n\t\t\tif (!filter) return 0;\n\t\t\tconst counted = await count({ filter: input.filter });\n\t\t\ttry {\n\t\t\t\tawait client.deleteMany({ filter });\n\t\t\t} catch (error) {\n\t\t\t\tif (!isPineconeNotFound(error)) throw error;\n\t\t\t}\n\n\t\t\treturn counted;\n\t\t}\n\n\t\treturn 0;\n\t};\n\n\tconst clear = async (): Promise<void> => {\n\t\tconst client = await getClient();\n\t\ttry {\n\t\t\tawait client.deleteAll();\n\t\t} catch (error) {\n\t\t\tif (!isPineconeNotFound(error)) throw error;\n\t\t}\n\t};\n\n\treturn {\n\t\tembed,\n\t\tquery,\n\t\tupsert,\n\t\tcount,\n\t\tdelete: remove,\n\t\tclear,\n\t\tgetCapabilities: () => ({\n\t\t\tbackend: 'custom',\n\t\t\tpersistence: 'external',\n\t\t\tnativeVectorSearch: true,\n\t\t\tserverSideFiltering: true,\n\t\t\tstreamingIngestStatus: false\n\t\t})\n\t} as RAGVectorStore;\n};\n\nconst DEFAULT_INDEX_READY_TIMEOUT_MS = 120000;\nconst DEFAULT_INDEX_READY_POLL_MS = 1500;\nconst DEFAULT_SERVERLESS_SPEC: PineconeServerlessSpec = {\n\tserverless: { cloud: 'aws', region: 'us-east-1' }\n};\n\ntype PineconeErrorLike = {\n\tstatus?: number;\n\tstatusCode?: number;\n\tresponse?: { status?: number };\n\tname?: string;\n\tmessage?: string;\n};\n\nconst isPineconeNotFound = (error: unknown): boolean => {\n\tif (!error) return false;\n\tconst err = error as PineconeErrorLike;\n\tconst status = err.status ?? err.statusCode ?? err.response?.status ?? undefined;\n\tif (status === 404) return true;\n\tconst name = String(err.name ?? '');\n\tif (name === 'PineconeNotFoundError') return true;\n\tconst message = String(err.message ?? '').toLowerCase();\n\n\treturn (\n\t\tmessage.includes('not found') ||\n\t\tmessage.includes('does not exist') ||\n\t\tmessage.includes('404')\n\t);\n};\n\nconst resolveProvisioningClient = async (\n\toptions: DescribePineconeIndexOptions | EnsurePineconeIndexOptions\n): Promise<InstanceType<PineconeSDKModule['Pinecone']>> => {\n\tconst apiKey = options.apiKey ?? process.env.PINECONE_API_KEY;\n\tif (!apiKey) {\n\t\tthrow new Error(\n\t\t\t`${PKG}: missing Pinecone apiKey (pass options.apiKey or set PINECONE_API_KEY)`\n\t\t);\n\t}\n\tif (\n\t\ttypeof options.indexName !== 'string' ||\n\t\toptions.indexName.length === 0\n\t) {\n\t\tthrow new Error(`${PKG}: indexName is required`);\n\t}\n\tconst { Pinecone } = await loadPineconeSDK();\n\n\treturn new Pinecone({ apiKey });\n};\n\nconst waitForIndexReady = async (\n\tpc: InstanceType<PineconeSDKModule['Pinecone']>,\n\tindexName: string,\n\ttimeoutMs: number,\n\tpollIntervalMs: number\n): Promise<PineconeIndexDescription> => {\n\tconst deadline = Date.now() + timeoutMs;\n\tfor (;;) {\n\t\tconst description = await pc.describeIndex(indexName);\n\t\tconst status = description?.status;\n\t\tconst ready =\n\t\t\tstatus?.ready === true ||\n\t\t\tstatus?.state === 'Ready' ||\n\t\t\tstatus?.state === 'ScalingUp';\n\t\tif (ready) return description;\n\t\tif (Date.now() >= deadline) {\n\t\t\tthrow new Error(\n\t\t\t\t`${PKG}: index \"${indexName}\" did not become ready within ${timeoutMs}ms (last state: ${\n\t\t\t\t\tstatus?.state ?? 'unknown'\n\t\t\t\t})`\n\t\t\t);\n\t\t}\n\t\tawait new Promise((resolve) => setTimeout(resolve, pollIntervalMs));\n\t}\n};\n\nexport const describePineconeIndex = async (\n\toptions: DescribePineconeIndexOptions\n): Promise<PineconeIndexDescription | undefined> => {\n\tconst pc = await resolveProvisioningClient(options);\n\ttry {\n\t\treturn await pc.describeIndex(options.indexName);\n\t} catch (error) {\n\t\tif (isPineconeNotFound(error)) return undefined;\n\t\tthrow error;\n\t}\n};\n\nexport const ensurePineconeIndex = async (\n\toptions: EnsurePineconeIndexOptions\n): Promise<EnsurePineconeIndexResult> => {\n\tif (!Number.isInteger(options.dimensions) || options.dimensions <= 0) {\n\t\tthrow new Error(\n\t\t\t`${PKG}: dimensions must be a positive integer (received ${String(\n\t\t\t\toptions.dimensions\n\t\t\t)})`\n\t\t);\n\t}\n\tconst metric = options.metric ?? 'cosine';\n\tif (!PINECONE_DISTANCE_METRICS.includes(metric)) {\n\t\tthrow new Error(\n\t\t\t`${PKG}: unsupported metric \"${metric}\". Allowed: ${PINECONE_DISTANCE_METRICS.join(\n\t\t\t\t', '\n\t\t\t)}`\n\t\t);\n\t}\n\tconst pc = await resolveProvisioningClient(options);\n\tconst timeoutMs = options.waitTimeoutMs ?? DEFAULT_INDEX_READY_TIMEOUT_MS;\n\tconst pollIntervalMs = options.pollIntervalMs ?? DEFAULT_INDEX_READY_POLL_MS;\n\tconst shouldWait = options.waitUntilReady !== false;\n\n\tlet existing: PineconeIndexDescription | undefined;\n\ttry {\n\t\texisting = await pc.describeIndex(options.indexName);\n\t} catch (error) {\n\t\tif (!isPineconeNotFound(error)) throw error;\n\t}\n\n\tif (existing) {\n\t\tif (existing.dimension !== options.dimensions) {\n\t\t\tthrow new Error(\n\t\t\t\t`${PKG}: index \"${options.indexName}\" already exists with dimension=${existing.dimension}, but ${options.dimensions} was requested`\n\t\t\t);\n\t\t}\n\t\tif (existing.metric && existing.metric !== metric) {\n\t\t\tthrow new Error(\n\t\t\t\t`${PKG}: index \"${options.indexName}\" already exists with metric=\"${existing.metric}\", but \"${metric}\" was requested`\n\t\t\t);\n\t\t}\n\t\tif (shouldWait && existing.status?.ready !== true) {\n\t\t\tconst description = await waitForIndexReady(\n\t\t\t\tpc,\n\t\t\t\toptions.indexName,\n\t\t\t\ttimeoutMs,\n\t\t\t\tpollIntervalMs\n\t\t\t);\n\n\t\t\treturn { created: false, description };\n\t\t}\n\n\t\treturn { created: false, description: existing };\n\t}\n\n\tconst spec = options.spec ?? DEFAULT_SERVERLESS_SPEC;\n\tawait pc.createIndex({\n\t\tname: options.indexName,\n\t\tdimension: options.dimensions,\n\t\tmetric,\n\t\tspec,\n\t\t...(options.deletionProtection\n\t\t\t? { deletionProtection: options.deletionProtection }\n\t\t\t: {})\n\t});\n\n\tif (!shouldWait) {\n\t\tlet description: PineconeIndexDescription | undefined;\n\t\ttry {\n\t\t\tdescription = await pc.describeIndex(options.indexName);\n\t\t} catch (error) {\n\t\t\tif (!isPineconeNotFound(error)) throw error;\n\t\t}\n\n\t\treturn { created: true, description };\n\t}\n\n\tconst description = await waitForIndexReady(\n\t\tpc,\n\t\toptions.indexName,\n\t\ttimeoutMs,\n\t\tpollIntervalMs\n\t);\n\n\treturn { created: true, description };\n};\n\nexport const createPineconeRAGCollection = (\n\toptions: PineconeRAGOptions\n): RAGCollection =>\n\tcreateRAGCollection({\n\t\tstore: createPineconeStore(options)\n\t});\n\nexport const createPineconeRAG = (options: PineconeRAGOptions): PineconeRAG => {\n\tconst store = createPineconeStore(options);\n\tconst collection = createRAGCollection({ store });\n\n\treturn {\n\t\tstore,\n\t\tcollection,\n\t\tgetCapabilities: () => store.getCapabilities?.()\n\t};\n};\n"
|
|
5
|
+
"import type {\n\tCreateIndexOptions,\n\tIndex,\n\tIndexModel,\n\tPineconeRecord,\n\tQueryResponse,\n\tRecordMetadata,\n\tScoredPineconeRecord\n} from '@pinecone-database/pinecone';\nimport type {\n\tRAGBackendCapabilities,\n\tRAGCollection,\n\tRAGQueryInput,\n\tRAGQueryResult,\n\tRAGUpsertInput,\n\tRAGVectorStore\n} from '@absolutejs/rag/adapter-kit';\nimport {\n\tcreateRAGCollection,\n\tcreateRAGVector,\n\tnormalizeVector\n} from '@absolutejs/rag/adapter-kit';\n\nexport const ABSOLUTE_PINECONE_RAG_PACKAGE_NAME = '@absolutejs/rag-pinecone';\n\nexport const PINECONE_DISTANCE_METRICS = [\n\t'cosine',\n\t'euclidean',\n\t'dotproduct'\n] as const;\n\nexport type PineconeDistanceMetric = 'cosine' | 'euclidean' | 'dotproduct';\n\ntype PineconeIndexClient = Index<RecordMetadata>;\n\nexport type PineconeRAGVectorConfig = {\n\tprovider: 'pinecone';\n\tdimensions: number;\n\tdistanceMetric?: PineconeDistanceMetric;\n};\n\nexport type PineconeRAGOptions = {\n\tapiKey?: string;\n\tindexName?: string;\n\tindexHost?: string;\n\tnamespace?: string;\n\tclient?: PineconeIndexClient;\n\tvector: PineconeRAGVectorConfig;\n\tembedding?: RAGVectorStore['embed'];\n};\n\nexport type PineconeRAG = {\n\tstore: RAGVectorStore;\n\tcollection: RAGCollection;\n\tgetCapabilities: () => RAGBackendCapabilities | undefined;\n};\n\nexport type PineconeServerlessSpec = {\n\tserverless: {\n\t\tcloud: 'aws' | 'gcp' | 'azure';\n\t\tregion: string;\n\t};\n};\n\nexport type PineconePodSpec = {\n\tpod: {\n\t\tenvironment: string;\n\t\tpodType: string;\n\t\tpods?: number;\n\t\treplicas?: number;\n\t\tshards?: number;\n\t\tmetadataConfig?: { indexed?: string[] };\n\t\tsourceCollection?: string;\n\t};\n};\n\nexport type PineconeIndexSpec = PineconeServerlessSpec | PineconePodSpec;\n\nexport type DescribePineconeIndexOptions = {\n\tapiKey?: string;\n\tindexName: string;\n};\n\nexport type EnsurePineconeIndexOptions = {\n\tapiKey?: string;\n\tindexName: string;\n\tdimensions: number;\n\tmetric?: PineconeDistanceMetric;\n\tspec?: PineconeIndexSpec;\n\tdeletionProtection?: 'enabled' | 'disabled';\n\twaitUntilReady?: boolean;\n\twaitTimeoutMs?: number;\n\tpollIntervalMs?: number;\n};\n\nexport type EnsurePineconeIndexResult = {\n\tcreated: boolean;\n\tdescription: IndexModel | undefined;\n};\n\ntype ResolvedPineconeVectorConfig = {\n\tprovider: 'pinecone';\n\tdimensions: number;\n\tdistanceMetric: PineconeDistanceMetric;\n};\n\ntype MetadataValue = string | number | boolean | string[];\n\ntype PineconeFilter = Record<string, unknown>;\n\nconst PKG = ABSOLUTE_PINECONE_RAG_PACKAGE_NAME;\nconst DEFAULT_DIMENSIONS = 1536;\nconst DEFAULT_DISTANCE_METRIC: PineconeDistanceMetric = 'cosine';\nconst PINECONE_UPSERT_BATCH_SIZE = 100;\nconst PINECONE_FETCH_BATCH_SIZE = 1000;\nconst PINECONE_FILTERED_COUNT_TOPK = 10000;\nconst RESERVED_METADATA_KEYS = new Set(['chunkId', 'text', 'title', 'source']);\n\nconst isObjectRecord = (value: unknown): value is Record<string, unknown> =>\n\tBoolean(value) && typeof value === 'object' && !Array.isArray(value);\n\nconst isOperatorRecord = (value: unknown): value is Record<string, unknown> =>\n\tisObjectRecord(value) &&\n\tObject.keys(value).length > 0 &&\n\tObject.keys(value).every((key) => key.startsWith('$'));\n\nconst chunkArray = <T>(input: readonly T[], size: number): T[][] => {\n\tconst out: T[][] = [];\n\tfor (let i = 0; i < input.length; i += size) {\n\t\tout.push(input.slice(i, i + size));\n\t}\n\n\treturn out;\n};\n\nconst resolveVectorConfig = (\n\toptions: Partial<PineconeRAGOptions>\n): ResolvedPineconeVectorConfig => {\n\tconst vector = options?.vector;\n\tif (!vector || vector.provider !== 'pinecone') {\n\t\tthrow new Error(\n\t\t\t`${PKG}: Pinecone RAG requires vector.provider = \"pinecone\"`\n\t\t);\n\t}\n\tconst dimensions = vector.dimensions ?? DEFAULT_DIMENSIONS;\n\tif (!Number.isInteger(dimensions) || dimensions <= 0) {\n\t\tthrow new Error(\n\t\t\t`${PKG}: vector.dimensions must be a positive integer (received ${String(\n\t\t\t\tdimensions\n\t\t\t)})`\n\t\t);\n\t}\n\tconst distanceMetric = vector.distanceMetric ?? DEFAULT_DISTANCE_METRIC;\n\tif (!PINECONE_DISTANCE_METRICS.includes(distanceMetric)) {\n\t\tthrow new Error(\n\t\t\t`${PKG}: unsupported distanceMetric \"${distanceMetric}\". Allowed: ${PINECONE_DISTANCE_METRICS.join(\n\t\t\t\t', '\n\t\t\t)}`\n\t\t);\n\t}\n\n\treturn { provider: 'pinecone', dimensions, distanceMetric };\n};\n\ntype PineconeSDK = typeof import('@pinecone-database/pinecone');\n\nlet pineconeModulePromise: Promise<PineconeSDK> | undefined;\nconst loadPineconeSDK = (): Promise<PineconeSDK> => {\n\tif (!pineconeModulePromise) {\n\t\tpineconeModulePromise = import('@pinecone-database/pinecone').catch(\n\t\t\t(error: unknown) => {\n\t\t\t\tpineconeModulePromise = undefined;\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`${PKG}: failed to load @pinecone-database/pinecone — install it as a dependency. (${\n\t\t\t\t\t\terror instanceof Error ? error.message : String(error)\n\t\t\t\t\t})`\n\t\t\t\t);\n\t\t\t}\n\t\t);\n\t}\n\n\treturn pineconeModulePromise;\n};\n\nconst resolveIndexClientFactory = (\n\toptions: PineconeRAGOptions\n): (() => Promise<PineconeIndexClient>) => {\n\tconst namespace =\n\t\ttypeof options.namespace === 'string' && options.namespace.length > 0\n\t\t\t? options.namespace\n\t\t\t: undefined;\n\n\tlet cached: PineconeIndexClient | undefined;\n\n\tconst applyNamespace = (\n\t\tidx: PineconeIndexClient\n\t): PineconeIndexClient => {\n\t\tif (!namespace) return idx;\n\n\t\treturn idx.namespace(namespace);\n\t};\n\n\tif (options.client) {\n\t\tconst injectedClient = options.client;\n\n\t\treturn async () => {\n\t\t\tif (cached) return cached;\n\t\t\tcached = applyNamespace(injectedClient);\n\n\t\t\treturn cached;\n\t\t};\n\t}\n\n\tconst indexName = options.indexName;\n\tif (typeof indexName !== 'string' || indexName.length === 0) {\n\t\tthrow new Error(\n\t\t\t`${PKG}: indexName is required when client is not provided`\n\t\t);\n\t}\n\tconst apiKey = options.apiKey ?? process.env.PINECONE_API_KEY;\n\tif (!apiKey) {\n\t\tthrow new Error(\n\t\t\t`${PKG}: missing Pinecone apiKey (pass options.apiKey or set PINECONE_API_KEY)`\n\t\t);\n\t}\n\n\treturn async () => {\n\t\tif (cached) return cached;\n\t\tconst { Pinecone } = await loadPineconeSDK();\n\t\tconst pc = new Pinecone({ apiKey });\n\t\tconst baseIndex = options.indexHost\n\t\t\t? pc.index(indexName, options.indexHost)\n\t\t\t: pc.index(indexName);\n\t\tcached = applyNamespace(baseIndex);\n\n\t\treturn cached;\n\t};\n};\n\nconst sanitizeMetadataValue = (value: unknown): MetadataValue | undefined => {\n\tif (value === null || value === undefined) return undefined;\n\tif (typeof value === 'string' || typeof value === 'boolean') return value;\n\tif (typeof value === 'number') {\n\t\treturn Number.isFinite(value) ? value : undefined;\n\t}\n\tif (Array.isArray(value)) {\n\t\tconst strings: string[] = [];\n\t\tfor (const entry of value) {\n\t\t\tif (entry === null || entry === undefined) continue;\n\t\t\tif (typeof entry === 'string') {\n\t\t\t\tstrings.push(entry);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (typeof entry === 'number' && Number.isFinite(entry)) {\n\t\t\t\tstrings.push(String(entry));\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (typeof entry === 'boolean') {\n\t\t\t\tstrings.push(String(entry));\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\n\t\treturn strings;\n\t}\n\tif (typeof value === 'object') {\n\t\ttry {\n\t\t\treturn JSON.stringify(value);\n\t\t} catch {\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\treturn undefined;\n};\n\nconst sanitizeMetadata = (metadata: unknown): RecordMetadata => {\n\tif (!isObjectRecord(metadata)) return {};\n\tconst out: RecordMetadata = {};\n\tfor (const [key, value] of Object.entries(metadata)) {\n\t\tif (RESERVED_METADATA_KEYS.has(key)) continue;\n\t\tconst sanitized = sanitizeMetadataValue(value);\n\t\tif (sanitized === undefined) continue;\n\t\tout[key] = sanitized;\n\t}\n\n\treturn out;\n};\n\nconst translateOperatorFilter = (\n\tfield: string,\n\toperatorRecord: Record<string, unknown>\n): PineconeFilter | undefined => {\n\tconst direct: Record<string, unknown> = {};\n\tconst expanded: PineconeFilter[] = [];\n\tfor (const [op, value] of Object.entries(operatorRecord)) {\n\t\tswitch (op) {\n\t\t\tcase '$eq':\n\t\t\tcase '$ne':\n\t\t\tcase '$gt':\n\t\t\tcase '$gte':\n\t\t\tcase '$lt':\n\t\t\tcase '$lte':\n\t\t\t\tdirect[op] = value;\n\t\t\t\tbreak;\n\t\t\tcase '$in':\n\t\t\t\tif (Array.isArray(value)) direct.$in = value;\n\t\t\t\tbreak;\n\t\t\tcase '$exists':\n\t\t\t\tdirect.$exists = Boolean(value);\n\t\t\t\tbreak;\n\t\t\tcase '$contains':\n\t\t\t\tdirect.$in = [value];\n\t\t\t\tbreak;\n\t\t\tcase '$containsAny':\n\t\t\t\tif (Array.isArray(value)) direct.$in = value;\n\t\t\t\tbreak;\n\t\t\tcase '$containsAll':\n\t\t\t\tif (Array.isArray(value)) {\n\t\t\t\t\tfor (const entry of value) {\n\t\t\t\t\t\texpanded.push({ [field]: { $in: [entry] } });\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthrow new Error(`${PKG}: unsupported filter operator \"${op}\"`);\n\t\t}\n\t}\n\tif (expanded.length === 0) {\n\t\treturn Object.keys(direct).length > 0 ? { [field]: direct } : undefined;\n\t}\n\tif (Object.keys(direct).length === 0) {\n\t\treturn expanded.length === 1 ? expanded[0] : { $and: expanded };\n\t}\n\n\treturn { $and: [{ [field]: direct }, ...expanded] };\n};\n\nconst translateFilter = (filter: unknown): PineconeFilter | undefined => {\n\tif (!isObjectRecord(filter) || Object.keys(filter).length === 0) {\n\t\treturn undefined;\n\t}\n\tconst clauses: PineconeFilter[] = [];\n\tfor (const [key, value] of Object.entries(filter)) {\n\t\tif (key === '$and' || key === '$or') {\n\t\t\tif (!Array.isArray(value)) continue;\n\t\t\tconst subs = value\n\t\t\t\t.map((entry) => translateFilter(entry))\n\t\t\t\t.filter((entry): entry is PineconeFilter => entry !== undefined);\n\t\t\tif (subs.length > 0) clauses.push({ [key]: subs });\n\t\t\tcontinue;\n\t\t}\n\t\tif (key === '$not') {\n\t\t\tthrow new Error(`${PKG}: $not is not supported by Pinecone`);\n\t\t}\n\t\tif (key.includes('.')) {\n\t\t\tthrow new Error(\n\t\t\t\t`${PKG}: nested key paths (\"${key}\") are not supported by Pinecone (metadata is flat)`\n\t\t\t);\n\t\t}\n\t\tif (isOperatorRecord(value)) {\n\t\t\tconst translated = translateOperatorFilter(key, value);\n\t\t\tif (translated) clauses.push(translated);\n\t\t\tcontinue;\n\t\t}\n\t\tclauses.push({ [key]: { $eq: value } });\n\t}\n\tif (clauses.length === 0) return undefined;\n\tif (clauses.length === 1) return clauses[0];\n\n\treturn { $and: clauses };\n};\n\nconst scoreForMetric = (\n\trawScore: number | undefined,\n\tdistanceMetric: PineconeDistanceMetric\n): number => {\n\tif (typeof rawScore !== 'number' || !Number.isFinite(rawScore)) return 0;\n\tswitch (distanceMetric) {\n\t\tcase 'euclidean':\n\t\t\treturn 1 / (1 + Math.abs(rawScore));\n\t\tcase 'dotproduct':\n\t\tcase 'cosine':\n\t\tdefault:\n\t\t\treturn rawScore;\n\t}\n};\n\nconst buildPineconeRecord = (\n\tchunk: RAGUpsertInput['chunks'][number],\n\tvalues: number[]\n): PineconeRecord<RecordMetadata> => {\n\tconst metadata: RecordMetadata = {\n\t\t...sanitizeMetadata(chunk.metadata),\n\t\tchunkId: chunk.chunkId,\n\t\ttext: chunk.text\n\t};\n\tif (chunk.title) metadata.title = chunk.title;\n\tif (chunk.source) metadata.source = chunk.source;\n\n\treturn { id: chunk.chunkId, values, metadata };\n};\n\nconst extractQueryResult = (\n\tmatch: ScoredPineconeRecord<RecordMetadata>,\n\tdistanceMetric: PineconeDistanceMetric\n): RAGQueryResult => {\n\tconst meta = isObjectRecord(match.metadata) ? match.metadata : {};\n\tconst userMetadata: Record<string, unknown> = {};\n\tfor (const [key, value] of Object.entries(meta)) {\n\t\tif (RESERVED_METADATA_KEYS.has(key)) continue;\n\t\tuserMetadata[key] = value;\n\t}\n\tconst chunkId =\n\t\ttypeof meta.chunkId === 'string' ? meta.chunkId : String(match.id);\n\tconst chunkText = typeof meta.text === 'string' ? meta.text : '';\n\n\treturn {\n\t\tchunkId,\n\t\tchunkText,\n\t\ttitle: typeof meta.title === 'string' ? meta.title : undefined,\n\t\tsource: typeof meta.source === 'string' ? meta.source : undefined,\n\t\tmetadata:\n\t\t\tObject.keys(userMetadata).length > 0 ? userMetadata : undefined,\n\t\tscore: scoreForMetric(match.score, distanceMetric)\n\t};\n};\n\nexport const createPineconeStore = (\n\toptions: PineconeRAGOptions\n): RAGVectorStore => {\n\tconst vector = resolveVectorConfig(options ?? {});\n\tconst namespace =\n\t\ttypeof options.namespace === 'string' && options.namespace.length > 0\n\t\t\t? options.namespace\n\t\t\t: undefined;\n\tconst getClient = resolveIndexClientFactory(options ?? {});\n\n\tconst embed: RAGVectorStore['embed'] = async (input) => {\n\t\tif (typeof options.embedding === 'function') {\n\t\t\tconst result = await options.embedding(input);\n\n\t\t\treturn normalizeVector(result);\n\t\t}\n\n\t\treturn normalizeVector([\n\t\t\t...createRAGVector(input.text, vector.dimensions)\n\t\t]);\n\t};\n\n\tconst upsert = async (input: RAGUpsertInput): Promise<void> => {\n\t\tif (!input?.chunks || input.chunks.length === 0) return;\n\t\tconst client = await getClient();\n\t\tconst records = await Promise.all(\n\t\t\tinput.chunks.map(async (chunk) => {\n\t\t\t\tconst values =\n\t\t\t\t\tArray.isArray(chunk.embedding) && chunk.embedding.length > 0\n\t\t\t\t\t\t? normalizeVector(chunk.embedding)\n\t\t\t\t\t\t: await embed({ text: chunk.text });\n\n\t\t\t\treturn buildPineconeRecord(chunk, values);\n\t\t\t})\n\t\t);\n\t\tfor (const batch of chunkArray(records, PINECONE_UPSERT_BATCH_SIZE)) {\n\t\t\tawait client.upsert(batch);\n\t\t}\n\t};\n\n\tconst query = async (input: RAGQueryInput): Promise<RAGQueryResult[]> => {\n\t\tconst client = await getClient();\n\t\tconst filter = translateFilter(input.filter);\n\t\tconst result: QueryResponse<RecordMetadata> = await client.query({\n\t\t\tvector: normalizeVector(input.queryVector),\n\t\t\ttopK: input.topK,\n\t\t\tincludeMetadata: true,\n\t\t\tincludeValues: false,\n\t\t\t...(filter ? { filter } : {})\n\t\t});\n\t\tconst matches = Array.isArray(result.matches) ? result.matches : [];\n\n\t\treturn matches.map((match) =>\n\t\t\textractQueryResult(match, vector.distanceMetric)\n\t\t);\n\t};\n\n\tconst count = async (\n\t\tinput: { chunkIds?: string[]; filter?: Record<string, unknown> } = {}\n\t): Promise<number> => {\n\t\tconst client = await getClient();\n\t\tif (Array.isArray(input.chunkIds) && input.chunkIds.length > 0) {\n\t\t\tlet total = 0;\n\t\t\tfor (const batch of chunkArray(\n\t\t\t\tinput.chunkIds,\n\t\t\t\tPINECONE_FETCH_BATCH_SIZE\n\t\t\t)) {\n\t\t\t\tconst response = await client.fetch(batch);\n\t\t\t\ttotal += Object.keys(response.records ?? {}).length;\n\t\t\t}\n\n\t\t\treturn total;\n\t\t}\n\t\tif (\n\t\t\tisObjectRecord(input.filter) &&\n\t\t\tObject.keys(input.filter).length > 0\n\t\t) {\n\t\t\tconst filter = translateFilter(input.filter);\n\t\t\tconst probeVector = new Array<number>(vector.dimensions).fill(0);\n\t\t\tconst result: QueryResponse<RecordMetadata> = await client.query({\n\t\t\t\tvector: probeVector,\n\t\t\t\ttopK: PINECONE_FILTERED_COUNT_TOPK,\n\t\t\t\tincludeMetadata: false,\n\t\t\t\tincludeValues: false,\n\t\t\t\t...(filter ? { filter } : {})\n\t\t\t});\n\n\t\t\treturn Array.isArray(result.matches) ? result.matches.length : 0;\n\t\t}\n\t\tconst stats = await client.describeIndexStats();\n\t\tif (namespace) {\n\t\t\treturn stats.namespaces?.[namespace]?.recordCount ?? 0;\n\t\t}\n\n\t\treturn stats.totalRecordCount ?? 0;\n\t};\n\n\tconst remove = async (\n\t\tinput: { chunkIds?: string[]; filter?: Record<string, unknown> } = {}\n\t): Promise<number> => {\n\t\tconst client = await getClient();\n\t\tif (Array.isArray(input.chunkIds) && input.chunkIds.length > 0) {\n\t\t\tfor (const batch of chunkArray(\n\t\t\t\tinput.chunkIds,\n\t\t\t\tPINECONE_FETCH_BATCH_SIZE\n\t\t\t)) {\n\t\t\t\ttry {\n\t\t\t\t\tawait client.deleteMany(batch);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tif (!isPineconeNotFound(error)) throw error;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn input.chunkIds.length;\n\t\t}\n\t\tif (\n\t\t\tisObjectRecord(input.filter) &&\n\t\t\tObject.keys(input.filter).length > 0\n\t\t) {\n\t\t\tconst filter = translateFilter(input.filter);\n\t\t\tif (!filter) return 0;\n\t\t\tconst counted = await count({ filter: input.filter });\n\t\t\ttry {\n\t\t\t\tawait client.deleteMany(filter);\n\t\t\t} catch (error) {\n\t\t\t\tif (!isPineconeNotFound(error)) throw error;\n\t\t\t}\n\n\t\t\treturn counted;\n\t\t}\n\n\t\treturn 0;\n\t};\n\n\tconst clear = async (): Promise<void> => {\n\t\tconst client = await getClient();\n\t\ttry {\n\t\t\tawait client.deleteAll();\n\t\t} catch (error) {\n\t\t\tif (!isPineconeNotFound(error)) throw error;\n\t\t}\n\t};\n\n\treturn {\n\t\tembed,\n\t\tquery,\n\t\tupsert,\n\t\tcount,\n\t\tdelete: remove,\n\t\tclear,\n\t\tgetCapabilities: () => ({\n\t\t\tbackend: 'custom',\n\t\t\tpersistence: 'external',\n\t\t\tnativeVectorSearch: true,\n\t\t\tserverSideFiltering: true,\n\t\t\tstreamingIngestStatus: false\n\t\t})\n\t};\n};\n\nconst DEFAULT_INDEX_READY_TIMEOUT_MS = 120000;\nconst DEFAULT_INDEX_READY_POLL_MS = 1500;\nconst DEFAULT_SERVERLESS_SPEC: PineconeServerlessSpec = {\n\tserverless: { cloud: 'aws', region: 'us-east-1' }\n};\n\nconst readNumberProperty = (\n\tsource: Record<string, unknown>,\n\tkey: string\n): number | undefined => {\n\tconst value = source[key];\n\n\treturn typeof value === 'number' ? value : undefined;\n};\n\nconst isPineconeNotFound = (error: unknown): boolean => {\n\tif (!isObjectRecord(error)) return false;\n\tconst status =\n\t\treadNumberProperty(error, 'status') ??\n\t\treadNumberProperty(error, 'statusCode') ??\n\t\t(isObjectRecord(error.response)\n\t\t\t? readNumberProperty(error.response, 'status')\n\t\t\t: undefined);\n\tif (status === 404) return true;\n\tconst name = typeof error.name === 'string' ? error.name : '';\n\tif (name === 'PineconeNotFoundError') return true;\n\tconst message =\n\t\ttypeof error.message === 'string' ? error.message.toLowerCase() : '';\n\n\treturn (\n\t\tmessage.includes('not found') ||\n\t\tmessage.includes('does not exist') ||\n\t\tmessage.includes('404')\n\t);\n};\n\nconst resolveProvisioningClient = async (\n\toptions: DescribePineconeIndexOptions | EnsurePineconeIndexOptions\n): Promise<InstanceType<PineconeSDK['Pinecone']>> => {\n\tconst apiKey = options.apiKey ?? process.env.PINECONE_API_KEY;\n\tif (!apiKey) {\n\t\tthrow new Error(\n\t\t\t`${PKG}: missing Pinecone apiKey (pass options.apiKey or set PINECONE_API_KEY)`\n\t\t);\n\t}\n\tif (\n\t\ttypeof options.indexName !== 'string' ||\n\t\toptions.indexName.length === 0\n\t) {\n\t\tthrow new Error(`${PKG}: indexName is required`);\n\t}\n\tconst { Pinecone } = await loadPineconeSDK();\n\n\treturn new Pinecone({ apiKey });\n};\n\nconst waitForIndexReady = async (\n\tpc: InstanceType<PineconeSDK['Pinecone']>,\n\tindexName: string,\n\ttimeoutMs: number,\n\tpollIntervalMs: number\n): Promise<IndexModel> => {\n\tconst deadline = Date.now() + timeoutMs;\n\tfor (;;) {\n\t\tconst description = await pc.describeIndex(indexName);\n\t\tconst status = description.status;\n\t\tconst ready =\n\t\t\tstatus.ready === true ||\n\t\t\tstatus.state === 'Ready' ||\n\t\t\tstatus.state === 'ScalingUp';\n\t\tif (ready) return description;\n\t\tif (Date.now() >= deadline) {\n\t\t\tthrow new Error(\n\t\t\t\t`${PKG}: index \"${indexName}\" did not become ready within ${timeoutMs}ms (last state: ${\n\t\t\t\t\tstatus.state ?? 'unknown'\n\t\t\t\t})`\n\t\t\t);\n\t\t}\n\t\tawait new Promise((resolve) => setTimeout(resolve, pollIntervalMs));\n\t}\n};\n\nexport const describePineconeIndex = async (\n\toptions: DescribePineconeIndexOptions\n): Promise<IndexModel | undefined> => {\n\tconst pc = await resolveProvisioningClient(options);\n\ttry {\n\t\treturn await pc.describeIndex(options.indexName);\n\t} catch (error) {\n\t\tif (isPineconeNotFound(error)) return undefined;\n\t\tthrow error;\n\t}\n};\n\nconst toCreateIndexSpec = (\n\tspec: PineconeIndexSpec\n): CreateIndexOptions['spec'] =>\n\t'serverless' in spec\n\t\t? { serverless: spec.serverless }\n\t\t: { pod: spec.pod };\n\nexport const ensurePineconeIndex = async (\n\toptions: EnsurePineconeIndexOptions\n): Promise<EnsurePineconeIndexResult> => {\n\tif (!Number.isInteger(options.dimensions) || options.dimensions <= 0) {\n\t\tthrow new Error(\n\t\t\t`${PKG}: dimensions must be a positive integer (received ${String(\n\t\t\t\toptions.dimensions\n\t\t\t)})`\n\t\t);\n\t}\n\tconst metric = options.metric ?? 'cosine';\n\tif (!PINECONE_DISTANCE_METRICS.includes(metric)) {\n\t\tthrow new Error(\n\t\t\t`${PKG}: unsupported metric \"${metric}\". Allowed: ${PINECONE_DISTANCE_METRICS.join(\n\t\t\t\t', '\n\t\t\t)}`\n\t\t);\n\t}\n\tconst pc = await resolveProvisioningClient(options);\n\tconst timeoutMs = options.waitTimeoutMs ?? DEFAULT_INDEX_READY_TIMEOUT_MS;\n\tconst pollIntervalMs = options.pollIntervalMs ?? DEFAULT_INDEX_READY_POLL_MS;\n\tconst shouldWait = options.waitUntilReady !== false;\n\n\tlet existing: IndexModel | undefined;\n\ttry {\n\t\texisting = await pc.describeIndex(options.indexName);\n\t} catch (error) {\n\t\tif (!isPineconeNotFound(error)) throw error;\n\t}\n\n\tif (existing) {\n\t\tif (existing.dimension !== options.dimensions) {\n\t\t\tthrow new Error(\n\t\t\t\t`${PKG}: index \"${options.indexName}\" already exists with dimension=${String(\n\t\t\t\t\texisting.dimension\n\t\t\t\t)}, but ${options.dimensions} was requested`\n\t\t\t);\n\t\t}\n\t\tif (existing.metric && existing.metric !== metric) {\n\t\t\tthrow new Error(\n\t\t\t\t`${PKG}: index \"${options.indexName}\" already exists with metric=\"${existing.metric}\", but \"${metric}\" was requested`\n\t\t\t);\n\t\t}\n\t\tif (shouldWait && existing.status.ready !== true) {\n\t\t\tconst description = await waitForIndexReady(\n\t\t\t\tpc,\n\t\t\t\toptions.indexName,\n\t\t\t\ttimeoutMs,\n\t\t\t\tpollIntervalMs\n\t\t\t);\n\n\t\t\treturn { created: false, description };\n\t\t}\n\n\t\treturn { created: false, description: existing };\n\t}\n\n\tconst spec = toCreateIndexSpec(options.spec ?? DEFAULT_SERVERLESS_SPEC);\n\tconst createOptions: CreateIndexOptions = {\n\t\tname: options.indexName,\n\t\tdimension: options.dimensions,\n\t\tmetric,\n\t\tspec,\n\t\t...(options.deletionProtection\n\t\t\t? { deletionProtection: options.deletionProtection }\n\t\t\t: {})\n\t};\n\tawait pc.createIndex(createOptions);\n\n\tif (!shouldWait) {\n\t\tlet description: IndexModel | undefined;\n\t\ttry {\n\t\t\tdescription = await pc.describeIndex(options.indexName);\n\t\t} catch (error) {\n\t\t\tif (!isPineconeNotFound(error)) throw error;\n\t\t}\n\n\t\treturn { created: true, description };\n\t}\n\n\tconst description = await waitForIndexReady(\n\t\tpc,\n\t\toptions.indexName,\n\t\ttimeoutMs,\n\t\tpollIntervalMs\n\t);\n\n\treturn { created: true, description };\n};\n\nexport const createPineconeRAGCollection = (\n\toptions: PineconeRAGOptions\n): RAGCollection =>\n\tcreateRAGCollection({\n\t\tstore: createPineconeStore(options)\n\t});\n\nexport const createPineconeRAG = (options: PineconeRAGOptions): PineconeRAG => {\n\tconst store = createPineconeStore(options);\n\tconst collection = createRAGCollection({ store });\n\n\treturn {\n\t\tstore,\n\t\tcollection,\n\t\tgetCapabilities: () => store.getCapabilities?.()\n\t};\n};\n\nexport type {\n\tCreateIndexOptions,\n\tIndex,\n\tIndexModel,\n\tPineconeRecord,\n\tQueryResponse,\n\tRecordMetadata,\n\tScoredPineconeRecord\n} from '@pinecone-database/pinecone';\n"
|
|
6
6
|
],
|
|
7
|
-
"mappings": ";;;;AAQA;AAAA;AAAA;AAAA;AAAA;AAMO,IAAM,qCAAqC;AAE3C,IAAM,4BAA4B;AAAA,EACxC;AAAA,EACA;AAAA,EACA;AACD;AA4HA,IAAM,MAAM;AACZ,IAAM,qBAAqB;AAC3B,IAAM,0BAAkD;AACxD,IAAM,6BAA6B;AACnC,IAAM,4BAA4B;AAClC,IAAM,+BAA+B;AACrC,IAAM,yBAAyB,IAAI,IAAI,CAAC,WAAW,QAAQ,SAAS,QAAQ,CAAC;AAE7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E,SAAS,OAAO,aAAa,SAAS;AAAA,EAChD;AAAA,EAEA,MAAM,OAAO,kBAAkB,QAAQ,QAAQ,uBAAuB;AAAA,EACtE,MAAM,gBAAoC;AAAA,IACzC,MAAM,QAAQ;AAAA,IACd,WAAW,QAAQ;AAAA,IACnB;AAAA,IACA;AAAA,OACI,QAAQ,qBACT,EAAE,oBAAoB,QAAQ,mBAAmB,IACjD,CAAC;AAAA,EACL;AAAA,EACA,MAAM,GAAG,YAAY,aAAa;AAAA,EAElC,IAAI,CAAC,YAAY;AAAA,IAChB,IAAI;AAAA,IACJ,IAAI;AAAA,MACH,eAAc,MAAM,GAAG,cAAc,QAAQ,SAAS;AAAA,MACrD,OAAO,OAAO;AAAA,MACf,IAAI,CAAC,mBAAmB,KAAK;AAAA,QAAG,MAAM;AAAA;AAAA,IAGvC,OAAO,EAAE,SAAS,MAAM,0BAAY;AAAA,EACrC;AAAA,EAEA,MAAM,cAAc,MAAM,kBACzB,IACA,QAAQ,WACR,WACA,cACD;AAAA,EAEA,OAAO,EAAE,SAAS,MAAM,YAAY;AAAA;AAG9B,IAAM,8BAA8B,CAC1C,YAEA,oBAAoB;AAAA,EACnB,OAAO,oBAAoB,OAAO;AACnC,CAAC;AAEK,IAAM,oBAAoB,CAAC,YAA6C;AAAA,EAC9E,MAAM,QAAQ,oBAAoB,OAAO;AAAA,EACzC,MAAM,aAAa,oBAAoB,EAAE,MAAM,CAAC;AAAA,EAEhD,OAAO;AAAA,IACN;AAAA,IACA;AAAA,IACA,iBAAiB,MAAM,MAAM,kBAAkB;AAAA,EAChD;AAAA;",
|
|
8
|
+
"debugId": "DE0CBE49A367C19C64756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@absolutejs/rag-pinecone",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"description": "Pinecone vector-store adapter for @absolutejs/rag",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -23,21 +23,22 @@
|
|
|
23
23
|
"vector"
|
|
24
24
|
],
|
|
25
25
|
"scripts": {
|
|
26
|
-
"build": "rm -rf dist && bun build src/index.ts --outdir dist --sourcemap --target=bun --external @absolutejs/rag --external @pinecone-database/pinecone && tsc --project tsconfig.build.json",
|
|
26
|
+
"build": "rm -rf dist && bun build src/index.ts --outdir dist --sourcemap --target=bun --external @absolutejs/rag --external @absolutejs/rag/adapter-kit --external @absolutejs/ai --external @pinecone-database/pinecone && tsc --project tsconfig.build.json",
|
|
27
27
|
"test": "bun test",
|
|
28
28
|
"typecheck": "tsc --noEmit",
|
|
29
29
|
"format": "prettier --write \"./**/*.{ts,json,md}\"",
|
|
30
30
|
"release": "bun run format && bun run build && bun publish"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@absolutejs/rag": "^0.0.
|
|
33
|
+
"@absolutejs/rag": "^0.0.20"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
|
-
"@pinecone-database/pinecone": ">=
|
|
36
|
+
"@pinecone-database/pinecone": ">=6.0.0 <8.0.0"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@
|
|
40
|
-
"@
|
|
39
|
+
"@absolutejs/ai": "^0.0.9",
|
|
40
|
+
"@pinecone-database/pinecone": ">=6.0.0 <7.0.0",
|
|
41
|
+
"@types/bun": "1.3.9",
|
|
41
42
|
"prettier": "3.5.3",
|
|
42
43
|
"typescript": "5.8.3"
|
|
43
44
|
},
|