@retrivora-ai/rag-engine 1.9.8 → 1.9.9
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 +36 -28
- package/dist/{ILLMProvider-B8ROITYK.d.mts → ILLMProvider-DMxLyTdq.d.mts} +2 -2
- package/dist/{ILLMProvider-B8ROITYK.d.ts → ILLMProvider-DMxLyTdq.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 +140 -28
- package/dist/handlers/index.mjs +146 -28
- package/dist/{index-DNvoi-sV.d.ts → index-CfkqZd2Y.d.ts} +1 -1
- package/dist/{index-CrxCy36A.d.mts → index-DXd29KMq.d.mts} +1 -1
- package/dist/{index-BCPKUAVL.d.ts → index-D_bOdJML.d.ts} +1 -1
- package/dist/{index-B8PbEFSY.d.mts → index-xygonxpW.d.mts} +1 -1
- package/dist/index.css +485 -557
- package/dist/index.d.mts +16 -10
- package/dist/index.d.ts +16 -10
- package/dist/index.js +24 -765
- package/dist/index.mjs +20 -779
- package/dist/server.d.mts +8 -5
- package/dist/server.d.ts +8 -5
- package/dist/server.js +141 -28
- package/dist/server.mjs +147 -28
- package/package.json +3 -2
- package/src/app/page.tsx +2 -0
- package/src/components/constants.tsx +224 -0
- package/src/config/RagConfig.ts +2 -2
- package/src/core/ConfigResolver.ts +32 -6
- package/src/core/LicenseVerifier.ts +106 -0
- package/src/core/Pipeline.ts +8 -6
- package/src/core/Retrivora.ts +1 -0
- package/src/index.ts +3 -5
- package/src/components/AmbientBackground.tsx +0 -29
- package/src/components/ArchitectureCard.tsx +0 -53
- package/src/components/ArchitectureCardsSection.tsx +0 -48
- package/src/components/DocViewer.tsx +0 -97
- package/src/components/Documentation.tsx +0 -141
- package/src/components/Hero.tsx +0 -142
- package/src/components/Lifecycle.tsx +0 -77
- package/src/components/Navbar.tsx +0 -55
package/dist/server.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { p as VectorDBConfig, L as LLMConfig, e as EmbeddingConfig, k as RagConfig, n as UniversalRagConfig, o as UpsertDocument, V as VectorMatch, G as GraphDBConfig, r as GraphNode, s as Edge, t as GraphSearchResult, I as ILLMProvider, q as VectorDBProvider, h as LLMProvider, f as EmbeddingProvider, j as RAGConfig, U as UIConfig, C as ChatMessage, c as ChatOptions, E as EmbedOptions } from './ILLMProvider-
|
|
2
|
-
export { d as ChatResponse, g as IngestDocument, l as RetrievalConfig, W as WorkflowConfig } from './ILLMProvider-
|
|
3
|
-
export { A as AuthenticationException, C as Chunk, a as ChunkOptions, b as ConfigurationException, D as DocumentChunker, E as EmbeddingFailedException, g as Pipeline, P as ProviderNotFoundException, R as RateLimitException, c as RetrievalException, d as Retrivora, e as RetrivoraError, f as RetrivoraErrorCode, w as wrapError } from './index-
|
|
4
|
-
import { H as HealthCheckResult, I as IProviderValidator, a as IProviderHealthChecker } from './index-
|
|
5
|
-
export { C as ConfigValidator, V as ValidationError, b as VectorPlugin, c as createChatHandler, d as createFeedbackHandler, e as createHealthHandler, f as createHistoryHandler, g as createIngestHandler, h as createRagHandler, i as createSessionsHandler, j as createStreamHandler, k as createUploadHandler, s as sseErrorFrame, l as sseFrame, m as sseMetaFrame, n as sseTextFrame } from './index-
|
|
1
|
+
import { p as VectorDBConfig, L as LLMConfig, e as EmbeddingConfig, k as RagConfig, n as UniversalRagConfig, o as UpsertDocument, V as VectorMatch, G as GraphDBConfig, r as GraphNode, s as Edge, t as GraphSearchResult, I as ILLMProvider, q as VectorDBProvider, h as LLMProvider, f as EmbeddingProvider, j as RAGConfig, U as UIConfig, C as ChatMessage, c as ChatOptions, E as EmbedOptions } from './ILLMProvider-DMxLyTdq.mjs';
|
|
2
|
+
export { d as ChatResponse, g as IngestDocument, l as RetrievalConfig, W as WorkflowConfig } from './ILLMProvider-DMxLyTdq.mjs';
|
|
3
|
+
export { A as AuthenticationException, C as Chunk, a as ChunkOptions, b as ConfigurationException, D as DocumentChunker, E as EmbeddingFailedException, g as Pipeline, P as ProviderNotFoundException, R as RateLimitException, c as RetrievalException, d as Retrivora, e as RetrivoraError, f as RetrivoraErrorCode, w as wrapError } from './index-xygonxpW.mjs';
|
|
4
|
+
import { H as HealthCheckResult, I as IProviderValidator, a as IProviderHealthChecker } from './index-DXd29KMq.mjs';
|
|
5
|
+
export { C as ConfigValidator, V as ValidationError, b as VectorPlugin, c as createChatHandler, d as createFeedbackHandler, e as createHealthHandler, f as createHistoryHandler, g as createIngestHandler, h as createRagHandler, i as createSessionsHandler, j as createStreamHandler, k as createUploadHandler, s as sseErrorFrame, l as sseFrame, m as sseMetaFrame, n as sseTextFrame } from './index-DXd29KMq.mjs';
|
|
6
6
|
import 'next/server';
|
|
7
7
|
|
|
8
8
|
interface LicensePayload {
|
|
@@ -15,6 +15,8 @@ interface LicensePayload {
|
|
|
15
15
|
* Enables zero-latency local license validation without external network calls.
|
|
16
16
|
*/
|
|
17
17
|
declare class LicenseVerifier {
|
|
18
|
+
private static readonly cache;
|
|
19
|
+
private static readonly CACHE_TTL_MS;
|
|
18
20
|
private static readonly PUBLIC_KEY;
|
|
19
21
|
/**
|
|
20
22
|
* Decodes, verifies signature, and checks metadata of a license key.
|
|
@@ -24,6 +26,7 @@ declare class LicenseVerifier {
|
|
|
24
26
|
* @param publicKeyOverride - Optional override for unit/integration tests.
|
|
25
27
|
*/
|
|
26
28
|
static verify(licenseKey: string | undefined, currentProjectId: string, provider?: string, publicKeyOverride?: string): LicensePayload;
|
|
29
|
+
static verifyIP(licenseKey: string | undefined): Promise<void>;
|
|
27
30
|
}
|
|
28
31
|
|
|
29
32
|
/**
|
package/dist/server.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { p as VectorDBConfig, L as LLMConfig, e as EmbeddingConfig, k as RagConfig, n as UniversalRagConfig, o as UpsertDocument, V as VectorMatch, G as GraphDBConfig, r as GraphNode, s as Edge, t as GraphSearchResult, I as ILLMProvider, q as VectorDBProvider, h as LLMProvider, f as EmbeddingProvider, j as RAGConfig, U as UIConfig, C as ChatMessage, c as ChatOptions, E as EmbedOptions } from './ILLMProvider-
|
|
2
|
-
export { d as ChatResponse, g as IngestDocument, l as RetrievalConfig, W as WorkflowConfig } from './ILLMProvider-
|
|
3
|
-
export { A as AuthenticationException, C as Chunk, a as ChunkOptions, b as ConfigurationException, D as DocumentChunker, E as EmbeddingFailedException, g as Pipeline, P as ProviderNotFoundException, R as RateLimitException, c as RetrievalException, d as Retrivora, e as RetrivoraError, f as RetrivoraErrorCode, w as wrapError } from './index-
|
|
4
|
-
import { H as HealthCheckResult, I as IProviderValidator, a as IProviderHealthChecker } from './index-
|
|
5
|
-
export { C as ConfigValidator, V as ValidationError, b as VectorPlugin, c as createChatHandler, d as createFeedbackHandler, e as createHealthHandler, f as createHistoryHandler, g as createIngestHandler, h as createRagHandler, i as createSessionsHandler, j as createStreamHandler, k as createUploadHandler, s as sseErrorFrame, l as sseFrame, m as sseMetaFrame, n as sseTextFrame } from './index-
|
|
1
|
+
import { p as VectorDBConfig, L as LLMConfig, e as EmbeddingConfig, k as RagConfig, n as UniversalRagConfig, o as UpsertDocument, V as VectorMatch, G as GraphDBConfig, r as GraphNode, s as Edge, t as GraphSearchResult, I as ILLMProvider, q as VectorDBProvider, h as LLMProvider, f as EmbeddingProvider, j as RAGConfig, U as UIConfig, C as ChatMessage, c as ChatOptions, E as EmbedOptions } from './ILLMProvider-DMxLyTdq.js';
|
|
2
|
+
export { d as ChatResponse, g as IngestDocument, l as RetrievalConfig, W as WorkflowConfig } from './ILLMProvider-DMxLyTdq.js';
|
|
3
|
+
export { A as AuthenticationException, C as Chunk, a as ChunkOptions, b as ConfigurationException, D as DocumentChunker, E as EmbeddingFailedException, g as Pipeline, P as ProviderNotFoundException, R as RateLimitException, c as RetrievalException, d as Retrivora, e as RetrivoraError, f as RetrivoraErrorCode, w as wrapError } from './index-CfkqZd2Y.js';
|
|
4
|
+
import { H as HealthCheckResult, I as IProviderValidator, a as IProviderHealthChecker } from './index-D_bOdJML.js';
|
|
5
|
+
export { C as ConfigValidator, V as ValidationError, b as VectorPlugin, c as createChatHandler, d as createFeedbackHandler, e as createHealthHandler, f as createHistoryHandler, g as createIngestHandler, h as createRagHandler, i as createSessionsHandler, j as createStreamHandler, k as createUploadHandler, s as sseErrorFrame, l as sseFrame, m as sseMetaFrame, n as sseTextFrame } from './index-D_bOdJML.js';
|
|
6
6
|
import 'next/server';
|
|
7
7
|
|
|
8
8
|
interface LicensePayload {
|
|
@@ -15,6 +15,8 @@ interface LicensePayload {
|
|
|
15
15
|
* Enables zero-latency local license validation without external network calls.
|
|
16
16
|
*/
|
|
17
17
|
declare class LicenseVerifier {
|
|
18
|
+
private static readonly cache;
|
|
19
|
+
private static readonly CACHE_TTL_MS;
|
|
18
20
|
private static readonly PUBLIC_KEY;
|
|
19
21
|
/**
|
|
20
22
|
* Decodes, verifies signature, and checks metadata of a license key.
|
|
@@ -24,6 +26,7 @@ declare class LicenseVerifier {
|
|
|
24
26
|
* @param publicKeyOverride - Optional override for unit/integration tests.
|
|
25
27
|
*/
|
|
26
28
|
static verify(licenseKey: string | undefined, currentProjectId: string, provider?: string, publicKeyOverride?: string): LicensePayload;
|
|
29
|
+
static verifyIP(licenseKey: string | undefined): Promise<void>;
|
|
27
30
|
}
|
|
28
31
|
|
|
29
32
|
/**
|
package/dist/server.js
CHANGED
|
@@ -2429,7 +2429,7 @@ var ConfigResolver = class {
|
|
|
2429
2429
|
}
|
|
2430
2430
|
}
|
|
2431
2431
|
static mergeRetrievalWorkflow(rag, retrieval, workflow) {
|
|
2432
|
-
var _a2, _b, _c, _d, _e;
|
|
2432
|
+
var _a2, _b, _c, _d, _e, _f;
|
|
2433
2433
|
if (!rag && !retrieval && !workflow) return void 0;
|
|
2434
2434
|
const normalized = __spreadValues({}, rag != null ? rag : {});
|
|
2435
2435
|
if (retrieval) {
|
|
@@ -2437,20 +2437,44 @@ var ConfigResolver = class {
|
|
|
2437
2437
|
normalized.scoreThreshold = (_b = retrieval.scoreThreshold) != null ? _b : normalized.scoreThreshold;
|
|
2438
2438
|
normalized.useReranking = (_c = retrieval.useReranking) != null ? _c : normalized.useReranking;
|
|
2439
2439
|
if (retrieval.strategy === "hybrid") normalized.architecture = (_d = normalized.architecture) != null ? _d : "hybrid";
|
|
2440
|
-
if (retrieval.strategy === "agentic") normalized.architecture = "
|
|
2441
|
-
if (retrieval.strategy === "contextual-compression")
|
|
2440
|
+
if (retrieval.strategy === "agentic") normalized.architecture = "multi-agent";
|
|
2441
|
+
if (retrieval.strategy === "contextual-compression") {
|
|
2442
|
+
normalized.useReranking = true;
|
|
2443
|
+
normalized.architecture = (_e = normalized.architecture) != null ? _e : "retrieve-and-rerank";
|
|
2444
|
+
}
|
|
2442
2445
|
}
|
|
2443
2446
|
if (workflow == null ? void 0 : workflow.type) {
|
|
2444
2447
|
const type = workflow.type;
|
|
2445
|
-
if (type === "
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
+
if (type === "naive-rag") {
|
|
2449
|
+
normalized.architecture = "naive";
|
|
2450
|
+
normalized.useReranking = false;
|
|
2451
|
+
normalized.useGraphRetrieval = false;
|
|
2452
|
+
} else if (type === "retrieve-and-rerank") {
|
|
2453
|
+
normalized.architecture = "retrieve-and-rerank";
|
|
2454
|
+
normalized.useReranking = true;
|
|
2455
|
+
} else if (type === "multimodal-rag") {
|
|
2456
|
+
normalized.architecture = "multimodal";
|
|
2457
|
+
} else if (type === "graph-rag") {
|
|
2448
2458
|
normalized.architecture = "graph";
|
|
2449
2459
|
normalized.useGraphRetrieval = true;
|
|
2460
|
+
} else if (type === "hybrid-rag") {
|
|
2461
|
+
normalized.architecture = "hybrid";
|
|
2462
|
+
} else if (type === "agentic-router") {
|
|
2463
|
+
normalized.architecture = "agentic-router";
|
|
2464
|
+
} else if (type === "multi-agent-rag" || type === "multi-agent" || type === "agentic" || type === "agentic-rag") {
|
|
2465
|
+
normalized.architecture = "multi-agent";
|
|
2450
2466
|
} else if (type === "simple-rag" || type === "rag") {
|
|
2451
|
-
normalized.architecture = (
|
|
2467
|
+
normalized.architecture = (_f = normalized.architecture) != null ? _f : "naive";
|
|
2452
2468
|
}
|
|
2453
2469
|
}
|
|
2470
|
+
if (normalized.architecture === "retrieve-and-rerank") {
|
|
2471
|
+
normalized.useReranking = true;
|
|
2472
|
+
} else if (normalized.architecture === "graph") {
|
|
2473
|
+
normalized.useGraphRetrieval = true;
|
|
2474
|
+
} else if (normalized.architecture === "naive") {
|
|
2475
|
+
normalized.useReranking = false;
|
|
2476
|
+
normalized.useGraphRetrieval = false;
|
|
2477
|
+
}
|
|
2454
2478
|
return normalized;
|
|
2455
2479
|
}
|
|
2456
2480
|
};
|
|
@@ -4305,6 +4329,19 @@ var LicenseVerifier = class {
|
|
|
4305
4329
|
*/
|
|
4306
4330
|
static verify(licenseKey, currentProjectId, provider, publicKeyOverride) {
|
|
4307
4331
|
const isProduction = process.env.NODE_ENV === "production";
|
|
4332
|
+
const now = Date.now();
|
|
4333
|
+
if (licenseKey) {
|
|
4334
|
+
const cacheKey = `${licenseKey}:${currentProjectId}:${provider || ""}:${publicKeyOverride || ""}`;
|
|
4335
|
+
const cached = this.cache.get(cacheKey);
|
|
4336
|
+
if (cached && now - cached.cachedAt < this.CACHE_TTL_MS) {
|
|
4337
|
+
const currentTimestampSec = Math.floor(now / 1e3);
|
|
4338
|
+
if (cached.payload.expiresAt && currentTimestampSec > cached.payload.expiresAt) {
|
|
4339
|
+
this.cache.delete(cacheKey);
|
|
4340
|
+
} else {
|
|
4341
|
+
return cached.payload;
|
|
4342
|
+
}
|
|
4343
|
+
}
|
|
4344
|
+
}
|
|
4308
4345
|
if (!licenseKey) {
|
|
4309
4346
|
if (isProduction) {
|
|
4310
4347
|
throw new ConfigurationException(
|
|
@@ -4391,6 +4428,10 @@ var LicenseVerifier = class {
|
|
|
4391
4428
|
}
|
|
4392
4429
|
}
|
|
4393
4430
|
}
|
|
4431
|
+
if (licenseKey) {
|
|
4432
|
+
const cacheKey = `${licenseKey}:${currentProjectId}:${provider || ""}:${publicKeyOverride || ""}`;
|
|
4433
|
+
this.cache.set(cacheKey, { payload, cachedAt: now });
|
|
4434
|
+
}
|
|
4394
4435
|
return payload;
|
|
4395
4436
|
} catch (err) {
|
|
4396
4437
|
const message = err instanceof Error ? err.message : String(err);
|
|
@@ -4399,7 +4440,76 @@ var LicenseVerifier = class {
|
|
|
4399
4440
|
);
|
|
4400
4441
|
}
|
|
4401
4442
|
}
|
|
4443
|
+
static async verifyIP(licenseKey) {
|
|
4444
|
+
if (!licenseKey) return;
|
|
4445
|
+
try {
|
|
4446
|
+
const parts = licenseKey.split(".");
|
|
4447
|
+
if (parts.length !== 3) return;
|
|
4448
|
+
const [, payloadB64] = parts;
|
|
4449
|
+
const payload = JSON.parse(
|
|
4450
|
+
Buffer.from(payloadB64, "base64url").toString("utf8")
|
|
4451
|
+
);
|
|
4452
|
+
const tier = (payload.tier || "").toLowerCase();
|
|
4453
|
+
if (tier === "enterprise" || tier === "custom") {
|
|
4454
|
+
return;
|
|
4455
|
+
}
|
|
4456
|
+
if (payload.ipv4 || payload.ipv6) {
|
|
4457
|
+
let currentIpv4 = "";
|
|
4458
|
+
let currentIpv6 = "";
|
|
4459
|
+
try {
|
|
4460
|
+
const res = await fetch("https://api4.ipify.org?format=json", { signal: AbortSignal.timeout(3e3) });
|
|
4461
|
+
const data = await res.json();
|
|
4462
|
+
currentIpv4 = data.ip;
|
|
4463
|
+
} catch (e) {
|
|
4464
|
+
}
|
|
4465
|
+
try {
|
|
4466
|
+
const res = await fetch("https://api6.ipify.org?format=json", { signal: AbortSignal.timeout(3e3) });
|
|
4467
|
+
const data = await res.json();
|
|
4468
|
+
currentIpv6 = data.ip;
|
|
4469
|
+
} catch (e) {
|
|
4470
|
+
}
|
|
4471
|
+
const localIps = [];
|
|
4472
|
+
try {
|
|
4473
|
+
const osModule = require("os");
|
|
4474
|
+
const interfaces = osModule.networkInterfaces();
|
|
4475
|
+
for (const name of Object.keys(interfaces)) {
|
|
4476
|
+
for (const iface of interfaces[name] || []) {
|
|
4477
|
+
if (!iface.internal) {
|
|
4478
|
+
localIps.push(iface.address);
|
|
4479
|
+
}
|
|
4480
|
+
}
|
|
4481
|
+
}
|
|
4482
|
+
} catch (e) {
|
|
4483
|
+
}
|
|
4484
|
+
const isIpv4Match = payload.ipv4 && (currentIpv4 === payload.ipv4 || localIps.includes(payload.ipv4));
|
|
4485
|
+
const isIpv6Match = payload.ipv6 && (currentIpv6 === payload.ipv6 || localIps.includes(payload.ipv6));
|
|
4486
|
+
if (payload.ipv4 && payload.ipv6) {
|
|
4487
|
+
if (!isIpv4Match && !isIpv6Match) {
|
|
4488
|
+
throw new Error(
|
|
4489
|
+
`License key access restricted. This license key was created for a different system (authorized IPv4: ${payload.ipv4}, IPv6: ${payload.ipv6}) and cannot be used on this machine.`
|
|
4490
|
+
);
|
|
4491
|
+
}
|
|
4492
|
+
} else if (payload.ipv4 && !isIpv4Match) {
|
|
4493
|
+
throw new Error(
|
|
4494
|
+
`License key access restricted. This license key was created for a different system (authorized IPv4: ${payload.ipv4}) and cannot be used on this machine.`
|
|
4495
|
+
);
|
|
4496
|
+
} else if (payload.ipv6 && !isIpv6Match) {
|
|
4497
|
+
throw new Error(
|
|
4498
|
+
`License key access restricted. This license key was created for a different system (authorized IPv6: ${payload.ipv6}) and cannot be used on this machine.`
|
|
4499
|
+
);
|
|
4500
|
+
}
|
|
4501
|
+
}
|
|
4502
|
+
} catch (err) {
|
|
4503
|
+
if (err.message.includes("License key access restricted")) {
|
|
4504
|
+
throw new ConfigurationException(`[Retrivora SDK] ${err.message}`);
|
|
4505
|
+
}
|
|
4506
|
+
}
|
|
4507
|
+
}
|
|
4402
4508
|
};
|
|
4509
|
+
// A simple in-memory cache to save CPU overhead of cryptographic signature checks.
|
|
4510
|
+
LicenseVerifier.cache = /* @__PURE__ */ new Map();
|
|
4511
|
+
LicenseVerifier.CACHE_TTL_MS = 60 * 1e3;
|
|
4512
|
+
// Cache verified license for 60 seconds
|
|
4403
4513
|
// Retrivora's Public Key used to verify the license key signature.
|
|
4404
4514
|
// In production, this matches the private key held by Retrivora SaaS.
|
|
4405
4515
|
LicenseVerifier.PUBLIC_KEY = `-----BEGIN PUBLIC KEY-----
|
|
@@ -7360,7 +7470,7 @@ var Pipeline = class {
|
|
|
7360
7470
|
return this.initialised ? this.llmProvider : void 0;
|
|
7361
7471
|
}
|
|
7362
7472
|
async initialize() {
|
|
7363
|
-
var _a2, _b, _c;
|
|
7473
|
+
var _a2, _b, _c, _d;
|
|
7364
7474
|
if (this.initialised) return;
|
|
7365
7475
|
const chartInstruction = `You are a helpful assistant. Use the provided context to answer questions accurately.
|
|
7366
7476
|
|
|
@@ -7403,7 +7513,7 @@ var Pipeline = class {
|
|
|
7403
7513
|
this.entityExtractor = new EntityExtractor(this.llmProvider);
|
|
7404
7514
|
}
|
|
7405
7515
|
await this.vectorDB.initialize();
|
|
7406
|
-
if (((_a2 = this.config.rag) == null ? void 0 : _a2.architecture) === "agentic" || this.config.mcpServers && this.config.mcpServers.length > 0) {
|
|
7516
|
+
if (((_a2 = this.config.rag) == null ? void 0 : _a2.architecture) === "agentic" || ((_b = this.config.rag) == null ? void 0 : _b.architecture) === "multi-agent" || this.config.mcpServers && this.config.mcpServers.length > 0) {
|
|
7407
7517
|
this.mcpRegistry = new MCPRegistry(this.config.mcpServers || []);
|
|
7408
7518
|
this.multiAgentCoordinator = new MultiAgentCoordinator({
|
|
7409
7519
|
llmProvider: this.llmProvider,
|
|
@@ -7415,7 +7525,7 @@ var Pipeline = class {
|
|
|
7415
7525
|
this.agent = new LangChainAgent(this, this.config);
|
|
7416
7526
|
await this.agent.initialize(this.llmProvider);
|
|
7417
7527
|
}
|
|
7418
|
-
if ((
|
|
7528
|
+
if ((_d = (_c = this.config.rag) == null ? void 0 : _c.cag) == null ? void 0 : _d.enabled) {
|
|
7419
7529
|
await this.loadColdContext(this.config.projectId);
|
|
7420
7530
|
}
|
|
7421
7531
|
this.initialised = true;
|
|
@@ -7578,9 +7688,9 @@ ${m.content}`).join("\n\n---\n\n");
|
|
|
7578
7688
|
return { reply, sources };
|
|
7579
7689
|
}
|
|
7580
7690
|
async ask(question, history = [], namespace) {
|
|
7581
|
-
var _a2;
|
|
7691
|
+
var _a2, _b;
|
|
7582
7692
|
await this.initialize();
|
|
7583
|
-
if ((((_a2 = this.config.rag) == null ? void 0 : _a2.architecture) === "agentic" || this.config.mcpServers && this.config.mcpServers.length > 0) && this.multiAgentCoordinator) {
|
|
7693
|
+
if ((((_a2 = this.config.rag) == null ? void 0 : _a2.architecture) === "agentic" || ((_b = this.config.rag) == null ? void 0 : _b.architecture) === "multi-agent" || this.config.mcpServers && this.config.mcpServers.length > 0) && this.multiAgentCoordinator) {
|
|
7584
7694
|
return await this.multiAgentCoordinator.run(question, history);
|
|
7585
7695
|
}
|
|
7586
7696
|
const stream = this.askStream(question, history, namespace);
|
|
@@ -7615,9 +7725,9 @@ ${m.content}`).join("\n\n---\n\n");
|
|
|
7615
7725
|
}
|
|
7616
7726
|
askStream(_0) {
|
|
7617
7727
|
return __asyncGenerator(this, arguments, function* (question, history = [], namespace) {
|
|
7618
|
-
var _a2;
|
|
7728
|
+
var _a2, _b;
|
|
7619
7729
|
yield new __await(this.initialize());
|
|
7620
|
-
if ((((_a2 = this.config.rag) == null ? void 0 : _a2.architecture) === "agentic" || this.config.mcpServers && this.config.mcpServers.length > 0) && this.multiAgentCoordinator) {
|
|
7730
|
+
if ((((_a2 = this.config.rag) == null ? void 0 : _a2.architecture) === "agentic" || ((_b = this.config.rag) == null ? void 0 : _b.architecture) === "multi-agent" || this.config.mcpServers && this.config.mcpServers.length > 0) && this.multiAgentCoordinator) {
|
|
7621
7731
|
const stream2 = this.multiAgentCoordinator.runStream(question, history);
|
|
7622
7732
|
try {
|
|
7623
7733
|
for (var iter = __forAwait(stream2), more, temp, error; more = !(temp = yield new __await(iter.next())).done; more = false) {
|
|
@@ -7666,7 +7776,7 @@ ${m.content}`).join("\n\n---\n\n");
|
|
|
7666
7776
|
*/
|
|
7667
7777
|
askStreamInternal(_0) {
|
|
7668
7778
|
return __asyncGenerator(this, arguments, function* (question, history = [], namespace) {
|
|
7669
|
-
var _a2, _b, _c, _d, _e, _f, _g2, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
|
|
7779
|
+
var _a2, _b, _c, _d, _e, _f, _g2, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A;
|
|
7670
7780
|
yield new __await(this.initialize());
|
|
7671
7781
|
const ns = namespace != null ? namespace : this.config.projectId;
|
|
7672
7782
|
const topK = (_b = (_a2 = this.config.rag) == null ? void 0 : _a2.topK) != null ? _b : 5;
|
|
@@ -7689,13 +7799,14 @@ ${m.content}`).join("\n\n---\n\n");
|
|
|
7689
7799
|
const embedStart = performance.now();
|
|
7690
7800
|
const cacheKey = `${ns}::${searchQuery}`;
|
|
7691
7801
|
const cachedVector = this.embeddingCache.get(cacheKey);
|
|
7692
|
-
const
|
|
7802
|
+
const arch = (_h = this.config.rag) == null ? void 0 : _h.architecture;
|
|
7803
|
+
const useGraph = arch !== "naive" && arch !== "retrieve-and-rerank" && this.graphDB && ((_i = this.config.rag) == null ? void 0 : _i.useGraphRetrieval);
|
|
7693
7804
|
const [strategyResult, embeddedVector] = yield new __await(Promise.all([
|
|
7694
7805
|
QueryProcessor.determineRetrievalStrategy(
|
|
7695
7806
|
searchQuery,
|
|
7696
7807
|
useGraph ? this.llmRouter.get("fast") : void 0,
|
|
7697
|
-
(
|
|
7698
|
-
(
|
|
7808
|
+
(_j = this.config.rag) == null ? void 0 : _j.graphKeywords,
|
|
7809
|
+
(_k = this.config.rag) == null ? void 0 : _k.vectorKeywords
|
|
7699
7810
|
),
|
|
7700
7811
|
// Embed immediately regardless of strategy — costs nothing if cached.
|
|
7701
7812
|
// If strategy turns out to be 'graph'-only we just won't use the vector.
|
|
@@ -7705,7 +7816,7 @@ ${m.content}`).join("\n\n---\n\n");
|
|
|
7705
7816
|
if (!cachedVector && queryVector.length > 0) {
|
|
7706
7817
|
this.embeddingCache.set(cacheKey, queryVector);
|
|
7707
7818
|
}
|
|
7708
|
-
const graphData = (strategyResult === "graph" || strategyResult === "both") && this.graphDB && ((
|
|
7819
|
+
const graphData = (strategyResult === "graph" || strategyResult === "both") && this.graphDB && ((_l = this.config.rag) == null ? void 0 : _l.useGraphRetrieval) ? yield new __await(this.graphDB.query(searchQuery)) : void 0;
|
|
7709
7820
|
const hasMetadataFilter = filter.metadata && Object.keys(filter.metadata).length > 0;
|
|
7710
7821
|
const hasNumericPredicates = Array.isArray(filter.__numericPredicates) && filter.__numericPredicates.length > 0;
|
|
7711
7822
|
const wantsExhaustiveList = hasNumericPredicates || hasMetadataFilter || /\b(list|all|show|provide|give|get|browse|find|search|display)\b/i.test(question);
|
|
@@ -7718,7 +7829,8 @@ ${m.content}`).join("\n\n---\n\n");
|
|
|
7718
7829
|
const structuredSources = this.applyStructuredFilters(rawSources, filter);
|
|
7719
7830
|
let fullSources = hasNumericPredicates ? structuredSources : structuredSources.filter((m) => m.score >= scoreThreshold);
|
|
7720
7831
|
const rerankLimit = wantsExhaustiveList ? retrievalLimit : topK;
|
|
7721
|
-
|
|
7832
|
+
const useReranking = arch !== "naive" && (arch === "retrieve-and-rerank" || ((_m = this.config.rag) == null ? void 0 : _m.useReranking));
|
|
7833
|
+
if (!hasNumericPredicates && useReranking) {
|
|
7722
7834
|
fullSources = yield new __await(this.reranker.rerank(fullSources, question, rerankLimit));
|
|
7723
7835
|
} else if (!wantsExhaustiveList) {
|
|
7724
7836
|
fullSources = fullSources.slice(0, topK);
|
|
@@ -7748,7 +7860,7 @@ ${graphContext}
|
|
|
7748
7860
|
VECTOR CONTEXT:
|
|
7749
7861
|
${context}`;
|
|
7750
7862
|
}
|
|
7751
|
-
if ((
|
|
7863
|
+
if ((_o = (_n = this.config.rag) == null ? void 0 : _n.cag) == null ? void 0 : _o.enabled) {
|
|
7752
7864
|
if (!this.coldContexts.has(ns)) {
|
|
7753
7865
|
yield new __await(this.loadColdContext(ns));
|
|
7754
7866
|
}
|
|
@@ -7801,10 +7913,10 @@ ${context}`;
|
|
|
7801
7913
|
let hallucinationScoringPromise = Promise.resolve(void 0);
|
|
7802
7914
|
const restrictionSuffix = "\n\n(IMPORTANT: Format your response beautifully using rich Markdown! Use bolding for emphasis, headings (##) for structure, bullet points for lists, and proper line breaks between paragraphs to make it highly readable. However, NEVER generate Markdown tables, HTML figures, or text charts (the UI renders requested charts separately, so NEVER say you cannot create, display, draw, render, or provide a chart/visualization). If listing products, use simple markdown bullet points or comma-separated names. NEVER use plus signs (+) to separate product names, category names, or list items. For product description/detail questions, provide customer-facing prose only and do NOT list internal catalog fields such as Handle, Body (HTML), Vendor, Type, Tags, Published, Option, Variant, SKU, or raw metadata labels. You CAN use numbers for years/counts like 2006 or 5800, but NEVER put a dollar sign ($) before them.)";
|
|
7803
7915
|
const isClaude37 = this.config.llm.model.includes("claude-3-7-sonnet");
|
|
7804
|
-
const isNativeThinking = isClaude37 && (((
|
|
7916
|
+
const isNativeThinking = isClaude37 && (((_p = this.config.llm.options) == null ? void 0 : _p.thinking) === true || ((_q = this.config.llm.options) == null ? void 0 : _q.thinking) === "enabled" || ((_r = this.config.llm.options) == null ? void 0 : _r.thinking) !== false);
|
|
7805
7917
|
const modelNameLower = this.config.llm.model.toLowerCase();
|
|
7806
7918
|
const isReasoningModel = modelNameLower.includes("-r1") || modelNameLower.includes("deepseek-r1") || modelNameLower.includes("reasoning") || modelNameLower.includes("thinking");
|
|
7807
|
-
const isSimulatedThinking = !isNativeThinking && (((
|
|
7919
|
+
const isSimulatedThinking = !isNativeThinking && (((_s = this.config.llm.options) == null ? void 0 : _s.thinking) === true || ((_t = this.config.llm.options) == null ? void 0 : _t.thinking) === "enabled" || isReasoningModel && ((_u = this.config.llm.options) == null ? void 0 : _u.thinking) !== false);
|
|
7808
7920
|
let finalRestrictionSuffix = restrictionSuffix;
|
|
7809
7921
|
if (isSimulatedThinking) {
|
|
7810
7922
|
finalRestrictionSuffix += "\n\n(IMPORTANT: You must think step-by-step before answering. Write your thinking process inside a `<think>...</think>` block. Write the `<think>` block first, then follow it with your final response. Keep the thinking process thorough and detailed. Example: `<think>Thinking details here...</think>Final answer text here.`)";
|
|
@@ -7812,7 +7924,7 @@ ${context}`;
|
|
|
7812
7924
|
const hardenedHistory = [...history];
|
|
7813
7925
|
const userQuestion = { role: "user", content: question + finalRestrictionSuffix };
|
|
7814
7926
|
const messages = [...hardenedHistory, userQuestion];
|
|
7815
|
-
const systemPrompt = (
|
|
7927
|
+
const systemPrompt = (_v = this.config.llm.systemPrompt) != null ? _v : "";
|
|
7816
7928
|
const userPrompt = messages.map((m) => `${m.role}: ${m.content}`).join("\n");
|
|
7817
7929
|
let fullReply = "";
|
|
7818
7930
|
let thinkingText = "";
|
|
@@ -7923,7 +8035,7 @@ ${context}`;
|
|
|
7923
8035
|
}
|
|
7924
8036
|
yield fullReply;
|
|
7925
8037
|
}
|
|
7926
|
-
const runHallucination = ((
|
|
8038
|
+
const runHallucination = ((_w = this.config.llm.options) == null ? void 0 : _w.hallucinationScoring) === true || this.config.llm.provider !== "ollama" && ((_x = this.config.llm.options) == null ? void 0 : _x.hallucinationScoring) !== false;
|
|
7927
8039
|
if (runHallucination) {
|
|
7928
8040
|
hallucinationScoringPromise = scoreHallucination(this.llmProvider, fullReply, context).catch(() => void 0);
|
|
7929
8041
|
}
|
|
@@ -7932,7 +8044,7 @@ ${context}`;
|
|
|
7932
8044
|
const latency = {
|
|
7933
8045
|
embedMs: Math.round(embedMs),
|
|
7934
8046
|
retrieveMs: Math.round(retrieveMs),
|
|
7935
|
-
rerankMs: ((
|
|
8047
|
+
rerankMs: arch !== "naive" && (arch === "retrieve-and-rerank" || ((_y = this.config.rag) == null ? void 0 : _y.useReranking)) ? Math.round(rerankMs) : void 0,
|
|
7936
8048
|
generateMs: Math.round(generateMs),
|
|
7937
8049
|
totalMs: Math.round(totalMs)
|
|
7938
8050
|
};
|
|
@@ -7945,7 +8057,7 @@ ${context}`;
|
|
|
7945
8057
|
totalTokens: promptTokens + completionTokens,
|
|
7946
8058
|
estimatedCostUsd: estimateCostUsd(promptTokens, completionTokens, this.config.llm.model)
|
|
7947
8059
|
};
|
|
7948
|
-
const awaitHallucination = ((
|
|
8060
|
+
const awaitHallucination = ((_z = this.config.llm.options) == null ? void 0 : _z.awaitHallucination) === true;
|
|
7949
8061
|
const [uiTransformation, hallucinationResult] = yield new __await(Promise.all([
|
|
7950
8062
|
uiTransformationPromise,
|
|
7951
8063
|
awaitHallucination ? hallucinationScoringPromise : Promise.resolve(void 0)
|
|
@@ -7974,7 +8086,7 @@ ${context}`;
|
|
|
7974
8086
|
hallucinationReason: hScore.reason
|
|
7975
8087
|
} : {});
|
|
7976
8088
|
const trace = buildTrace(hallucinationResult);
|
|
7977
|
-
if ((
|
|
8089
|
+
if ((_A = this.config.telemetry) == null ? void 0 : _A.enabled) {
|
|
7978
8090
|
const telemetryUrl = this.config.telemetry.url || "/api/telemetry";
|
|
7979
8091
|
const absoluteUrl = telemetryUrl.startsWith("http") ? telemetryUrl : (process.env.NEXT_PUBLIC_APP_URL || `http://localhost:${process.env.PORT || 3e3}`) + telemetryUrl;
|
|
7980
8092
|
(async () => {
|
|
@@ -8250,6 +8362,7 @@ var Retrivora = class {
|
|
|
8250
8362
|
this.config.projectId,
|
|
8251
8363
|
(_a2 = this.config.vectorDb) == null ? void 0 : _a2.provider
|
|
8252
8364
|
);
|
|
8365
|
+
await LicenseVerifier.verifyIP(this.config.licenseKey);
|
|
8253
8366
|
} catch (err) {
|
|
8254
8367
|
throw wrapError(err, "CONFIGURATION_ERROR");
|
|
8255
8368
|
}
|