@retrivora-ai/rag-engine 2.4.0 → 2.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/handlers/index.js +1 -62
- package/dist/handlers/index.mjs +1 -62
- package/dist/index.js +2 -16
- package/dist/index.mjs +2 -16
- package/dist/server.d.mts +1 -0
- package/dist/server.d.ts +1 -0
- package/dist/server.js +7 -94
- package/dist/server.mjs +7 -94
- package/package.json +1 -1
- package/src/LicensedRetrivora.ts +21 -16
- package/src/browser.tsx +139 -0
- package/src/components/ConfigProvider.tsx +1 -9
- package/src/components/DocumentUpload.tsx +28 -29
- package/src/components/UIDispatcher.tsx +1 -1
- package/src/config/LicenseConfigResolver.ts +11 -11
- package/src/config/serverConfig.ts +24 -24
- package/src/core/ConfigFetcher.ts +2 -2
- package/src/core/LLMRouter.ts +3 -3
- package/src/core/PluginManager.ts +5 -5
- package/src/core/mcp.ts +5 -5
- package/src/handlers/index.ts +9 -9
- package/src/hooks/useRagChat.ts +13 -13
- package/src/llm/LLMFactory.ts +1 -1
- package/src/llm/providers/UniversalLLMAdapter.ts +18 -18
- package/src/providers/graphdb/SimpleGraphProvider.ts +5 -5
- package/src/providers/vectordb/ChromaDBProvider.ts +4 -4
- package/src/providers/vectordb/MultiTablePostgresProvider.ts +32 -32
- package/src/providers/vectordb/QdrantProvider.ts +17 -17
- package/src/telemetry/TelemetryService.ts +12 -12
- package/src/utils/SchemaMapper.ts +1 -1
- package/src/utils/UITransformer.ts +1 -1
package/dist/index.mjs
CHANGED
|
@@ -311,7 +311,7 @@ function projectSettingsToUiConfig(settings) {
|
|
|
311
311
|
// package.json
|
|
312
312
|
var package_default = {
|
|
313
313
|
name: "@retrivora-ai/rag-engine",
|
|
314
|
-
version: "2.4.
|
|
314
|
+
version: "2.4.2",
|
|
315
315
|
description: "Retrivora AI is a plug-and-play AI engine for RAG chat experiences \u2014 generic vector DB + LLM provider, embeddable or standalone.",
|
|
316
316
|
author: "Abhinav Alkuchi",
|
|
317
317
|
license: "UNLICENSED",
|
|
@@ -491,7 +491,6 @@ var ConfigFetcher = class {
|
|
|
491
491
|
for (const baseUrl of controlPlaneUrls) {
|
|
492
492
|
try {
|
|
493
493
|
const url = `${baseUrl}/api/v1/config?projectId=${encodeURIComponent(projectId)}`;
|
|
494
|
-
console.log(`[ConfigFetcher] Fetching config from: ${url}`);
|
|
495
494
|
const res = await fetch(url, {
|
|
496
495
|
method: "GET",
|
|
497
496
|
headers: __spreadValues({
|
|
@@ -499,7 +498,6 @@ var ConfigFetcher = class {
|
|
|
499
498
|
"x-sdk-version": SDK_VERSION
|
|
500
499
|
}, licenseKey ? { "x-license-key": licenseKey } : {})
|
|
501
500
|
});
|
|
502
|
-
console.log(`[ConfigFetcher] Response status: ${res.status}`);
|
|
503
501
|
if (!res.ok) {
|
|
504
502
|
console.warn(`[ConfigFetcher] Error text: ${await res.text()}`);
|
|
505
503
|
}
|
|
@@ -622,15 +620,7 @@ function ConfigProvider({
|
|
|
622
620
|
if (config == null ? void 0 : config.borderRadius) flatUi.borderRadius = config.borderRadius;
|
|
623
621
|
if (config == null ? void 0 : config.visualStyle) flatUi.visualStyle = config.visualStyle;
|
|
624
622
|
return __spreadValues(__spreadValues({}, flatUi), config == null ? void 0 : config.ui);
|
|
625
|
-
}, [
|
|
626
|
-
config == null ? void 0 : config.ui,
|
|
627
|
-
config == null ? void 0 : config.primaryColor,
|
|
628
|
-
config == null ? void 0 : config.secondaryColor,
|
|
629
|
-
config == null ? void 0 : config.accentColor,
|
|
630
|
-
config == null ? void 0 : config.theme,
|
|
631
|
-
config == null ? void 0 : config.borderRadius,
|
|
632
|
-
config == null ? void 0 : config.visualStyle
|
|
633
|
-
]);
|
|
623
|
+
}, [config]);
|
|
634
624
|
const explicitSettings = useMemo(
|
|
635
625
|
() => projectSettingsInput ? normalizeProjectSettings(projectId, projectSettingsInput) : void 0,
|
|
636
626
|
[projectSettingsInput, projectId]
|
|
@@ -765,7 +755,6 @@ function DocumentUpload({ namespace, uploadUrl, retrivoraApiBase, onUploadComple
|
|
|
765
755
|
const apiBase = retrivoraApiBase || configuredApiBase || "/api/retrivora";
|
|
766
756
|
const primaryUrl = uploadUrl || `${apiBase.replace(/\/$/, "")}/upload`;
|
|
767
757
|
const uploadHeaders = __spreadValues(__spreadValues({}, configHeaders || {}), licenseKey ? { "x-license-key": licenseKey } : {});
|
|
768
|
-
console.log(`[Retrivora SDK] \u{1F4E4} Initiating upload request to "${primaryUrl}" (Files: ${idleFiles.length}, Namespace: "${targetNs}", Dimension: ${dimension})`);
|
|
769
758
|
try {
|
|
770
759
|
let response = await fetch(primaryUrl, {
|
|
771
760
|
method: "POST",
|
|
@@ -782,7 +771,6 @@ function DocumentUpload({ namespace, uploadUrl, retrivoraApiBase, onUploadComple
|
|
|
782
771
|
}
|
|
783
772
|
const result = await response.json();
|
|
784
773
|
if (!response.ok) throw new Error(result.error || `Upload failed with HTTP status ${response.status}`);
|
|
785
|
-
console.log(`[Retrivora SDK] \u2705 Upload response success:`, result);
|
|
786
774
|
setFileStates((prev) => prev.map((s) => s.status === "uploading" ? __spreadProps(__spreadValues({}, s), { status: "success" }) : s));
|
|
787
775
|
const updatedSuccessCount = fileStates.length;
|
|
788
776
|
setLastUploadSummary({
|
|
@@ -2566,7 +2554,6 @@ function resolveStructuredRows(config) {
|
|
|
2566
2554
|
}
|
|
2567
2555
|
function UIDispatcher({ rawContent, primaryColor, accentColor, isStreaming, onAddToCart, viewportSize = "large" }) {
|
|
2568
2556
|
var _a;
|
|
2569
|
-
console.log("rawContent", rawContent);
|
|
2570
2557
|
const result = React7.useMemo(() => {
|
|
2571
2558
|
try {
|
|
2572
2559
|
const clean = rawContent.replace(/^```[a-z]*\s*/i, "").replace(/```\s*$/, "").trim();
|
|
@@ -3475,7 +3462,6 @@ function useRagChat(projectId, options = {}) {
|
|
|
3475
3462
|
onReply == null ? void 0 : onReply(finalMsg);
|
|
3476
3463
|
} catch (err) {
|
|
3477
3464
|
if (err instanceof Error && err.name === "AbortError") {
|
|
3478
|
-
console.log("[useRagChat] Streaming stopped by user.");
|
|
3479
3465
|
return;
|
|
3480
3466
|
}
|
|
3481
3467
|
let msg = err instanceof Error ? err.message : "Something went wrong. Please try again.";
|
package/dist/server.d.mts
CHANGED
package/dist/server.d.ts
CHANGED
package/dist/server.js
CHANGED
|
@@ -330,7 +330,7 @@ var init_package = __esm({
|
|
|
330
330
|
"package.json"() {
|
|
331
331
|
package_default = {
|
|
332
332
|
name: "@retrivora-ai/rag-engine",
|
|
333
|
-
version: "2.4.
|
|
333
|
+
version: "2.4.2",
|
|
334
334
|
description: "Retrivora AI is a plug-and-play AI engine for RAG chat experiences \u2014 generic vector DB + LLM provider, embeddable or standalone.",
|
|
335
335
|
author: "Abhinav Alkuchi",
|
|
336
336
|
license: "UNLICENSED",
|
|
@@ -525,7 +525,6 @@ var init_ConfigFetcher = __esm({
|
|
|
525
525
|
for (const baseUrl of controlPlaneUrls) {
|
|
526
526
|
try {
|
|
527
527
|
const url = `${baseUrl}/api/v1/config?projectId=${encodeURIComponent(projectId)}`;
|
|
528
|
-
console.log(`[ConfigFetcher] Fetching config from: ${url}`);
|
|
529
528
|
const res = await fetch(url, {
|
|
530
529
|
method: "GET",
|
|
531
530
|
headers: __spreadValues({
|
|
@@ -533,7 +532,6 @@ var init_ConfigFetcher = __esm({
|
|
|
533
532
|
"x-sdk-version": SDK_VERSION
|
|
534
533
|
}, licenseKey ? { "x-license-key": licenseKey } : {})
|
|
535
534
|
});
|
|
536
|
-
console.log(`[ConfigFetcher] Response status: ${res.status}`);
|
|
537
535
|
if (!res.ok) {
|
|
538
536
|
console.warn(`[ConfigFetcher] Error text: ${await res.text()}`);
|
|
539
537
|
}
|
|
@@ -1252,9 +1250,6 @@ var init_MultiTablePostgresProvider = __esm({
|
|
|
1252
1250
|
if (this.tables.length === 0) {
|
|
1253
1251
|
console.warn('[MultiTablePostgresProvider] No tables with "embedding" columns found in the database.');
|
|
1254
1252
|
} else {
|
|
1255
|
-
console.log(
|
|
1256
|
-
`[MultiTablePostgresProvider] Connected. Searching across ${this.tables.length} table(s): ${this.tables.join(", ")}`
|
|
1257
|
-
);
|
|
1258
1253
|
}
|
|
1259
1254
|
} finally {
|
|
1260
1255
|
client.release();
|
|
@@ -1376,11 +1371,8 @@ var init_MultiTablePostgresProvider = __esm({
|
|
|
1376
1371
|
}
|
|
1377
1372
|
const vectorLiteral = `[${vector.join(",")}]`;
|
|
1378
1373
|
const allResults = [];
|
|
1379
|
-
console.log(`[MultiTablePostgresProvider] --- Starting Multi-Table Search ---`);
|
|
1380
1374
|
const queryText = _filter == null ? void 0 : _filter.queryText;
|
|
1381
1375
|
const entityHints = Array.isArray(_filter == null ? void 0 : _filter.keywords) ? _filter.keywords.map((k) => k.trim().toLowerCase()).filter(Boolean) : [];
|
|
1382
|
-
console.log(`[MultiTablePostgresProvider] queryText: "${queryText}"`);
|
|
1383
|
-
console.log(`[MultiTablePostgresProvider] entityHints: [${entityHints.join(", ")}]`);
|
|
1384
1376
|
const getDynamicKeywordQuery = () => {
|
|
1385
1377
|
if (entityHints.length > 0) {
|
|
1386
1378
|
return entityHints.map((h) => h.replace(/\s+/g, " & ")).join(" & ");
|
|
@@ -1468,9 +1460,7 @@ var init_MultiTablePostgresProvider = __esm({
|
|
|
1468
1460
|
}
|
|
1469
1461
|
const result = await this.pool.query(sqlQuery, params);
|
|
1470
1462
|
if (result.rowCount && result.rowCount > 0) {
|
|
1471
|
-
console.log(` \u2705 Table "${table}": Found ${result.rowCount} potential matches. Top score: ${result.rows[0].hybrid_score.toFixed(4)}`);
|
|
1472
1463
|
} else {
|
|
1473
|
-
console.log(` \u26AA Table "${table}": No relevant matches found.`);
|
|
1474
1464
|
}
|
|
1475
1465
|
const tableResults = [];
|
|
1476
1466
|
for (const row of result.rows) {
|
|
@@ -1508,9 +1498,6 @@ var init_MultiTablePostgresProvider = __esm({
|
|
|
1508
1498
|
var _a4;
|
|
1509
1499
|
return ((_a4 = res.metadata) == null ? void 0 : _a4.source_table) === bestMatchTable;
|
|
1510
1500
|
});
|
|
1511
|
-
console.log(`[MultiTablePostgresProvider] --- Search Complete ---`);
|
|
1512
|
-
console.log(`[MultiTablePostgresProvider] Final top match from "${bestMatchTable}" with score ${finalSorted[0].score.toFixed(4)}`);
|
|
1513
|
-
console.log(`[MultiTablePostgresProvider] Restricting recommendations strictly to table: "${bestMatchTable}"`);
|
|
1514
1501
|
return finalSorted.slice(0, Math.max(topK, 15));
|
|
1515
1502
|
}
|
|
1516
1503
|
async delete(_id, _namespace) {
|
|
@@ -1888,13 +1875,11 @@ var init_QdrantProvider = __esm({
|
|
|
1888
1875
|
if (this.schemaDiscovered) return;
|
|
1889
1876
|
await this.ping();
|
|
1890
1877
|
await this.ensureCollection();
|
|
1891
|
-
console.log(`[QdrantProvider] \u{1F50D} Discovering schema for collection "${this.indexName}"...`);
|
|
1892
1878
|
const discoveredFields = await this.discoverSchema();
|
|
1893
1879
|
const opts = this.config.options;
|
|
1894
1880
|
const configFields = opts.filterableFields || [];
|
|
1895
1881
|
const allFields = [.../* @__PURE__ */ new Set([...discoveredFields, ...configFields])];
|
|
1896
1882
|
if (allFields.length > 0) {
|
|
1897
|
-
console.log(`[QdrantProvider] \u{1F6E0} Ensuring indexes for ${allFields.length} discovered fields...`);
|
|
1898
1883
|
await Promise.all(
|
|
1899
1884
|
allFields.map(async (fieldInfo) => {
|
|
1900
1885
|
const [fieldName, schemaType] = fieldInfo.split(":");
|
|
@@ -1902,7 +1887,6 @@ var init_QdrantProvider = __esm({
|
|
|
1902
1887
|
})
|
|
1903
1888
|
);
|
|
1904
1889
|
} else {
|
|
1905
|
-
console.log(`[QdrantProvider] \u2139\uFE0F No fields discovered for indexing.`);
|
|
1906
1890
|
}
|
|
1907
1891
|
this.schemaDiscovered = true;
|
|
1908
1892
|
}
|
|
@@ -1946,19 +1930,16 @@ var init_QdrantProvider = __esm({
|
|
|
1946
1930
|
var _a3;
|
|
1947
1931
|
try {
|
|
1948
1932
|
await this.http.get(`/collections/${this.indexName}`);
|
|
1949
|
-
console.log(`[QdrantProvider] \u2705 Collection "${this.indexName}" already exists.`);
|
|
1950
1933
|
} catch (err) {
|
|
1951
1934
|
if (import_axios4.default.isAxiosError(err) && ((_a3 = err.response) == null ? void 0 : _a3.status) === 404) {
|
|
1952
1935
|
const opts = this.config.options;
|
|
1953
1936
|
const dimensionsForCreate = opts.dimensions || 1536;
|
|
1954
|
-
console.log(`[QdrantProvider] \u23F3 Creating collection "${this.indexName}" (dimensions: ${dimensionsForCreate})...`);
|
|
1955
1937
|
await this.http.put(`/collections/${this.indexName}`, {
|
|
1956
1938
|
vectors: {
|
|
1957
1939
|
size: dimensionsForCreate,
|
|
1958
1940
|
distance: "Cosine"
|
|
1959
1941
|
}
|
|
1960
1942
|
});
|
|
1961
|
-
console.log(`[QdrantProvider] \u2705 Created collection "${this.indexName}"`);
|
|
1962
1943
|
} else {
|
|
1963
1944
|
throw err;
|
|
1964
1945
|
}
|
|
@@ -1978,7 +1959,6 @@ var init_QdrantProvider = __esm({
|
|
|
1978
1959
|
field_name: fullPath,
|
|
1979
1960
|
field_schema: schema
|
|
1980
1961
|
});
|
|
1981
|
-
console.log(`[QdrantProvider] \u2705 Ensured ${schema} index for "${fullPath}"`);
|
|
1982
1962
|
} catch (err) {
|
|
1983
1963
|
let status;
|
|
1984
1964
|
if (import_axios4.default.isAxiosError(err)) status = (_a3 = err.response) == null ? void 0 : _a3.status;
|
|
@@ -2131,15 +2111,12 @@ var init_ChromaDBProvider = __esm({
|
|
|
2131
2111
|
try {
|
|
2132
2112
|
const { data } = await this.http.get(`/api/v1/collections/${this.indexName}`);
|
|
2133
2113
|
this.collectionId = data.id;
|
|
2134
|
-
console.log(`[ChromaDBProvider] \u2705 Collection "${this.indexName}" found (id: ${this.collectionId})`);
|
|
2135
2114
|
} catch (err) {
|
|
2136
2115
|
if (import_axios5.default.isAxiosError(err) && ((_a3 = err.response) == null ? void 0 : _a3.status) === 404) {
|
|
2137
|
-
console.log(`[ChromaDBProvider] \u23F3 Collection "${this.indexName}" not found. Creating...`);
|
|
2138
2116
|
const { data } = await this.http.post("/api/v1/collections", {
|
|
2139
2117
|
name: this.indexName
|
|
2140
2118
|
});
|
|
2141
2119
|
this.collectionId = data.id;
|
|
2142
|
-
console.log(`[ChromaDBProvider] \u2705 Created collection "${this.indexName}" (id: ${this.collectionId})`);
|
|
2143
2120
|
} else {
|
|
2144
2121
|
throw err;
|
|
2145
2122
|
}
|
|
@@ -2625,7 +2602,6 @@ var init_SimpleGraphProvider = __esm({
|
|
|
2625
2602
|
this.edges = [];
|
|
2626
2603
|
}
|
|
2627
2604
|
async initialize() {
|
|
2628
|
-
console.log("[SimpleGraphProvider] Initialised in-memory graph store.");
|
|
2629
2605
|
}
|
|
2630
2606
|
async addNodes(nodes) {
|
|
2631
2607
|
for (const node of nodes) {
|
|
@@ -3110,13 +3086,6 @@ var UI_BORDER_RADIUS_OPTIONS = ["none", "sm", "md", "lg", "xl", "full"];
|
|
|
3110
3086
|
var _runtimeConfig = null;
|
|
3111
3087
|
function injectRuntimeConfig(config) {
|
|
3112
3088
|
_runtimeConfig = config;
|
|
3113
|
-
console.log("[serverConfig] \u2705 Runtime tier config injected:", {
|
|
3114
|
-
tier: config.tier,
|
|
3115
|
-
llmModel: config.llmModel,
|
|
3116
|
-
embeddingModel: config.embeddingModel,
|
|
3117
|
-
llmBaseUrl: config.llmBaseUrl,
|
|
3118
|
-
hasLitellmKey: !!config.litellmApiKey
|
|
3119
|
-
});
|
|
3120
3089
|
}
|
|
3121
3090
|
function getRuntimeConfig() {
|
|
3122
3091
|
return _runtimeConfig;
|
|
@@ -3249,26 +3218,12 @@ function getEnvConfig(env = process.env, base) {
|
|
|
3249
3218
|
const llmModel = (_Ca = (_Ba = (_Aa = readString(env, "LLM_MODEL")) != null ? _Aa : (_za = base == null ? void 0 : base.llm) == null ? void 0 : _za.model) != null ? _Ba : rt == null ? void 0 : rt.llmModel) != null ? _Ca : tierBasedLLMModel;
|
|
3250
3219
|
const llmApiKey = (_Ga = (_Fa = (_Da = readString(env, "LITELLM_MASTER_KEY")) != null ? _Da : rt == null ? void 0 : rt.litellmApiKey) != null ? _Fa : (_Ea = base == null ? void 0 : base.llm) == null ? void 0 : _Ea.apiKey) != null ? _Ga : licenseKey;
|
|
3251
3220
|
const llmProfile = (_Ka = (_Ja = readString(env, "LLM_UNIVERSAL_PROFILE")) != null ? _Ja : (_Ia = (_Ha = base == null ? void 0 : base.llm) == null ? void 0 : _Ha.options) == null ? void 0 : _Ia.profile) != null ? _Ka : "litellm";
|
|
3252
|
-
console.log("[serverConfig] \u{1F527} LLM Configuration:", {
|
|
3253
|
-
baseUrl: llmBaseUrl,
|
|
3254
|
-
model: llmModel,
|
|
3255
|
-
provider: llmProvider,
|
|
3256
|
-
hasApiKey: !!llmApiKey,
|
|
3257
|
-
source: (rt == null ? void 0 : rt.llmModel) ? "runtime-injected" : "env/fallback"
|
|
3258
|
-
});
|
|
3259
3221
|
const defaultEmbeddingProvider = "universal_rest";
|
|
3260
3222
|
const embeddingProvider = (_Na = (_Ma = readEnum(env, "EMBEDDING_PROVIDER", defaultEmbeddingProvider, EMBEDDING_PROVIDERS)) != null ? _Ma : (_La = base == null ? void 0 : base.embedding) == null ? void 0 : _La.provider) != null ? _Na : defaultEmbeddingProvider;
|
|
3261
3223
|
const embeddingBaseUrl = (_Ua = (_Ta = (_Sa = (_Ra = (_Pa = (_Oa = readString(env, "LITELLM_BASE_URL")) != null ? _Oa : readString(env, "EMBEDDING_BASE_URL")) != null ? _Pa : readString(env, "LLM_BASE_URL")) != null ? _Ra : (_Qa = base == null ? void 0 : base.embedding) == null ? void 0 : _Qa.baseUrl) != null ? _Sa : rt == null ? void 0 : rt.embeddingBaseUrl) != null ? _Ta : rt == null ? void 0 : rt.llmBaseUrl) != null ? _Ua : defaultGatewayUrl;
|
|
3262
3224
|
const embeddingModel = (_Ya = (_Xa = (_Wa = readString(env, "EMBEDDING_MODEL")) != null ? _Wa : (_Va = base == null ? void 0 : base.embedding) == null ? void 0 : _Va.model) != null ? _Xa : rt == null ? void 0 : rt.embeddingModel) != null ? _Ya : tierBasedEmbeddingModel;
|
|
3263
3225
|
const embeddingApiKey = (_ab = (_$a = (_Za = readString(env, "LITELLM_MASTER_KEY")) != null ? _Za : rt == null ? void 0 : rt.litellmApiKey) != null ? _$a : (__a = base == null ? void 0 : base.embedding) == null ? void 0 : __a.apiKey) != null ? _ab : licenseKey;
|
|
3264
3226
|
const embeddingProfile = (_eb = (_db = readString(env, "EMBEDDING_UNIVERSAL_PROFILE")) != null ? _db : (_cb = (_bb = base == null ? void 0 : base.embedding) == null ? void 0 : _bb.options) == null ? void 0 : _cb.profile) != null ? _eb : "litellm";
|
|
3265
|
-
console.log("[serverConfig] \u{1F527} Embedding Configuration:", {
|
|
3266
|
-
baseUrl: embeddingBaseUrl,
|
|
3267
|
-
model: embeddingModel,
|
|
3268
|
-
provider: embeddingProvider,
|
|
3269
|
-
hasApiKey: !!embeddingApiKey,
|
|
3270
|
-
source: (rt == null ? void 0 : rt.embeddingModel) ? "runtime-injected" : "env/fallback"
|
|
3271
|
-
});
|
|
3272
3227
|
return __spreadProps(__spreadValues({
|
|
3273
3228
|
projectId,
|
|
3274
3229
|
licenseKey,
|
|
@@ -4690,12 +4645,6 @@ var UniversalLLMAdapter = class {
|
|
|
4690
4645
|
this.resolvedHeaders = __spreadValues(__spreadValues({
|
|
4691
4646
|
"Content-Type": "application/json"
|
|
4692
4647
|
}, config.apiKey ? { Authorization: `Bearer ${config.apiKey}` } : {}), this.opts.headers || {});
|
|
4693
|
-
console.log("[UniversalLLMAdapter] Initialized with:", {
|
|
4694
|
-
model: this.model,
|
|
4695
|
-
baseUrl: this.baseUrl,
|
|
4696
|
-
hasApiKey: !!this.apiKey,
|
|
4697
|
-
apiKeyPrefix: this.apiKey ? `${this.apiKey.slice(0, 12)}...` : void 0
|
|
4698
|
-
});
|
|
4699
4648
|
this.http = import_axios2.default.create({
|
|
4700
4649
|
baseURL: this.baseUrl,
|
|
4701
4650
|
headers: this.resolvedHeaders,
|
|
@@ -4912,15 +4861,10 @@ ${context != null ? context : "None"}` },
|
|
|
4912
4861
|
const path2 = (_a3 = this.opts.embedPath) != null ? _a3 : "/embeddings";
|
|
4913
4862
|
const payload = this.opts.embedPayloadTemplate ? buildPayload(this.opts.embedPayloadTemplate, { input: text, model: this.model }) : { input: text, model: this.model };
|
|
4914
4863
|
try {
|
|
4915
|
-
console.log(`[UniversalLLMAdapter] Posting to embedding endpoint: ${this.baseUrl}${path2}`, {
|
|
4916
|
-
model: this.model,
|
|
4917
|
-
inputLength: typeof text === "string" ? text.length : "unknown"
|
|
4918
|
-
});
|
|
4919
4864
|
const { data } = await this.http.post(path2, payload);
|
|
4920
4865
|
const extractPath = (_b = this.opts.embedExtractPath) != null ? _b : "data[0].embedding";
|
|
4921
4866
|
const vector = resolvePath(data, extractPath);
|
|
4922
4867
|
if (Array.isArray(vector)) {
|
|
4923
|
-
console.log(`[UniversalLLMAdapter] Embedding HTTP request successful. Vector size: ${vector.length}`);
|
|
4924
4868
|
return vector;
|
|
4925
4869
|
}
|
|
4926
4870
|
console.warn(
|
|
@@ -4946,12 +4890,10 @@ ${context != null ? context : "None"}` },
|
|
|
4946
4890
|
}
|
|
4947
4891
|
}
|
|
4948
4892
|
try {
|
|
4949
|
-
console.log(`[UniversalLLMAdapter] Retrying embedding request to: ${this.baseUrl}${path2}`);
|
|
4950
4893
|
const { data } = await this.http.post(path2, payload);
|
|
4951
4894
|
const extractPath = (_f = this.opts.embedExtractPath) != null ? _f : "data[0].embedding";
|
|
4952
4895
|
const vector = resolvePath(data, extractPath);
|
|
4953
4896
|
if (Array.isArray(vector)) {
|
|
4954
|
-
console.log(`[UniversalLLMAdapter] Retry embedding HTTP request successful. Vector size: ${vector.length}`);
|
|
4955
4897
|
return vector;
|
|
4956
4898
|
}
|
|
4957
4899
|
console.error(
|
|
@@ -5015,7 +4957,6 @@ var LLMFactory = class _LLMFactory {
|
|
|
5015
4957
|
*/
|
|
5016
4958
|
static register(name, factory) {
|
|
5017
4959
|
customProviders.set(name.toLowerCase(), factory);
|
|
5018
|
-
console.log(`[LLMFactory] Registered custom provider: "${name}"`);
|
|
5019
4960
|
}
|
|
5020
4961
|
/**
|
|
5021
4962
|
* Unregister a previously registered custom provider.
|
|
@@ -5795,7 +5736,6 @@ var MCPClient = class {
|
|
|
5795
5736
|
});
|
|
5796
5737
|
await this.sendNotification("notifications/initialized");
|
|
5797
5738
|
this.initialized = true;
|
|
5798
|
-
console.log(`[MCPClient] Connected and initialized server "${this.config.name}" successfully.`);
|
|
5799
5739
|
} catch (err) {
|
|
5800
5740
|
this.disconnect();
|
|
5801
5741
|
throw new Error(`[MCPClient] Failed to initialize server "${this.config.name}": ${err.message}`);
|
|
@@ -5821,7 +5761,6 @@ var MCPClient = class {
|
|
|
5821
5761
|
console.warn(`[MCPClient] [stderr] [${this.config.name}]:`, data.toString("utf-8"));
|
|
5822
5762
|
});
|
|
5823
5763
|
this.childProcess.on("close", (code) => {
|
|
5824
|
-
console.log(`[MCPClient] Connection closed for "${this.config.name}" with exit code: ${code}`);
|
|
5825
5764
|
this.disconnect();
|
|
5826
5765
|
});
|
|
5827
5766
|
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
@@ -6956,13 +6895,11 @@ var LLMRouter = class {
|
|
|
6956
6895
|
const providerFastDefault = (_a3 = FAST_MODEL_DEFAULTS[this.config.llm.provider]) != null ? _a3 : "";
|
|
6957
6896
|
const fastModelName = envFastModel || providerFastDefault;
|
|
6958
6897
|
if (fastModelName && fastModelName !== this.config.llm.model) {
|
|
6959
|
-
console.log(`[LLMRouter] Fast role \u2192 provider="${this.config.llm.provider}" model="${fastModelName}"`);
|
|
6960
6898
|
const fastConfig = __spreadProps(__spreadValues({}, this.config.llm), {
|
|
6961
6899
|
model: fastModelName
|
|
6962
6900
|
});
|
|
6963
6901
|
this.models.set("fast", LLMFactory.create(fastConfig, this.config.embedding));
|
|
6964
6902
|
} else {
|
|
6965
|
-
console.log(`[LLMRouter] Fast role \u2192 reusing default model (no lightweight alternative configured).`);
|
|
6966
6903
|
this.models.set("fast", defaultModel);
|
|
6967
6904
|
}
|
|
6968
6905
|
this.models.set("powerful", defaultModel);
|
|
@@ -8958,7 +8895,6 @@ var SchemaMapper = class {
|
|
|
8958
8895
|
}
|
|
8959
8896
|
static async _doTrain(llm, cacheKey, keys) {
|
|
8960
8897
|
var _a3, _b, _c, _d, _e, _f, _g2, _h, _i, _j, _k;
|
|
8961
|
-
console.log(`[SchemaMapper] \u{1F9E0} Training on new schema keys: ${keys.join(", ")}`);
|
|
8962
8898
|
const propertyList = Object.entries(this.TARGET_PROPERTIES).map(([prop, desc]) => `- ${prop} (${desc})`).join("\n");
|
|
8963
8899
|
const messages = [
|
|
8964
8900
|
{ role: "system", content: "You are a database schema expert. Respond ONLY with valid JSON." },
|
|
@@ -11921,7 +11857,6 @@ function createStreamHandler(configOrPlugin, options) {
|
|
|
11921
11857
|
},
|
|
11922
11858
|
cancel(reason) {
|
|
11923
11859
|
isActive = false;
|
|
11924
|
-
console.log("[createStreamHandler] Stream connection closed by client:", reason);
|
|
11925
11860
|
}
|
|
11926
11861
|
});
|
|
11927
11862
|
return new Response(stream, { headers: __spreadProps(__spreadValues({}, SSE_HEADERS), { "x-message-id": assistantMsgId, "x-user-message-id": userMsgId }) });
|
|
@@ -12012,7 +11947,6 @@ function createLicenseHandler(configOrPlugin, options) {
|
|
|
12012
11947
|
const rawKey = req.headers.get("x-license-key") || (body == null ? void 0 : body.licenseKey) || ((_a3 = req.headers.get("authorization")) == null ? void 0 : _a3.replace(/^Bearer\s+/i, "")) || config.licenseKey || process.env.NEXT_PUBLIC_RETRIVORA_LICENSE_KEY || process.env.RETRIVORA_LICENSE_KEY || "";
|
|
12013
11948
|
const licenseKey = (rawKey || "").trim().replace(/^["']|["']$/g, "").trim();
|
|
12014
11949
|
const projectId = (body == null ? void 0 : body.projectId) || config.projectId || "";
|
|
12015
|
-
console.log(`[DEBUG] createLicenseHandler: projectId="${projectId}", body.projectId="${body == null ? void 0 : body.projectId}", config.projectId="${config.projectId}"`);
|
|
12016
11950
|
const payload = await LicenseVerifier.verifyAsync(licenseKey, projectId);
|
|
12017
11951
|
return import_server.NextResponse.json({
|
|
12018
11952
|
valid: true,
|
|
@@ -12043,7 +11977,6 @@ function createUploadHandler(configOrPlugin, options) {
|
|
|
12043
11977
|
const plugin = getOrCreatePlugin(configOrPlugin);
|
|
12044
11978
|
const onAuthorize = options == null ? void 0 : options.onAuthorize;
|
|
12045
11979
|
return async function POST(req, context) {
|
|
12046
|
-
console.log("Upload handler invoked");
|
|
12047
11980
|
const authResult = await checkAuth(req, onAuthorize);
|
|
12048
11981
|
if (authResult) return authResult;
|
|
12049
11982
|
const config = plugin.getConfig();
|
|
@@ -12052,7 +11985,6 @@ function createUploadHandler(configOrPlugin, options) {
|
|
|
12052
11985
|
try {
|
|
12053
11986
|
const formData = await req.formData();
|
|
12054
11987
|
const files = formData.getAll("files");
|
|
12055
|
-
console.log("Files received for upload:", files.map((f) => f.name));
|
|
12056
11988
|
const namespace = formData.get("namespace") || void 0;
|
|
12057
11989
|
const dimensionRaw = formData.get("dimension");
|
|
12058
11990
|
const dimension = dimensionRaw ? parseInt(dimensionRaw, 10) : void 0;
|
|
@@ -12623,19 +12555,11 @@ var LicenseConfigResolver = class {
|
|
|
12623
12555
|
const cacheKey = `${licenseKey}:${projectId}`;
|
|
12624
12556
|
const cached = this.configCache.get(cacheKey);
|
|
12625
12557
|
if (cached && Date.now() - cached.timestamp < this.CACHE_TTL_MS) {
|
|
12626
|
-
console.log("[LicenseConfigResolver] Using cached config for", projectId);
|
|
12627
12558
|
return this.buildConfigs(cached.config, cached.credentials, licenseKey, projectId);
|
|
12628
12559
|
}
|
|
12629
|
-
console.log("[LicenseConfigResolver] Fetching tier config from Retrivora...");
|
|
12630
12560
|
const tierConfig = await this.fetchTierConfig(licenseKey, projectId);
|
|
12631
|
-
console.log("[LicenseConfigResolver] Fetching provider credentials from Retrivora...");
|
|
12632
12561
|
const credentials = await this.fetchProviderCredentials(licenseKey, projectId);
|
|
12633
12562
|
this.configCache.set(cacheKey, { config: tierConfig, credentials, timestamp: Date.now() });
|
|
12634
|
-
console.log("[LicenseConfigResolver] \u2705 Successfully resolved config from Retrivora:", {
|
|
12635
|
-
tier: tierConfig.tier,
|
|
12636
|
-
llmModel: tierConfig.llmModel,
|
|
12637
|
-
embeddingModel: tierConfig.embeddingModel
|
|
12638
|
-
});
|
|
12639
12563
|
return this.buildConfigs(tierConfig, credentials, licenseKey, projectId);
|
|
12640
12564
|
}
|
|
12641
12565
|
/**
|
|
@@ -12661,7 +12585,6 @@ var LicenseConfigResolver = class {
|
|
|
12661
12585
|
`[LicenseConfigResolver] Config API returned error: ${response.data.error || response.data.message}`
|
|
12662
12586
|
);
|
|
12663
12587
|
}
|
|
12664
|
-
console.log(`[LicenseConfigResolver] Resolved tier: ${response.data.config.tier}`);
|
|
12665
12588
|
return response.data.config;
|
|
12666
12589
|
} catch (err) {
|
|
12667
12590
|
console.error("[LicenseConfigResolver] Failed to fetch config:", err.message);
|
|
@@ -12693,7 +12616,6 @@ var LicenseConfigResolver = class {
|
|
|
12693
12616
|
`[LicenseConfigResolver] Credentials API returned error: ${response.data.error || response.data.message}`
|
|
12694
12617
|
);
|
|
12695
12618
|
}
|
|
12696
|
-
console.log(`[LicenseConfigResolver] Retrieved provider credentials for project: ${projectId}`);
|
|
12697
12619
|
return response.data.credentials;
|
|
12698
12620
|
} catch (err) {
|
|
12699
12621
|
console.error("[LicenseConfigResolver] Failed to fetch credentials:", err.message);
|
|
@@ -12770,7 +12692,6 @@ var LicenseConfigResolver = class {
|
|
|
12770
12692
|
*/
|
|
12771
12693
|
static clearCache() {
|
|
12772
12694
|
this.configCache.clear();
|
|
12773
|
-
console.log("[LicenseConfigResolver] Configuration cache cleared");
|
|
12774
12695
|
}
|
|
12775
12696
|
/**
|
|
12776
12697
|
* Get cache stats for debugging
|
|
@@ -12917,7 +12838,6 @@ var _TelemetryService = class _TelemetryService {
|
|
|
12917
12838
|
};
|
|
12918
12839
|
try {
|
|
12919
12840
|
await this.http.post(_TelemetryService.RETRIVORA_TELEMETRY_URL, payload);
|
|
12920
|
-
console.log(`[TelemetryService] Flushed ${events.length} events to Retrivora`);
|
|
12921
12841
|
} catch (err) {
|
|
12922
12842
|
console.warn("[TelemetryService] Failed to send telemetry to Retrivora:", err.message);
|
|
12923
12843
|
this.eventQueue.unshift(...events);
|
|
@@ -12931,7 +12851,6 @@ var _TelemetryService = class _TelemetryService {
|
|
|
12931
12851
|
"X-Project-ID": this.projectId
|
|
12932
12852
|
}
|
|
12933
12853
|
});
|
|
12934
|
-
console.log(`[TelemetryService] Flushed ${events.length} events to user telemetry`);
|
|
12935
12854
|
} catch (err) {
|
|
12936
12855
|
console.warn("[TelemetryService] Failed to send telemetry to user endpoint:", err.message);
|
|
12937
12856
|
}
|
|
@@ -12985,7 +12904,6 @@ function getTelemetryService() {
|
|
|
12985
12904
|
}
|
|
12986
12905
|
function initializeTelemetryService(projectId, licenseKey, userTelemetryUrl) {
|
|
12987
12906
|
globalTelemetryService = new TelemetryService(projectId, licenseKey, userTelemetryUrl);
|
|
12988
|
-
console.log("[TelemetryService] Initialized for project:", projectId);
|
|
12989
12907
|
return globalTelemetryService;
|
|
12990
12908
|
}
|
|
12991
12909
|
async function shutdownTelemetryService() {
|
|
@@ -13016,13 +12934,12 @@ var LicensedRetrivora = class {
|
|
|
13016
12934
|
*/
|
|
13017
12935
|
async initialize() {
|
|
13018
12936
|
if (this.initialized) {
|
|
13019
|
-
console.log("[LicensedRetrivora] Already initialized");
|
|
13020
12937
|
return;
|
|
13021
12938
|
}
|
|
13022
|
-
console.log("[LicensedRetrivora] Initializing with license key...");
|
|
13023
12939
|
const operationId = this.generateId();
|
|
13024
12940
|
try {
|
|
13025
12941
|
const { llmConfig, embeddingConfig, vectorDbConfig, tierConfig } = await LicenseConfigResolver.resolveFromLicense(this.licenseKey, this.projectId);
|
|
12942
|
+
this.tierConfig = tierConfig;
|
|
13026
12943
|
const telemetry = getTelemetryService();
|
|
13027
12944
|
if (telemetry) {
|
|
13028
12945
|
telemetry.recordEvent({
|
|
@@ -13056,7 +12973,6 @@ var LicensedRetrivora = class {
|
|
|
13056
12973
|
this.pipeline = new Pipeline(this.ragConfig);
|
|
13057
12974
|
await this.pipeline.initialize();
|
|
13058
12975
|
this.initialized = true;
|
|
13059
|
-
console.log(`[LicensedRetrivora] Initialized successfully for tier: ${tierConfig.tier}`);
|
|
13060
12976
|
} catch (error) {
|
|
13061
12977
|
const telemetry = getTelemetryService();
|
|
13062
12978
|
if (telemetry && error instanceof Error) {
|
|
@@ -13078,16 +12994,16 @@ var LicensedRetrivora = class {
|
|
|
13078
12994
|
const telemetry = getTelemetryService();
|
|
13079
12995
|
const startTime = Date.now();
|
|
13080
12996
|
try {
|
|
13081
|
-
console.log(`[LicensedRetrivora] Starting ingestion of ${documents.length} document(s)`);
|
|
13082
12997
|
const results = await this.pipeline.ingest(documents);
|
|
13083
12998
|
const durationMs = Date.now() - startTime;
|
|
13084
12999
|
if (telemetry) {
|
|
13085
13000
|
for (const result of results) {
|
|
13001
|
+
const origDoc = documents.find((d) => String(d.docId) === String(result.docId));
|
|
13002
|
+
const size = origDoc ? new TextEncoder().encode(origDoc.content).length : 0;
|
|
13086
13003
|
telemetry.recordDocumentIngested({
|
|
13087
13004
|
documentId: String(result.docId),
|
|
13088
13005
|
documentName: String(result.docId),
|
|
13089
|
-
documentSize:
|
|
13090
|
-
// TODO: track actual size
|
|
13006
|
+
documentSize: size,
|
|
13091
13007
|
chunksGenerated: result.chunksIngested,
|
|
13092
13008
|
durationMs
|
|
13093
13009
|
});
|
|
@@ -13122,7 +13038,6 @@ var LicensedRetrivora = class {
|
|
|
13122
13038
|
const telemetry = getTelemetryService();
|
|
13123
13039
|
const startTime = Date.now();
|
|
13124
13040
|
try {
|
|
13125
|
-
console.log(`[LicensedRetrivora] Executing query: "${queryText.substring(0, 100)}..."`);
|
|
13126
13041
|
const response = await this.pipeline.runNormalQuery(queryText);
|
|
13127
13042
|
const durationMs = Date.now() - startTime;
|
|
13128
13043
|
if (telemetry) {
|
|
@@ -13151,12 +13066,11 @@ var LicensedRetrivora = class {
|
|
|
13151
13066
|
* Get license tier information (for UI display if needed)
|
|
13152
13067
|
*/
|
|
13153
13068
|
async getTierInfo() {
|
|
13154
|
-
if (!this.ragConfig) {
|
|
13069
|
+
if (!this.ragConfig || !this.tierConfig) {
|
|
13155
13070
|
throw new Error("[LicensedRetrivora] SDK not initialized.");
|
|
13156
13071
|
}
|
|
13157
13072
|
return {
|
|
13158
|
-
tier:
|
|
13159
|
-
// TODO: fetch from tier config
|
|
13073
|
+
tier: this.tierConfig.tier,
|
|
13160
13074
|
model: this.ragConfig.llm.model,
|
|
13161
13075
|
embeddingModel: this.ragConfig.embedding.model
|
|
13162
13076
|
};
|
|
@@ -13167,7 +13081,6 @@ var LicensedRetrivora = class {
|
|
|
13167
13081
|
async shutdown() {
|
|
13168
13082
|
await shutdownTelemetryService();
|
|
13169
13083
|
this.initialized = false;
|
|
13170
|
-
console.log("[LicensedRetrivora] Shutdown complete");
|
|
13171
13084
|
}
|
|
13172
13085
|
/**
|
|
13173
13086
|
* Check if SDK is initialized
|