@retrivora-ai/rag-engine 2.5.4 → 2.5.6
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/{ILLMProvider-DO5gj-e5.d.mts → ILLMProvider-DwFj0h2u.d.mts} +2 -2
- package/dist/{ILLMProvider-DO5gj-e5.d.ts → ILLMProvider-DwFj0h2u.d.ts} +2 -2
- package/dist/handlers/index.d.mts +2 -2
- package/dist/handlers/index.d.ts +2 -2
- package/dist/handlers/index.js +208 -28
- package/dist/handlers/index.mjs +202 -22
- package/dist/{index-Dex_gQ3P.d.mts → index-Byv5MaYi.d.mts} +16 -1
- package/dist/{index-DkOhRqEc.d.ts → index-Cb0GsT16.d.ts} +1 -1
- package/dist/{index-DE8qPWpI.d.mts → index-D1jN8KSF.d.mts} +1 -1
- package/dist/{index--RhMcXrt.d.ts → index-DP3_OpuB.d.ts} +16 -1
- package/dist/index.css +12 -83
- package/dist/index.d.mts +21 -16
- package/dist/index.d.ts +21 -16
- package/dist/index.js +3797 -3847
- package/dist/index.min.css +1 -1
- package/dist/index.mjs +3845 -3896
- package/dist/server.d.mts +57 -10
- package/dist/server.d.ts +57 -10
- package/dist/server.js +236 -34
- package/dist/server.mjs +229 -28
- package/package.json +1 -1
package/dist/server.mjs
CHANGED
|
@@ -326,7 +326,7 @@ var init_package = __esm({
|
|
|
326
326
|
"package.json"() {
|
|
327
327
|
package_default = {
|
|
328
328
|
name: "@retrivora-ai/rag-engine",
|
|
329
|
-
version: "2.5.
|
|
329
|
+
version: "2.5.6",
|
|
330
330
|
description: "Retrivora AI is a plug-and-play AI engine for RAG chat experiences \u2014 generic vector DB + LLM provider, embeddable or standalone.",
|
|
331
331
|
author: "Abhinav Alkuchi",
|
|
332
332
|
license: "UNLICENSED",
|
|
@@ -519,13 +519,27 @@ var init_ConfigFetcher = __esm({
|
|
|
519
519
|
* PINECONE_API_KEY if available, or vector operations are handled server-side.
|
|
520
520
|
*/
|
|
521
521
|
static async fetchRemoteConfig(projectId, licenseKey) {
|
|
522
|
-
var _a2, _b, _c, _d, _e, _f, _g2, _h, _i, _j, _k;
|
|
523
522
|
const cacheKey = `${projectId}:${licenseKey || ""}`;
|
|
524
523
|
const now = Date.now();
|
|
525
524
|
const cached = this.cache.get(cacheKey);
|
|
526
525
|
if (cached && now - cached.cachedAt < this.TTL_MS) {
|
|
527
526
|
return cached.config;
|
|
528
527
|
}
|
|
528
|
+
const existingInflight = this.inflight.get(cacheKey);
|
|
529
|
+
if (existingInflight) {
|
|
530
|
+
return existingInflight;
|
|
531
|
+
}
|
|
532
|
+
const promise = this._doFetch(projectId, licenseKey, cacheKey, now);
|
|
533
|
+
this.inflight.set(cacheKey, promise);
|
|
534
|
+
try {
|
|
535
|
+
return await promise;
|
|
536
|
+
} finally {
|
|
537
|
+
this.inflight.delete(cacheKey);
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
/** Internal: performs the actual HTTP fetch. Shared by all callers via inflight dedup. */
|
|
541
|
+
static async _doFetch(projectId, licenseKey, cacheKey, now) {
|
|
542
|
+
var _a2, _b, _c, _d, _e, _f, _g2, _h, _i, _j, _k;
|
|
529
543
|
const controlPlaneUrls = [
|
|
530
544
|
process.env.RETRIVORA_CONTROL_PLANE_URL,
|
|
531
545
|
process.env.NEXT_PUBLIC_RETRIVORA_CONTROL_PLANE_URL,
|
|
@@ -638,6 +652,8 @@ var init_ConfigFetcher = __esm({
|
|
|
638
652
|
}
|
|
639
653
|
};
|
|
640
654
|
ConfigFetcher.cache = /* @__PURE__ */ new Map();
|
|
655
|
+
/** In-flight deduplication: concurrent callers for the same key share one network request */
|
|
656
|
+
ConfigFetcher.inflight = /* @__PURE__ */ new Map();
|
|
641
657
|
ConfigFetcher.TTL_MS = 5 * 60 * 1e3;
|
|
642
658
|
}
|
|
643
659
|
});
|
|
@@ -1754,7 +1770,7 @@ var MilvusProvider_exports = {};
|
|
|
1754
1770
|
__export(MilvusProvider_exports, {
|
|
1755
1771
|
MilvusProvider: () => MilvusProvider
|
|
1756
1772
|
});
|
|
1757
|
-
import
|
|
1773
|
+
import axios4 from "axios";
|
|
1758
1774
|
var MilvusProvider;
|
|
1759
1775
|
var init_MilvusProvider = __esm({
|
|
1760
1776
|
"src/providers/vectordb/MilvusProvider.ts"() {
|
|
@@ -1766,7 +1782,7 @@ var init_MilvusProvider = __esm({
|
|
|
1766
1782
|
const opts = config.options;
|
|
1767
1783
|
const baseUrl = opts.baseUrl || opts.uri || (opts.host ? `http://${opts.host}:${opts.port || 19530}` : void 0);
|
|
1768
1784
|
if (!baseUrl) throw new Error("[MilvusProvider] options.baseUrl (or uri / host+port) is required");
|
|
1769
|
-
this.http =
|
|
1785
|
+
this.http = axios4.create({
|
|
1770
1786
|
baseURL: baseUrl,
|
|
1771
1787
|
headers: __spreadValues(__spreadValues({
|
|
1772
1788
|
"Content-Type": "application/json"
|
|
@@ -1867,7 +1883,7 @@ var QdrantProvider_exports = {};
|
|
|
1867
1883
|
__export(QdrantProvider_exports, {
|
|
1868
1884
|
QdrantProvider: () => QdrantProvider
|
|
1869
1885
|
});
|
|
1870
|
-
import
|
|
1886
|
+
import axios5 from "axios";
|
|
1871
1887
|
import crypto from "crypto";
|
|
1872
1888
|
var QdrantProvider;
|
|
1873
1889
|
var init_QdrantProvider = __esm({
|
|
@@ -1884,7 +1900,7 @@ var init_QdrantProvider = __esm({
|
|
|
1884
1900
|
this.contentField = opts.contentField || "content";
|
|
1885
1901
|
this.metadataField = opts.metadataField || "metadata";
|
|
1886
1902
|
this.isFlatPayload = !!opts.flatPayload;
|
|
1887
|
-
this.http =
|
|
1903
|
+
this.http = axios5.create({
|
|
1888
1904
|
baseURL: baseUrl,
|
|
1889
1905
|
timeout: 15e3,
|
|
1890
1906
|
// 15s timeout for vector DB operations
|
|
@@ -1952,7 +1968,7 @@ var init_QdrantProvider = __esm({
|
|
|
1952
1968
|
try {
|
|
1953
1969
|
await this.http.get(`/collections/${this.indexName}`);
|
|
1954
1970
|
} catch (err) {
|
|
1955
|
-
if (
|
|
1971
|
+
if (axios5.isAxiosError(err) && ((_a2 = err.response) == null ? void 0 : _a2.status) === 404) {
|
|
1956
1972
|
const opts = this.config.options;
|
|
1957
1973
|
const dimensionsForCreate = opts.dimensions || 1536;
|
|
1958
1974
|
await this.http.put(`/collections/${this.indexName}`, {
|
|
@@ -1982,7 +1998,7 @@ var init_QdrantProvider = __esm({
|
|
|
1982
1998
|
});
|
|
1983
1999
|
} catch (err) {
|
|
1984
2000
|
let status;
|
|
1985
|
-
if (
|
|
2001
|
+
if (axios5.isAxiosError(err)) status = (_a2 = err.response) == null ? void 0 : _a2.status;
|
|
1986
2002
|
if (status === 409) return;
|
|
1987
2003
|
console.warn(`[QdrantProvider] \u26A0\uFE0F Could not ensure index for "${fullPath}":`, err instanceof Error ? err.message : String(err));
|
|
1988
2004
|
}
|
|
@@ -2106,7 +2122,7 @@ var ChromaDBProvider_exports = {};
|
|
|
2106
2122
|
__export(ChromaDBProvider_exports, {
|
|
2107
2123
|
ChromaDBProvider: () => ChromaDBProvider
|
|
2108
2124
|
});
|
|
2109
|
-
import
|
|
2125
|
+
import axios6 from "axios";
|
|
2110
2126
|
var ChromaDBProvider;
|
|
2111
2127
|
var init_ChromaDBProvider = __esm({
|
|
2112
2128
|
"src/providers/vectordb/ChromaDBProvider.ts"() {
|
|
@@ -2119,7 +2135,7 @@ var init_ChromaDBProvider = __esm({
|
|
|
2119
2135
|
const opts = config.options;
|
|
2120
2136
|
const baseUrl = opts.baseUrl || (opts.host ? `http://${opts.host}:${opts.port || 8e3}` : void 0);
|
|
2121
2137
|
if (!baseUrl) throw new Error("[ChromaDBProvider] options.baseUrl is required");
|
|
2122
|
-
this.http =
|
|
2138
|
+
this.http = axios6.create({
|
|
2123
2139
|
baseURL: baseUrl,
|
|
2124
2140
|
headers: { "Content-Type": "application/json" }
|
|
2125
2141
|
});
|
|
@@ -2133,7 +2149,7 @@ var init_ChromaDBProvider = __esm({
|
|
|
2133
2149
|
const { data } = await this.http.get(`/api/v1/collections/${this.indexName}`);
|
|
2134
2150
|
this.collectionId = data.id;
|
|
2135
2151
|
} catch (err) {
|
|
2136
|
-
if (
|
|
2152
|
+
if (axios6.isAxiosError(err) && ((_a2 = err.response) == null ? void 0 : _a2.status) === 404) {
|
|
2137
2153
|
const { data } = await this.http.post("/api/v1/collections", {
|
|
2138
2154
|
name: this.indexName
|
|
2139
2155
|
});
|
|
@@ -2214,7 +2230,7 @@ var RedisProvider_exports = {};
|
|
|
2214
2230
|
__export(RedisProvider_exports, {
|
|
2215
2231
|
RedisProvider: () => RedisProvider
|
|
2216
2232
|
});
|
|
2217
|
-
import
|
|
2233
|
+
import axios7 from "axios";
|
|
2218
2234
|
var RedisProvider;
|
|
2219
2235
|
var init_RedisProvider = __esm({
|
|
2220
2236
|
"src/providers/vectordb/RedisProvider.ts"() {
|
|
@@ -2226,7 +2242,7 @@ var init_RedisProvider = __esm({
|
|
|
2226
2242
|
const opts = config.options;
|
|
2227
2243
|
const baseUrl = opts.baseUrl || opts.url || (opts.host ? `http://${opts.host}:${opts.port || 6379}` : void 0);
|
|
2228
2244
|
if (!baseUrl) throw new Error("[RedisProvider] options.baseUrl is required");
|
|
2229
|
-
this.http =
|
|
2245
|
+
this.http = axios7.create({
|
|
2230
2246
|
baseURL: baseUrl,
|
|
2231
2247
|
headers: __spreadValues({
|
|
2232
2248
|
"Content-Type": "application/json"
|
|
@@ -2296,7 +2312,7 @@ var WeaviateProvider_exports = {};
|
|
|
2296
2312
|
__export(WeaviateProvider_exports, {
|
|
2297
2313
|
WeaviateProvider: () => WeaviateProvider
|
|
2298
2314
|
});
|
|
2299
|
-
import
|
|
2315
|
+
import axios8 from "axios";
|
|
2300
2316
|
var WeaviateProvider;
|
|
2301
2317
|
var init_WeaviateProvider = __esm({
|
|
2302
2318
|
"src/providers/vectordb/WeaviateProvider.ts"() {
|
|
@@ -2308,7 +2324,7 @@ var init_WeaviateProvider = __esm({
|
|
|
2308
2324
|
const opts = config.options;
|
|
2309
2325
|
const baseUrl = opts.baseUrl || opts.url;
|
|
2310
2326
|
if (!baseUrl) throw new Error("[WeaviateProvider] options.baseUrl is required");
|
|
2311
|
-
this.http =
|
|
2327
|
+
this.http = axios8.create({
|
|
2312
2328
|
baseURL: baseUrl,
|
|
2313
2329
|
headers: __spreadValues(__spreadValues({
|
|
2314
2330
|
"Content-Type": "application/json"
|
|
@@ -2448,7 +2464,7 @@ var UniversalVectorProvider_exports = {};
|
|
|
2448
2464
|
__export(UniversalVectorProvider_exports, {
|
|
2449
2465
|
UniversalVectorProvider: () => UniversalVectorProvider
|
|
2450
2466
|
});
|
|
2451
|
-
import
|
|
2467
|
+
import axios9 from "axios";
|
|
2452
2468
|
var UniversalVectorProvider;
|
|
2453
2469
|
var init_UniversalVectorProvider = __esm({
|
|
2454
2470
|
"src/providers/vectordb/UniversalVectorProvider.ts"() {
|
|
@@ -2465,7 +2481,7 @@ var init_UniversalVectorProvider = __esm({
|
|
|
2465
2481
|
}
|
|
2466
2482
|
async initialize() {
|
|
2467
2483
|
var _a2;
|
|
2468
|
-
this.http =
|
|
2484
|
+
this.http = axios9.create({
|
|
2469
2485
|
baseURL: this.opts.baseUrl,
|
|
2470
2486
|
headers: __spreadValues({
|
|
2471
2487
|
"Content-Type": "application/json"
|
|
@@ -3045,7 +3061,9 @@ var LLM_PROVIDERS = [
|
|
|
3045
3061
|
"qwen",
|
|
3046
3062
|
"rest",
|
|
3047
3063
|
"universal_rest",
|
|
3048
|
-
"custom"
|
|
3064
|
+
"custom",
|
|
3065
|
+
"custom_embedding",
|
|
3066
|
+
"local_embedding"
|
|
3049
3067
|
];
|
|
3050
3068
|
var EMBEDDING_PROVIDERS = [
|
|
3051
3069
|
"openai",
|
|
@@ -3054,7 +3072,9 @@ var EMBEDDING_PROVIDERS = [
|
|
|
3054
3072
|
"qwen",
|
|
3055
3073
|
"rest",
|
|
3056
3074
|
"universal_rest",
|
|
3057
|
-
"custom"
|
|
3075
|
+
"custom",
|
|
3076
|
+
"custom_embedding",
|
|
3077
|
+
"local_embedding"
|
|
3058
3078
|
];
|
|
3059
3079
|
var PROVIDERS_WITH_EMBEDDINGS = [
|
|
3060
3080
|
"openai",
|
|
@@ -3062,7 +3082,10 @@ var PROVIDERS_WITH_EMBEDDINGS = [
|
|
|
3062
3082
|
"gemini",
|
|
3063
3083
|
"qwen",
|
|
3064
3084
|
"rest",
|
|
3065
|
-
"universal_rest"
|
|
3085
|
+
"universal_rest",
|
|
3086
|
+
"custom",
|
|
3087
|
+
"custom_embedding",
|
|
3088
|
+
"local_embedding"
|
|
3066
3089
|
];
|
|
3067
3090
|
|
|
3068
3091
|
// src/config/serverConfig.ts
|
|
@@ -3808,8 +3831,8 @@ var OllamaProvider = class {
|
|
|
3808
3831
|
const baseUrl = config.baseUrl || "http://localhost:11434";
|
|
3809
3832
|
const modelName = config.model;
|
|
3810
3833
|
try {
|
|
3811
|
-
const
|
|
3812
|
-
const { data } = await
|
|
3834
|
+
const axios11 = (await import("axios")).default;
|
|
3835
|
+
const { data } = await axios11.get(`${baseUrl}/api/tags`);
|
|
3813
3836
|
const models = data.models || [];
|
|
3814
3837
|
const hasModel = models.some((m) => m.name === modelName || m.name.startsWith(`${modelName}:`));
|
|
3815
3838
|
return {
|
|
@@ -4926,6 +4949,158 @@ ${context != null ? context : "None"}` },
|
|
|
4926
4949
|
}
|
|
4927
4950
|
};
|
|
4928
4951
|
|
|
4952
|
+
// src/llm/providers/CustomEmbeddingProvider.ts
|
|
4953
|
+
init_templateUtils();
|
|
4954
|
+
import axios3 from "axios";
|
|
4955
|
+
var CustomEmbeddingProvider = class {
|
|
4956
|
+
constructor(config) {
|
|
4957
|
+
var _a2, _b;
|
|
4958
|
+
this.model = config.model || "custom-embedding-model";
|
|
4959
|
+
this.apiKey = config.apiKey;
|
|
4960
|
+
const options = (_a2 = config.options) != null ? _a2 : {};
|
|
4961
|
+
this.opts = {
|
|
4962
|
+
baseUrl: config.baseUrl || options.baseUrl,
|
|
4963
|
+
embedPath: options.embedPath || "/embeddings",
|
|
4964
|
+
pingPath: options.pingPath || "/health",
|
|
4965
|
+
queryPrefix: options.queryPrefix || "",
|
|
4966
|
+
documentPrefix: options.documentPrefix || "",
|
|
4967
|
+
embedPayloadTemplate: options.embedPayloadTemplate,
|
|
4968
|
+
embedExtractPath: options.embedExtractPath,
|
|
4969
|
+
headers: options.headers || {},
|
|
4970
|
+
timeout: options.timeout || 3e4
|
|
4971
|
+
};
|
|
4972
|
+
this.baseUrl = (_b = this.opts.baseUrl) != null ? _b : "";
|
|
4973
|
+
if (!this.baseUrl) {
|
|
4974
|
+
throw new Error("[CustomEmbeddingProvider] baseUrl is required in config or config.options");
|
|
4975
|
+
}
|
|
4976
|
+
const headers = __spreadValues(__spreadValues({
|
|
4977
|
+
"Content-Type": "application/json"
|
|
4978
|
+
}, this.apiKey ? { Authorization: `Bearer ${this.apiKey}` } : {}), this.opts.headers || {});
|
|
4979
|
+
this.http = axios3.create({
|
|
4980
|
+
baseURL: this.baseUrl.replace(/\/$/, ""),
|
|
4981
|
+
headers,
|
|
4982
|
+
timeout: this.opts.timeout
|
|
4983
|
+
});
|
|
4984
|
+
}
|
|
4985
|
+
/**
|
|
4986
|
+
* Dummy chat implementation. CustomEmbeddingProvider is dedicated to embedding generation.
|
|
4987
|
+
*/
|
|
4988
|
+
async chat(_messages, _context, _options) {
|
|
4989
|
+
throw new Error("[CustomEmbeddingProvider] chat() is not supported on a dedicated embedding provider.");
|
|
4990
|
+
}
|
|
4991
|
+
/**
|
|
4992
|
+
* Generate vector embedding for a single string.
|
|
4993
|
+
*/
|
|
4994
|
+
async embed(text, options) {
|
|
4995
|
+
var _a2;
|
|
4996
|
+
const taskType = (_a2 = options == null ? void 0 : options.taskType) != null ? _a2 : "document";
|
|
4997
|
+
const prefix = taskType === "query" ? this.opts.queryPrefix : this.opts.documentPrefix;
|
|
4998
|
+
const formattedText = prefix ? `${prefix}${text}` : text;
|
|
4999
|
+
const modelToUse = (options == null ? void 0 : options.model) || this.model;
|
|
5000
|
+
const path2 = this.opts.embedPath || "/embeddings";
|
|
5001
|
+
let payload;
|
|
5002
|
+
if (this.opts.embedPayloadTemplate) {
|
|
5003
|
+
payload = buildPayload(this.opts.embedPayloadTemplate, {
|
|
5004
|
+
input: formattedText,
|
|
5005
|
+
model: modelToUse
|
|
5006
|
+
});
|
|
5007
|
+
} else {
|
|
5008
|
+
payload = {
|
|
5009
|
+
model: modelToUse,
|
|
5010
|
+
input: formattedText
|
|
5011
|
+
};
|
|
5012
|
+
}
|
|
5013
|
+
try {
|
|
5014
|
+
const { data } = await this.http.post(path2, payload);
|
|
5015
|
+
const vector = this.extractVector(data);
|
|
5016
|
+
if (vector) return vector;
|
|
5017
|
+
throw new Error(`[CustomEmbeddingProvider] Failed to extract embedding vector from response at ${path2}`);
|
|
5018
|
+
} catch (err) {
|
|
5019
|
+
console.error("[CustomEmbeddingProvider] Embedding request failed:", {
|
|
5020
|
+
baseUrl: this.baseUrl,
|
|
5021
|
+
path: path2,
|
|
5022
|
+
model: modelToUse,
|
|
5023
|
+
error: (err == null ? void 0 : err.message) || err
|
|
5024
|
+
});
|
|
5025
|
+
throw err;
|
|
5026
|
+
}
|
|
5027
|
+
}
|
|
5028
|
+
/**
|
|
5029
|
+
* Batch embedding generation for multiple texts.
|
|
5030
|
+
*/
|
|
5031
|
+
async batchEmbed(texts, options) {
|
|
5032
|
+
var _a2;
|
|
5033
|
+
if (!Array.isArray(texts) || texts.length === 0) return [];
|
|
5034
|
+
const taskType = (_a2 = options == null ? void 0 : options.taskType) != null ? _a2 : "document";
|
|
5035
|
+
const prefix = taskType === "query" ? this.opts.queryPrefix : this.opts.documentPrefix;
|
|
5036
|
+
const formattedTexts = prefix ? texts.map((t) => `${prefix}${t}`) : texts;
|
|
5037
|
+
const modelToUse = (options == null ? void 0 : options.model) || this.model;
|
|
5038
|
+
const path2 = this.opts.embedPath || "/embeddings";
|
|
5039
|
+
if (!this.opts.embedPayloadTemplate) {
|
|
5040
|
+
try {
|
|
5041
|
+
const payload = {
|
|
5042
|
+
model: modelToUse,
|
|
5043
|
+
input: formattedTexts
|
|
5044
|
+
};
|
|
5045
|
+
const { data } = await this.http.post(path2, payload);
|
|
5046
|
+
const batchVectors = this.extractBatchVectors(data);
|
|
5047
|
+
if (batchVectors && batchVectors.length === texts.length) {
|
|
5048
|
+
return batchVectors;
|
|
5049
|
+
}
|
|
5050
|
+
} catch (e) {
|
|
5051
|
+
}
|
|
5052
|
+
}
|
|
5053
|
+
return Promise.all(texts.map((text) => this.embed(text, options)));
|
|
5054
|
+
}
|
|
5055
|
+
/**
|
|
5056
|
+
* Ping provider endpoint for health check.
|
|
5057
|
+
*/
|
|
5058
|
+
async ping() {
|
|
5059
|
+
try {
|
|
5060
|
+
const pingPath = this.opts.pingPath || "/health";
|
|
5061
|
+
const res = await this.http.get(pingPath);
|
|
5062
|
+
return res.status >= 200 && res.status < 300;
|
|
5063
|
+
} catch (e) {
|
|
5064
|
+
try {
|
|
5065
|
+
const embedPath = this.opts.embedPath || "/embeddings";
|
|
5066
|
+
await this.http.post(embedPath, { input: "ping", model: this.model });
|
|
5067
|
+
return true;
|
|
5068
|
+
} catch (e2) {
|
|
5069
|
+
return false;
|
|
5070
|
+
}
|
|
5071
|
+
}
|
|
5072
|
+
}
|
|
5073
|
+
extractVector(data) {
|
|
5074
|
+
if (!data) return void 0;
|
|
5075
|
+
if (this.opts.embedExtractPath) {
|
|
5076
|
+
const extracted = resolvePath(data, this.opts.embedExtractPath);
|
|
5077
|
+
if (Array.isArray(extracted) && typeof extracted[0] === "number") {
|
|
5078
|
+
return extracted;
|
|
5079
|
+
}
|
|
5080
|
+
}
|
|
5081
|
+
const directVector = resolvePath(data, "data[0].embedding") || resolvePath(data, "embedding") || resolvePath(data, "embeddings[0]") || resolvePath(data, "data[0].vector") || resolvePath(data, "vector");
|
|
5082
|
+
if (Array.isArray(directVector) && typeof directVector[0] === "number") {
|
|
5083
|
+
return directVector;
|
|
5084
|
+
}
|
|
5085
|
+
if (Array.isArray(data) && typeof data[0] === "number") {
|
|
5086
|
+
return data;
|
|
5087
|
+
}
|
|
5088
|
+
return void 0;
|
|
5089
|
+
}
|
|
5090
|
+
extractBatchVectors(data) {
|
|
5091
|
+
if (!data) return void 0;
|
|
5092
|
+
if (typeof data === "object" && data !== null && Array.isArray(data.data)) {
|
|
5093
|
+
const list = data.data;
|
|
5094
|
+
const vectors = list.map((item) => (item == null ? void 0 : item.embedding) || (item == null ? void 0 : item.vector)).filter((v) => Array.isArray(v));
|
|
5095
|
+
if (vectors.length > 0) return vectors;
|
|
5096
|
+
}
|
|
5097
|
+
if (Array.isArray(data) && Array.isArray(data[0]) && typeof data[0][0] === "number") {
|
|
5098
|
+
return data;
|
|
5099
|
+
}
|
|
5100
|
+
return void 0;
|
|
5101
|
+
}
|
|
5102
|
+
};
|
|
5103
|
+
|
|
4929
5104
|
// src/llm/LLMFactory.ts
|
|
4930
5105
|
var customProviders = /* @__PURE__ */ new Map();
|
|
4931
5106
|
var LLMFactory = class _LLMFactory {
|
|
@@ -4968,6 +5143,8 @@ var LLMFactory = class _LLMFactory {
|
|
|
4968
5143
|
"rest",
|
|
4969
5144
|
"universal_rest",
|
|
4970
5145
|
"custom",
|
|
5146
|
+
"custom_embedding",
|
|
5147
|
+
"local_embedding",
|
|
4971
5148
|
...Array.from(customProviders.keys())
|
|
4972
5149
|
];
|
|
4973
5150
|
}
|
|
@@ -4986,6 +5163,9 @@ var LLMFactory = class _LLMFactory {
|
|
|
4986
5163
|
return new GroqProvider(llmConfig, embeddingConfig);
|
|
4987
5164
|
case "qwen":
|
|
4988
5165
|
return new QwenProvider(llmConfig, embeddingConfig);
|
|
5166
|
+
case "custom_embedding":
|
|
5167
|
+
case "local_embedding":
|
|
5168
|
+
return new CustomEmbeddingProvider(llmConfig);
|
|
4989
5169
|
case "rest":
|
|
4990
5170
|
case "universal_rest":
|
|
4991
5171
|
case "custom":
|
|
@@ -12272,6 +12452,8 @@ var _LicenseValidator = class _LicenseValidator {
|
|
|
12272
12452
|
// 5-minute TTL for successful validation only
|
|
12273
12453
|
constructor() {
|
|
12274
12454
|
this.cache = /* @__PURE__ */ new Map();
|
|
12455
|
+
/** In-flight deduplication: concurrent calls for same key share one network request */
|
|
12456
|
+
this.inflight = /* @__PURE__ */ new Map();
|
|
12275
12457
|
}
|
|
12276
12458
|
/** @returns Singleton instance of the validator (shared cache across all consumers). */
|
|
12277
12459
|
static getInstance() {
|
|
@@ -12352,6 +12534,24 @@ var _LicenseValidator = class _LicenseValidator {
|
|
|
12352
12534
|
this.cache.delete(effectiveLicenseKey);
|
|
12353
12535
|
}
|
|
12354
12536
|
}
|
|
12537
|
+
const inflightPromise = this._doNetworkValidate(
|
|
12538
|
+
effectiveLicenseKey,
|
|
12539
|
+
effectiveProjectId,
|
|
12540
|
+
sdkVersion,
|
|
12541
|
+
sdk,
|
|
12542
|
+
platform,
|
|
12543
|
+
retrivoraApiBase,
|
|
12544
|
+
customHeaders
|
|
12545
|
+
);
|
|
12546
|
+
this.inflight.set(effectiveLicenseKey, inflightPromise);
|
|
12547
|
+
try {
|
|
12548
|
+
return await inflightPromise;
|
|
12549
|
+
} finally {
|
|
12550
|
+
this.inflight.delete(effectiveLicenseKey);
|
|
12551
|
+
}
|
|
12552
|
+
}
|
|
12553
|
+
/** Performs the actual network request. Called once; result shared by in-flight dedup. */
|
|
12554
|
+
async _doNetworkValidate(effectiveLicenseKey, effectiveProjectId, sdkVersion, sdk, platform, retrivoraApiBase, customHeaders) {
|
|
12355
12555
|
const base = retrivoraApiBase || (typeof process !== "undefined" ? process.env.NEXT_PUBLIC_RETRIVORA_API_BASE || process.env.RETRIVORA_API_BASE : "") || "https://www.retrivora.com/api";
|
|
12356
12556
|
const validateUrl = `${base.replace(/\/$/, "")}/v1/license/validate`;
|
|
12357
12557
|
let res = null;
|
|
@@ -12442,7 +12642,7 @@ _LicenseValidator.SUCCESS_CACHE_TTL_MS = 5 * 60 * 1e3;
|
|
|
12442
12642
|
var LicenseValidator = _LicenseValidator;
|
|
12443
12643
|
|
|
12444
12644
|
// src/config/LicenseConfigResolver.ts
|
|
12445
|
-
import
|
|
12645
|
+
import axios10 from "axios";
|
|
12446
12646
|
var LicenseConfigResolver = class {
|
|
12447
12647
|
/**
|
|
12448
12648
|
* Validate and resolve configuration from license key
|
|
@@ -12466,7 +12666,7 @@ var LicenseConfigResolver = class {
|
|
|
12466
12666
|
*/
|
|
12467
12667
|
static async fetchTierConfig(licenseKey, projectId) {
|
|
12468
12668
|
try {
|
|
12469
|
-
const response = await
|
|
12669
|
+
const response = await axios10.post(
|
|
12470
12670
|
this.RETRIVORA_CONFIG_URL,
|
|
12471
12671
|
{ licenseKey, projectId },
|
|
12472
12672
|
{
|
|
@@ -12497,7 +12697,7 @@ var LicenseConfigResolver = class {
|
|
|
12497
12697
|
*/
|
|
12498
12698
|
static async fetchProviderCredentials(licenseKey, projectId) {
|
|
12499
12699
|
try {
|
|
12500
|
-
const response = await
|
|
12700
|
+
const response = await axios10.post(
|
|
12501
12701
|
this.RETRIVORA_CREDENTIALS_URL,
|
|
12502
12702
|
{ licenseKey, projectId },
|
|
12503
12703
|
{
|
|
@@ -12695,12 +12895,12 @@ var _TelemetryService = class _TelemetryService {
|
|
|
12695
12895
|
});
|
|
12696
12896
|
}
|
|
12697
12897
|
/**
|
|
12698
|
-
* Record query execution event
|
|
12898
|
+
* Record query execution event (PII-safe)
|
|
12699
12899
|
*/
|
|
12700
12900
|
recordQueryExecuted(data) {
|
|
12701
12901
|
this.recordEvent({
|
|
12702
12902
|
eventType: "query_executed" /* QUERY_EXECUTED */,
|
|
12703
|
-
|
|
12903
|
+
queryLength: data.queryLength,
|
|
12704
12904
|
resultCount: data.resultCount,
|
|
12705
12905
|
durationMs: data.durationMs,
|
|
12706
12906
|
operationId: data.operationId
|
|
@@ -12946,7 +13146,7 @@ var LicensedRetrivora = class {
|
|
|
12946
13146
|
const durationMs = Date.now() - startTime;
|
|
12947
13147
|
if (telemetry) {
|
|
12948
13148
|
telemetry.recordQueryExecuted({
|
|
12949
|
-
queryText,
|
|
13149
|
+
queryLength: queryText.length,
|
|
12950
13150
|
resultCount: ((_a2 = response.sources) == null ? void 0 : _a2.length) || 0,
|
|
12951
13151
|
durationMs,
|
|
12952
13152
|
operationId
|
|
@@ -13027,6 +13227,7 @@ export {
|
|
|
13027
13227
|
ConfigResolver,
|
|
13028
13228
|
ConfigValidator,
|
|
13029
13229
|
ConfigurationException,
|
|
13230
|
+
CustomEmbeddingProvider,
|
|
13030
13231
|
DocumentChunker,
|
|
13031
13232
|
DocumentParser,
|
|
13032
13233
|
EmbeddingFailedException,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@retrivora-ai/rag-engine",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.6",
|
|
4
4
|
"description": "Retrivora AI is a plug-and-play AI engine for RAG chat experiences — generic vector DB + LLM provider, embeddable or standalone.",
|
|
5
5
|
"author": "Abhinav Alkuchi",
|
|
6
6
|
"license": "UNLICENSED",
|