@elsium-ai/rag 0.2.2 → 0.3.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/embeddings.d.ts +3 -0
- package/dist/embeddings.d.ts.map +1 -1
- package/dist/index.d.ts +6 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +209 -1
- package/dist/stores/index.d.ts +3 -0
- package/dist/stores/index.d.ts.map +1 -0
- package/dist/stores/pgvector.d.ts +8 -0
- package/dist/stores/pgvector.d.ts.map +1 -0
- package/dist/vectorstore.d.ts +3 -0
- package/dist/vectorstore.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/embeddings.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Registry } from '@elsium-ai/core';
|
|
1
2
|
import type { EmbeddingConfig, EmbeddingVector } from './types';
|
|
2
3
|
export interface EmbeddingProvider {
|
|
3
4
|
readonly name: string;
|
|
@@ -7,5 +8,7 @@ export interface EmbeddingProvider {
|
|
|
7
8
|
}
|
|
8
9
|
export declare function createOpenAIEmbeddings(config: EmbeddingConfig): EmbeddingProvider;
|
|
9
10
|
export declare function createMockEmbeddings(dims?: number): EmbeddingProvider;
|
|
11
|
+
export type EmbeddingProviderFactory = (config: EmbeddingConfig) => EmbeddingProvider;
|
|
12
|
+
export declare const embeddingProviderRegistry: Registry<EmbeddingProviderFactory>;
|
|
10
13
|
export declare function getEmbeddingProvider(config: EmbeddingConfig): EmbeddingProvider;
|
|
11
14
|
//# sourceMappingURL=embeddings.d.ts.map
|
package/dist/embeddings.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"embeddings.d.ts","sourceRoot":"","sources":["../src/embeddings.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAE/D,MAAM,WAAW,iBAAiB;IACjC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAE3B,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAAA;IAC7C,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC,CAAA;CACvD;AAID,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,eAAe,GAAG,iBAAiB,CAyEjF;AAID,wBAAgB,oBAAoB,CAAC,IAAI,SAAM,GAAG,iBAAiB,CAgClE;AAID,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,eAAe,GAAG,iBAAiB,
|
|
1
|
+
{"version":3,"file":"embeddings.d.ts","sourceRoot":"","sources":["../src/embeddings.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAE/D,MAAM,WAAW,iBAAiB;IACjC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAE3B,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAAA;IAC7C,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC,CAAA;CACvD;AAID,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,eAAe,GAAG,iBAAiB,CAyEjF;AAID,wBAAgB,oBAAoB,CAAC,IAAI,SAAM,GAAG,iBAAiB,CAgClE;AAID,MAAM,MAAM,wBAAwB,GAAG,CAAC,MAAM,EAAE,eAAe,KAAK,iBAAiB,CAAA;AAErF,eAAO,MAAM,yBAAyB,EAAE,QAAQ,CAAC,wBAAwB,CACX,CAAA;AAI9D,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,eAAe,GAAG,iBAAiB,CAiB/E"}
|
package/dist/index.d.ts
CHANGED
|
@@ -3,10 +3,12 @@ export { textLoader, markdownLoader, htmlLoader, jsonLoader, csvLoader, getLoade
|
|
|
3
3
|
export type { DocumentLoader } from './loaders';
|
|
4
4
|
export { fixedSizeChunker, recursiveChunker, sentenceChunker, getChunker, } from './chunkers';
|
|
5
5
|
export type { Chunker } from './chunkers';
|
|
6
|
-
export { createOpenAIEmbeddings, createMockEmbeddings, getEmbeddingProvider, } from './embeddings';
|
|
7
|
-
export type { EmbeddingProvider } from './embeddings';
|
|
8
|
-
export { createInMemoryStore, cosineSimilarity, mmrRerank, } from './vectorstore';
|
|
9
|
-
export type { VectorStore } from './vectorstore';
|
|
6
|
+
export { createOpenAIEmbeddings, createMockEmbeddings, getEmbeddingProvider, embeddingProviderRegistry, } from './embeddings';
|
|
7
|
+
export type { EmbeddingProvider, EmbeddingProviderFactory } from './embeddings';
|
|
8
|
+
export { createInMemoryStore, cosineSimilarity, mmrRerank, vectorStoreRegistry, } from './vectorstore';
|
|
9
|
+
export type { VectorStore, VectorStoreFactory } from './vectorstore';
|
|
10
10
|
export { rag } from './pipeline';
|
|
11
11
|
export type { RAGPipeline, RAGPipelineConfig, IngestResult } from './pipeline';
|
|
12
|
+
export { createPgVectorStore } from './stores/index';
|
|
13
|
+
export type { PgVectorStoreConfig } from './stores/index';
|
|
12
14
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,YAAY,EACX,QAAQ,EACR,gBAAgB,EAChB,KAAK,EACL,aAAa,EACb,eAAe,EACf,aAAa,EACb,eAAe,EACf,YAAY,EACZ,UAAU,EACV,gBAAgB,EAChB,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,eAAe,GACf,MAAM,SAAS,CAAA;AAGhB,OAAO,EACN,UAAU,EACV,cAAc,EACd,UAAU,EACV,UAAU,EACV,SAAS,EACT,SAAS,GACT,MAAM,WAAW,CAAA;AAClB,YAAY,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAG/C,OAAO,EACN,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,UAAU,GACV,MAAM,YAAY,CAAA;AACnB,YAAY,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAGzC,OAAO,EACN,sBAAsB,EACtB,oBAAoB,EACpB,oBAAoB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,YAAY,EACX,QAAQ,EACR,gBAAgB,EAChB,KAAK,EACL,aAAa,EACb,eAAe,EACf,aAAa,EACb,eAAe,EACf,YAAY,EACZ,UAAU,EACV,gBAAgB,EAChB,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,eAAe,GACf,MAAM,SAAS,CAAA;AAGhB,OAAO,EACN,UAAU,EACV,cAAc,EACd,UAAU,EACV,UAAU,EACV,SAAS,EACT,SAAS,GACT,MAAM,WAAW,CAAA;AAClB,YAAY,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAG/C,OAAO,EACN,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,UAAU,GACV,MAAM,YAAY,CAAA;AACnB,YAAY,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAGzC,OAAO,EACN,sBAAsB,EACtB,oBAAoB,EACpB,oBAAoB,EACpB,yBAAyB,GACzB,MAAM,cAAc,CAAA;AACrB,YAAY,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAA;AAG/E,OAAO,EACN,mBAAmB,EACnB,gBAAgB,EAChB,SAAS,EACT,mBAAmB,GACnB,MAAM,eAAe,CAAA;AACtB,YAAY,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAA;AAGpE,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAA;AAChC,YAAY,EAAE,WAAW,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAG9E,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AACpD,YAAY,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -97,6 +97,89 @@ function generateId(prefix = "els") {
|
|
|
97
97
|
const random = cryptoHex(4);
|
|
98
98
|
return `${prefix}_${timestamp}_${random}`;
|
|
99
99
|
}
|
|
100
|
+
// ../core/src/logger.ts
|
|
101
|
+
var LOG_LEVELS = {
|
|
102
|
+
debug: 0,
|
|
103
|
+
info: 1,
|
|
104
|
+
warn: 2,
|
|
105
|
+
error: 3
|
|
106
|
+
};
|
|
107
|
+
function createLogger(options = {}) {
|
|
108
|
+
const { level = "info", pretty = false, context = {} } = options;
|
|
109
|
+
const minLevel = LOG_LEVELS[level];
|
|
110
|
+
function log(logLevel, message, data) {
|
|
111
|
+
if (LOG_LEVELS[logLevel] < minLevel)
|
|
112
|
+
return;
|
|
113
|
+
const entry = {
|
|
114
|
+
...context,
|
|
115
|
+
level: logLevel,
|
|
116
|
+
message,
|
|
117
|
+
timestamp: new Date().toISOString(),
|
|
118
|
+
...data ? { data } : {}
|
|
119
|
+
};
|
|
120
|
+
const output = pretty ? JSON.stringify(entry, null, 2) : JSON.stringify(entry);
|
|
121
|
+
if (logLevel === "error") {
|
|
122
|
+
console.error(output);
|
|
123
|
+
} else if (logLevel === "warn") {
|
|
124
|
+
console.warn(output);
|
|
125
|
+
} else {
|
|
126
|
+
console.log(output);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return {
|
|
130
|
+
debug: (msg, data) => log("debug", msg, data),
|
|
131
|
+
info: (msg, data) => log("info", msg, data),
|
|
132
|
+
warn: (msg, data) => log("warn", msg, data),
|
|
133
|
+
error: (msg, data) => log("error", msg, data),
|
|
134
|
+
child(childContext) {
|
|
135
|
+
return createLogger({
|
|
136
|
+
level,
|
|
137
|
+
pretty,
|
|
138
|
+
context: { ...context, ...childContext }
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
// ../core/src/schema.ts
|
|
144
|
+
var log = createLogger();
|
|
145
|
+
// ../core/src/registry.ts
|
|
146
|
+
var log2 = createLogger();
|
|
147
|
+
var BLOCKED_KEYS = new Set(["__proto__", "constructor", "prototype"]);
|
|
148
|
+
function createRegistry(label) {
|
|
149
|
+
const entries = new Map;
|
|
150
|
+
return {
|
|
151
|
+
register(name, factory) {
|
|
152
|
+
if (BLOCKED_KEYS.has(name)) {
|
|
153
|
+
log2.warn(`Registry(${label}): rejected blocked key "${name}"`);
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
entries.set(name, factory);
|
|
157
|
+
log2.debug(`Registry(${label}): registered "${name}"`);
|
|
158
|
+
},
|
|
159
|
+
get(name) {
|
|
160
|
+
if (BLOCKED_KEYS.has(name))
|
|
161
|
+
return;
|
|
162
|
+
return entries.get(name);
|
|
163
|
+
},
|
|
164
|
+
list() {
|
|
165
|
+
return Array.from(entries.keys());
|
|
166
|
+
},
|
|
167
|
+
has(name) {
|
|
168
|
+
if (BLOCKED_KEYS.has(name))
|
|
169
|
+
return false;
|
|
170
|
+
return entries.has(name);
|
|
171
|
+
},
|
|
172
|
+
unregister(name) {
|
|
173
|
+
if (BLOCKED_KEYS.has(name))
|
|
174
|
+
return false;
|
|
175
|
+
const deleted = entries.delete(name);
|
|
176
|
+
if (deleted) {
|
|
177
|
+
log2.debug(`Registry(${label}): unregistered "${name}"`);
|
|
178
|
+
}
|
|
179
|
+
return deleted;
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
}
|
|
100
183
|
// src/loaders.ts
|
|
101
184
|
function createDocument(content, metadata) {
|
|
102
185
|
return {
|
|
@@ -549,7 +632,11 @@ function createMockEmbeddings(dims = 128) {
|
|
|
549
632
|
}
|
|
550
633
|
};
|
|
551
634
|
}
|
|
635
|
+
var embeddingProviderRegistry = createRegistry("embeddingProvider");
|
|
552
636
|
function getEmbeddingProvider(config) {
|
|
637
|
+
const registered = embeddingProviderRegistry.get(config.provider);
|
|
638
|
+
if (registered)
|
|
639
|
+
return registered(config);
|
|
553
640
|
switch (config.provider) {
|
|
554
641
|
case "openai":
|
|
555
642
|
return createOpenAIEmbeddings(config);
|
|
@@ -558,12 +645,13 @@ function getEmbeddingProvider(config) {
|
|
|
558
645
|
default:
|
|
559
646
|
throw new ElsiumError({
|
|
560
647
|
code: "CONFIG_ERROR",
|
|
561
|
-
message: `Unknown embedding provider: ${config.provider}`,
|
|
648
|
+
message: `Unknown embedding provider: ${config.provider}. Available: openai, mock${embeddingProviderRegistry.list().length ? `, ${embeddingProviderRegistry.list().join(", ")}` : ""}`,
|
|
562
649
|
retryable: false
|
|
563
650
|
});
|
|
564
651
|
}
|
|
565
652
|
}
|
|
566
653
|
// src/vectorstore.ts
|
|
654
|
+
var vectorStoreRegistry = createRegistry("vectorStore");
|
|
567
655
|
function cosineSimilarity(a, b) {
|
|
568
656
|
if (a.length !== b.length)
|
|
569
657
|
return 0;
|
|
@@ -744,7 +832,125 @@ function rag(config) {
|
|
|
744
832
|
}
|
|
745
833
|
};
|
|
746
834
|
}
|
|
835
|
+
// src/stores/pgvector.ts
|
|
836
|
+
import { createRequire } from "node:module";
|
|
837
|
+
var require2 = createRequire(import.meta.url);
|
|
838
|
+
var log3 = createLogger();
|
|
839
|
+
var BLOCKED_KEYS2 = new Set(["__proto__", "constructor", "prototype"]);
|
|
840
|
+
var TABLE_NAME_PATTERN = /^[a-zA-Z_][a-zA-Z0-9_]*$/;
|
|
841
|
+
function createPgVectorStore(config) {
|
|
842
|
+
const { connectionString, tableName = "vector_chunks", dimensions = 1536 } = config;
|
|
843
|
+
if (BLOCKED_KEYS2.has(tableName)) {
|
|
844
|
+
throw new Error(`Invalid table name: ${tableName}`);
|
|
845
|
+
}
|
|
846
|
+
if (!TABLE_NAME_PATTERN.test(tableName)) {
|
|
847
|
+
throw new Error(`Invalid table name format: ${tableName}`);
|
|
848
|
+
}
|
|
849
|
+
let client = null;
|
|
850
|
+
let initialized = false;
|
|
851
|
+
async function getClient() {
|
|
852
|
+
if (client)
|
|
853
|
+
return client;
|
|
854
|
+
try {
|
|
855
|
+
const pg = require2("pg");
|
|
856
|
+
client = new pg.Client({ connectionString });
|
|
857
|
+
await client.connect();
|
|
858
|
+
if (!initialized) {
|
|
859
|
+
await client.query("CREATE EXTENSION IF NOT EXISTS vector");
|
|
860
|
+
await client.query(`
|
|
861
|
+
CREATE TABLE IF NOT EXISTS ${tableName} (
|
|
862
|
+
id TEXT PRIMARY KEY,
|
|
863
|
+
content TEXT NOT NULL,
|
|
864
|
+
document_id TEXT NOT NULL,
|
|
865
|
+
chunk_index INTEGER NOT NULL,
|
|
866
|
+
metadata JSONB DEFAULT '{}',
|
|
867
|
+
embedding vector(${dimensions})
|
|
868
|
+
)
|
|
869
|
+
`);
|
|
870
|
+
initialized = true;
|
|
871
|
+
}
|
|
872
|
+
return client;
|
|
873
|
+
} catch (err2) {
|
|
874
|
+
log3.error("Failed to initialize PgVector store", {
|
|
875
|
+
error: err2 instanceof Error ? err2.message : String(err2)
|
|
876
|
+
});
|
|
877
|
+
throw new Error("pg is required for PgVector store. Install it as a dependency.");
|
|
878
|
+
}
|
|
879
|
+
}
|
|
880
|
+
return {
|
|
881
|
+
name: "pgvector",
|
|
882
|
+
async upsert(chunks) {
|
|
883
|
+
const pg = await getClient();
|
|
884
|
+
for (const chunk of chunks) {
|
|
885
|
+
if (BLOCKED_KEYS2.has(chunk.id))
|
|
886
|
+
continue;
|
|
887
|
+
const embedding = `[${chunk.embedding.values.join(",")}]`;
|
|
888
|
+
await pg.query(`INSERT INTO ${tableName} (id, content, document_id, chunk_index, metadata, embedding)
|
|
889
|
+
VALUES ($1, $2, $3, $4, $5, $6)
|
|
890
|
+
ON CONFLICT (id) DO UPDATE SET
|
|
891
|
+
content = EXCLUDED.content,
|
|
892
|
+
document_id = EXCLUDED.document_id,
|
|
893
|
+
chunk_index = EXCLUDED.chunk_index,
|
|
894
|
+
metadata = EXCLUDED.metadata,
|
|
895
|
+
embedding = EXCLUDED.embedding`, [
|
|
896
|
+
chunk.id,
|
|
897
|
+
chunk.content,
|
|
898
|
+
chunk.documentId,
|
|
899
|
+
chunk.index,
|
|
900
|
+
JSON.stringify(chunk.metadata),
|
|
901
|
+
embedding
|
|
902
|
+
]);
|
|
903
|
+
}
|
|
904
|
+
},
|
|
905
|
+
async query(embedding, options) {
|
|
906
|
+
const pg = await getClient();
|
|
907
|
+
const topK = options?.topK ?? 5;
|
|
908
|
+
const minScore = options?.minScore ?? 0;
|
|
909
|
+
const embeddingStr = `[${embedding.values.join(",")}]`;
|
|
910
|
+
const result = await pg.query(`SELECT id, content, document_id, chunk_index, metadata,
|
|
911
|
+
1 - (embedding <=> $1::vector) as score
|
|
912
|
+
FROM ${tableName}
|
|
913
|
+
WHERE 1 - (embedding <=> $1::vector) >= $2
|
|
914
|
+
ORDER BY embedding <=> $1::vector
|
|
915
|
+
LIMIT $3`, [embeddingStr, minScore, topK]);
|
|
916
|
+
return result.rows.map((row) => ({
|
|
917
|
+
chunk: {
|
|
918
|
+
id: row.id,
|
|
919
|
+
content: row.content,
|
|
920
|
+
documentId: row.document_id,
|
|
921
|
+
index: row.chunk_index,
|
|
922
|
+
metadata: {
|
|
923
|
+
startChar: 0,
|
|
924
|
+
endChar: 0,
|
|
925
|
+
tokenEstimate: 0,
|
|
926
|
+
...row.metadata ?? {}
|
|
927
|
+
}
|
|
928
|
+
},
|
|
929
|
+
score: row.score,
|
|
930
|
+
distance: 1 - row.score
|
|
931
|
+
}));
|
|
932
|
+
},
|
|
933
|
+
async delete(ids) {
|
|
934
|
+
const pg = await getClient();
|
|
935
|
+
const filtered = ids.filter((id) => !BLOCKED_KEYS2.has(id));
|
|
936
|
+
if (filtered.length === 0)
|
|
937
|
+
return;
|
|
938
|
+
const placeholders = filtered.map((_, i) => `$${i + 1}`).join(", ");
|
|
939
|
+
await pg.query(`DELETE FROM ${tableName} WHERE id IN (${placeholders})`, filtered);
|
|
940
|
+
},
|
|
941
|
+
async clear() {
|
|
942
|
+
const pg = await getClient();
|
|
943
|
+
await pg.query(`DELETE FROM ${tableName}`);
|
|
944
|
+
},
|
|
945
|
+
async count() {
|
|
946
|
+
const pg = await getClient();
|
|
947
|
+
const result = await pg.query(`SELECT COUNT(*)::int as count FROM ${tableName}`);
|
|
948
|
+
return result.rows[0]?.count ?? 0;
|
|
949
|
+
}
|
|
950
|
+
};
|
|
951
|
+
}
|
|
747
952
|
export {
|
|
953
|
+
vectorStoreRegistry,
|
|
748
954
|
textLoader,
|
|
749
955
|
sentenceChunker,
|
|
750
956
|
recursiveChunker,
|
|
@@ -757,7 +963,9 @@ export {
|
|
|
757
963
|
getEmbeddingProvider,
|
|
758
964
|
getChunker,
|
|
759
965
|
fixedSizeChunker,
|
|
966
|
+
embeddingProviderRegistry,
|
|
760
967
|
csvLoader,
|
|
968
|
+
createPgVectorStore,
|
|
761
969
|
createOpenAIEmbeddings,
|
|
762
970
|
createMockEmbeddings,
|
|
763
971
|
createInMemoryStore,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/stores/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA;AAChD,YAAY,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { VectorStore } from '../vectorstore';
|
|
2
|
+
export interface PgVectorStoreConfig {
|
|
3
|
+
connectionString: string;
|
|
4
|
+
tableName?: string;
|
|
5
|
+
dimensions?: number;
|
|
6
|
+
}
|
|
7
|
+
export declare function createPgVectorStore(config: PgVectorStoreConfig): VectorStore;
|
|
8
|
+
//# sourceMappingURL=pgvector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pgvector.d.ts","sourceRoot":"","sources":["../../src/stores/pgvector.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAOjD,MAAM,WAAW,mBAAmB;IACnC,gBAAgB,EAAE,MAAM,CAAA;IACxB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,UAAU,CAAC,EAAE,MAAM,CAAA;CACnB;AAOD,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,mBAAmB,GAAG,WAAW,CAoI5E"}
|
package/dist/vectorstore.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Registry } from '@elsium-ai/core';
|
|
1
2
|
import type { EmbeddedChunk, EmbeddingVector, QueryOptions, RetrievalResult } from './types';
|
|
2
3
|
export interface VectorStore {
|
|
3
4
|
readonly name: string;
|
|
@@ -7,6 +8,8 @@ export interface VectorStore {
|
|
|
7
8
|
clear(): Promise<void>;
|
|
8
9
|
count(): Promise<number>;
|
|
9
10
|
}
|
|
11
|
+
export type VectorStoreFactory = (config: Record<string, unknown>) => VectorStore;
|
|
12
|
+
export declare const vectorStoreRegistry: Registry<VectorStoreFactory>;
|
|
10
13
|
export declare function cosineSimilarity(a: number[], b: number[]): number;
|
|
11
14
|
export declare function createInMemoryStore(options?: {
|
|
12
15
|
maxChunks?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vectorstore.d.ts","sourceRoot":"","sources":["../src/vectorstore.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"vectorstore.d.ts","sourceRoot":"","sources":["../src/vectorstore.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAE5F,MAAM,WAAW,WAAW;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IAErB,MAAM,CAAC,MAAM,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAC9C,KAAK,CAAC,SAAS,EAAE,eAAe,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC,CAAA;IACrF,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IACpC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;IACtB,KAAK,IAAI,OAAO,CAAC,MAAM,CAAC,CAAA;CACxB;AAID,MAAM,MAAM,kBAAkB,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,WAAW,CAAA;AAEjF,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,kBAAkB,CACX,CAAA;AAIlD,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,CAkBjE;AAID,wBAAgB,mBAAmB,CAAC,OAAO,CAAC,EAAE;IAC7C,SAAS,CAAC,EAAE,MAAM,CAAA;CAClB,GAAG,WAAW,CA2Dd;AAmDD,wBAAgB,SAAS,CACxB,cAAc,EAAE,eAAe,EAC/B,OAAO,EAAE,KAAK,CAAC,eAAe,GAAG;IAAE,SAAS,EAAE,eAAe,CAAA;CAAE,CAAC,EAChE,OAAO,CAAC,EAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,GAC1C,eAAe,EAAE,CAqBnB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elsium-ai/rag",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "RAG pipeline, document processing, embeddings, and vector stores for ElsiumAI",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Eric Utrera <ebutrera9103@gmail.com>",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"dev": "bun --watch src/index.ts"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@elsium-ai/core": "^0.
|
|
29
|
+
"@elsium-ai/core": "^0.3.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"typescript": "^5.7.0"
|