@retrivora-ai/rag-engine 2.1.2 → 2.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{ILLMProvider-0rRBYbVW.d.mts → ILLMProvider-BWa68XX5.d.mts} +2 -0
- package/dist/{ILLMProvider-0rRBYbVW.d.ts → ILLMProvider-BWa68XX5.d.ts} +2 -0
- package/dist/handlers/index.d.mts +2 -2
- package/dist/handlers/index.d.ts +2 -2
- package/dist/handlers/index.js +278 -69
- package/dist/handlers/index.mjs +278 -69
- package/dist/{index-B1wGUlSL.d.mts → index-BCbeeh74.d.ts} +11 -2
- package/dist/{index-DcklhThn.d.ts → index-BbJGyNmW.d.mts} +11 -2
- package/dist/{index-BIHHp_f6.d.ts → index-C6ehmP0b.d.ts} +1 -1
- package/dist/{index-BvODr57d.d.mts → index-DFc_Ll9z.d.mts} +1 -1
- package/dist/index.css +23 -0
- package/dist/index.d.mts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js +191 -21
- package/dist/index.mjs +190 -21
- package/dist/server.d.mts +6 -6
- package/dist/server.d.ts +6 -6
- package/dist/server.js +280 -69
- package/dist/server.mjs +279 -69
- package/package.json +1 -1
- package/src/components/DocumentUpload.tsx +50 -18
- package/src/config/serverConfig.ts +7 -7
- package/src/core/Pipeline.ts +23 -1
- package/src/handlers/index.ts +34 -10
- package/src/index.css +23 -0
- package/src/index.ts +1 -0
- package/src/server.ts +1 -0
- package/src/types/index.ts +2 -0
- package/src/types/props.ts +4 -0
- package/src/version.ts +6 -0
package/dist/server.d.mts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { V as VectorDBConfig, L as LLMConfig, d as EmbeddingConfig, i as RagConfig, n as UniversalRagConfig, o as UpsertDocument, q as VectorMatch, G as GraphDBConfig, r as GraphNode, s as Edge, t as GraphSearchResult, I as ILLMProvider, p as VectorDBProvider, g as LLMProvider, e as EmbeddingProvider, R as RAGConfig, m as UIConfig, C as ChatMessage, b as ChatOptions, E as EmbedOptions } from './ILLMProvider-
|
|
2
|
-
export { B as BarChartData, u as CarouselProduct, c as ChatResponse, v as IRetriever, f as IngestDocument, h as LatencyBreakdown, w as LineChartDataPoint, M as MessageRole, x as MetricCardData, O as ObservabilityTrace, P as PieChartData, y as Product, j as RagMessage, k as RetrievalConfig, z as RetrievalResult, l as RetrievedChunk, A as RetrivoraChunkMetadata, D as RetrivoraIngestedDocument, S as ScatterPlotDataPoint, F as SuggestionsResponse, H as TableData, T as TokenUsage, J as UITransformationResponse, U as UseRagChatOptions, a as UseRagChatReturn, K as VisualizationType, W as WorkflowConfig } from './ILLMProvider-
|
|
3
|
-
import { I as IRenderRule, i as DecisionContext, k as IntentCategory, n as RenderDecision } from './index-
|
|
4
|
-
export {
|
|
5
|
-
import { H as HealthCheckResult, I as IProviderValidator, a as IProviderHealthChecker } from './index-
|
|
6
|
-
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 { V as VectorDBConfig, L as LLMConfig, d as EmbeddingConfig, i as RagConfig, n as UniversalRagConfig, o as UpsertDocument, q as VectorMatch, G as GraphDBConfig, r as GraphNode, s as Edge, t as GraphSearchResult, I as ILLMProvider, p as VectorDBProvider, g as LLMProvider, e as EmbeddingProvider, R as RAGConfig, m as UIConfig, C as ChatMessage, b as ChatOptions, E as EmbedOptions } from './ILLMProvider-BWa68XX5.mjs';
|
|
2
|
+
export { B as BarChartData, u as CarouselProduct, c as ChatResponse, v as IRetriever, f as IngestDocument, h as LatencyBreakdown, w as LineChartDataPoint, M as MessageRole, x as MetricCardData, O as ObservabilityTrace, P as PieChartData, y as Product, j as RagMessage, k as RetrievalConfig, z as RetrievalResult, l as RetrievedChunk, A as RetrivoraChunkMetadata, D as RetrivoraIngestedDocument, S as ScatterPlotDataPoint, F as SuggestionsResponse, H as TableData, T as TokenUsage, J as UITransformationResponse, U as UseRagChatOptions, a as UseRagChatReturn, K as VisualizationType, W as WorkflowConfig } from './ILLMProvider-BWa68XX5.mjs';
|
|
3
|
+
import { I as IRenderRule, i as DecisionContext, k as IntentCategory, n as RenderDecision } from './index-BbJGyNmW.mjs';
|
|
4
|
+
export { x as ArchitectureCardProps, A as AuthenticationException, y as CarouselRendererStrategy, z as ChartRendererStrategy, e as ChartType, B as ChatViewportSize, C as ChatWidgetProps, a as ChatWindowProps, f as Chunk, g as ChunkOptions, c as ClientConfig, b as ConfigProviderProps, h as ConfigurationException, F as DocumentChunker, D as DocumentUploadProps, E as EmbeddingFailedException, j as IRendererStrategy, l as IntentClassifier, M as MessageBubbleProps, G as MixedRendererStrategy, H as Pipeline, J as PipelineStep, P as ProductCardProps, d as ProductCarouselProps, m as ProviderNotFoundException, K as ProviderPill, R as RateLimitException, L as RenderSectionDecision, o as RenderType, p as RendererRegistry, q as RetrievalException, r as Retrivora, s as RetrivoraError, t as RetrivoraErrorCode, u as RuleEngine, v as SDK_VERSION, N as Snippet, S as SourceCardProps, T as TableRendererStrategy, O as TextRendererStrategy, V as VisualizationDecisionEngine, w as decideVisualization, Q as wrapError } from './index-BbJGyNmW.mjs';
|
|
5
|
+
import { H as HealthCheckResult, I as IProviderValidator, a as IProviderHealthChecker } from './index-DFc_Ll9z.mjs';
|
|
6
|
+
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-DFc_Ll9z.mjs';
|
|
7
7
|
import 'react';
|
|
8
8
|
import 'next/server';
|
|
9
9
|
|
package/dist/server.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { V as VectorDBConfig, L as LLMConfig, d as EmbeddingConfig, i as RagConfig, n as UniversalRagConfig, o as UpsertDocument, q as VectorMatch, G as GraphDBConfig, r as GraphNode, s as Edge, t as GraphSearchResult, I as ILLMProvider, p as VectorDBProvider, g as LLMProvider, e as EmbeddingProvider, R as RAGConfig, m as UIConfig, C as ChatMessage, b as ChatOptions, E as EmbedOptions } from './ILLMProvider-
|
|
2
|
-
export { B as BarChartData, u as CarouselProduct, c as ChatResponse, v as IRetriever, f as IngestDocument, h as LatencyBreakdown, w as LineChartDataPoint, M as MessageRole, x as MetricCardData, O as ObservabilityTrace, P as PieChartData, y as Product, j as RagMessage, k as RetrievalConfig, z as RetrievalResult, l as RetrievedChunk, A as RetrivoraChunkMetadata, D as RetrivoraIngestedDocument, S as ScatterPlotDataPoint, F as SuggestionsResponse, H as TableData, T as TokenUsage, J as UITransformationResponse, U as UseRagChatOptions, a as UseRagChatReturn, K as VisualizationType, W as WorkflowConfig } from './ILLMProvider-
|
|
3
|
-
import { I as IRenderRule, i as DecisionContext, k as IntentCategory, n as RenderDecision } from './index-
|
|
4
|
-
export {
|
|
5
|
-
import { H as HealthCheckResult, I as IProviderValidator, a as IProviderHealthChecker } from './index-
|
|
6
|
-
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 { V as VectorDBConfig, L as LLMConfig, d as EmbeddingConfig, i as RagConfig, n as UniversalRagConfig, o as UpsertDocument, q as VectorMatch, G as GraphDBConfig, r as GraphNode, s as Edge, t as GraphSearchResult, I as ILLMProvider, p as VectorDBProvider, g as LLMProvider, e as EmbeddingProvider, R as RAGConfig, m as UIConfig, C as ChatMessage, b as ChatOptions, E as EmbedOptions } from './ILLMProvider-BWa68XX5.js';
|
|
2
|
+
export { B as BarChartData, u as CarouselProduct, c as ChatResponse, v as IRetriever, f as IngestDocument, h as LatencyBreakdown, w as LineChartDataPoint, M as MessageRole, x as MetricCardData, O as ObservabilityTrace, P as PieChartData, y as Product, j as RagMessage, k as RetrievalConfig, z as RetrievalResult, l as RetrievedChunk, A as RetrivoraChunkMetadata, D as RetrivoraIngestedDocument, S as ScatterPlotDataPoint, F as SuggestionsResponse, H as TableData, T as TokenUsage, J as UITransformationResponse, U as UseRagChatOptions, a as UseRagChatReturn, K as VisualizationType, W as WorkflowConfig } from './ILLMProvider-BWa68XX5.js';
|
|
3
|
+
import { I as IRenderRule, i as DecisionContext, k as IntentCategory, n as RenderDecision } from './index-BCbeeh74.js';
|
|
4
|
+
export { x as ArchitectureCardProps, A as AuthenticationException, y as CarouselRendererStrategy, z as ChartRendererStrategy, e as ChartType, B as ChatViewportSize, C as ChatWidgetProps, a as ChatWindowProps, f as Chunk, g as ChunkOptions, c as ClientConfig, b as ConfigProviderProps, h as ConfigurationException, F as DocumentChunker, D as DocumentUploadProps, E as EmbeddingFailedException, j as IRendererStrategy, l as IntentClassifier, M as MessageBubbleProps, G as MixedRendererStrategy, H as Pipeline, J as PipelineStep, P as ProductCardProps, d as ProductCarouselProps, m as ProviderNotFoundException, K as ProviderPill, R as RateLimitException, L as RenderSectionDecision, o as RenderType, p as RendererRegistry, q as RetrievalException, r as Retrivora, s as RetrivoraError, t as RetrivoraErrorCode, u as RuleEngine, v as SDK_VERSION, N as Snippet, S as SourceCardProps, T as TableRendererStrategy, O as TextRendererStrategy, V as VisualizationDecisionEngine, w as decideVisualization, Q as wrapError } from './index-BCbeeh74.js';
|
|
5
|
+
import { H as HealthCheckResult, I as IProviderValidator, a as IProviderHealthChecker } from './index-C6ehmP0b.js';
|
|
6
|
+
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-C6ehmP0b.js';
|
|
7
7
|
import 'react';
|
|
8
8
|
import 'next/server';
|
|
9
9
|
|
package/dist/server.js
CHANGED
|
@@ -591,26 +591,54 @@ function cleanApiKeyOverride(apiKeyOverride) {
|
|
|
591
591
|
}
|
|
592
592
|
return key;
|
|
593
593
|
}
|
|
594
|
+
async function resolveUserGatewayConfig(apiKeyOverride) {
|
|
595
|
+
var _a2;
|
|
596
|
+
if (!apiKeyOverride || !process.env.NEXT_PUBLIC_SUPABASE_URL || !process.env.SUPABASE_SERVICE_ROLE_KEY) {
|
|
597
|
+
return {};
|
|
598
|
+
}
|
|
599
|
+
try {
|
|
600
|
+
const { createAdminClient } = await import("@/lib/supabase-server");
|
|
601
|
+
const supabase = createAdminClient();
|
|
602
|
+
const { data: licenseRecord } = await supabase.from("licenses").select("project_id, customer_name, tier").eq("license_key", apiKeyOverride.trim()).single();
|
|
603
|
+
if (!licenseRecord) {
|
|
604
|
+
return {};
|
|
605
|
+
}
|
|
606
|
+
const projectId = licenseRecord.project_id;
|
|
607
|
+
const { data: configs } = await supabase.from("gateway_config").select("project_id, default_model, provider_keys, is_active").in("project_id", [projectId, "global"]).eq("is_active", true);
|
|
608
|
+
if (!configs || configs.length === 0) {
|
|
609
|
+
return {};
|
|
610
|
+
}
|
|
611
|
+
const matchedConfig = configs.find((c) => c.project_id === projectId) || configs.find((c) => c.project_id === "global");
|
|
612
|
+
const customGroqKey = (_a2 = matchedConfig == null ? void 0 : matchedConfig.provider_keys) == null ? void 0 : _a2.groq;
|
|
613
|
+
const targetModel = matchedConfig == null ? void 0 : matchedConfig.default_model;
|
|
614
|
+
return { customGroqKey, targetModel };
|
|
615
|
+
} catch (err) {
|
|
616
|
+
console.warn("[LLM Gateway Router] Error resolving user gateway_config:", err.message);
|
|
617
|
+
return {};
|
|
618
|
+
}
|
|
619
|
+
}
|
|
594
620
|
async function dispatchChatCompletion(req, apiKeyOverride) {
|
|
595
|
-
const
|
|
596
|
-
const
|
|
597
|
-
|
|
621
|
+
const { customGroqKey, targetModel } = await resolveUserGatewayConfig(apiKeyOverride);
|
|
622
|
+
const effectiveKey = customGroqKey || cleanApiKeyOverride(apiKeyOverride);
|
|
623
|
+
const activeModel = req.model || targetModel || "llama-3.1-8b-instant";
|
|
624
|
+
const provider = resolveProvider(activeModel);
|
|
625
|
+
console.log(`[LLM Gateway Router] Dispatching chat request: model=${activeModel}, provider=${provider}, hasCustomKey=${Boolean(customGroqKey)}, hasGlobalGroqKey=${Boolean(process.env.GROQ_API_KEY)}`);
|
|
598
626
|
try {
|
|
599
627
|
switch (provider) {
|
|
600
628
|
case "groq":
|
|
601
|
-
return await handleGroqRequest(req, effectiveKey);
|
|
629
|
+
return await handleGroqRequest(__spreadProps(__spreadValues({}, req), { model: activeModel }), effectiveKey);
|
|
602
630
|
case "openai":
|
|
603
|
-
return await handleOpenAIRequest(req, effectiveKey);
|
|
631
|
+
return await handleOpenAIRequest(__spreadProps(__spreadValues({}, req), { model: activeModel }), effectiveKey);
|
|
604
632
|
case "gemini":
|
|
605
|
-
return await handleGeminiRequest(req, effectiveKey);
|
|
633
|
+
return await handleGeminiRequest(__spreadProps(__spreadValues({}, req), { model: activeModel }), effectiveKey);
|
|
606
634
|
case "anthropic":
|
|
607
|
-
return await handleAnthropicRequest(req, effectiveKey);
|
|
635
|
+
return await handleAnthropicRequest(__spreadProps(__spreadValues({}, req), { model: activeModel }), effectiveKey);
|
|
608
636
|
case "ollama":
|
|
609
|
-
return await handleOllamaRequest(req);
|
|
637
|
+
return await handleOllamaRequest(__spreadProps(__spreadValues({}, req), { model: activeModel }));
|
|
610
638
|
case "huggingface":
|
|
611
|
-
return await handleHuggingFaceChatRequest(req, effectiveKey);
|
|
639
|
+
return await handleHuggingFaceChatRequest(__spreadProps(__spreadValues({}, req), { model: activeModel }), effectiveKey);
|
|
612
640
|
default:
|
|
613
|
-
throw new Error(`Unsupported LLM provider for model: ${
|
|
641
|
+
throw new Error(`Unsupported LLM provider for model: ${activeModel}`);
|
|
614
642
|
}
|
|
615
643
|
} catch (error) {
|
|
616
644
|
console.error(`[LLM Gateway Router] Provider '${provider}' failed for model '${req.model}':`, {
|
|
@@ -2731,6 +2759,7 @@ __export(server_exports, {
|
|
|
2731
2759
|
Rule6SmallResultSetRule: () => Rule6SmallResultSetRule,
|
|
2732
2760
|
Rule7LargeTableRule: () => Rule7LargeTableRule,
|
|
2733
2761
|
RuleEngine: () => RuleEngine,
|
|
2762
|
+
SDK_VERSION: () => SDK_VERSION,
|
|
2734
2763
|
TableRendererStrategy: () => TableRendererStrategy,
|
|
2735
2764
|
TextRendererStrategy: () => TextRendererStrategy,
|
|
2736
2765
|
UniversalLLMAdapter: () => UniversalLLMAdapter,
|
|
@@ -3113,7 +3142,7 @@ function getRagConfig(baseConfig, env = process.env) {
|
|
|
3113
3142
|
return getEnvConfig(env, baseConfig);
|
|
3114
3143
|
}
|
|
3115
3144
|
function getEnvConfig(env = process.env, base) {
|
|
3116
|
-
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, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __, _$, _aa, _ba, _ca, _da, _ea, _fa, _ga, _ha, _ia, _ja, _ka, _la, _ma, _na, _oa, _pa, _qa, _ra, _sa, _ta, _ua, _va, _wa, _xa, _ya, _za, _Aa, _Ba, _Ca, _Da, _Ea, _Fa, _Ga, _Ha, _Ia, _Ja, _Ka, _La, _Ma, _Na, _Oa, _Pa, _Qa, _Ra, _Sa, _Ta, _Ua, _Va, _Wa, _Xa, _Ya, _Za, __a, _$a, _ab, _bb, _cb, _db, _eb, _fb, _gb, _hb, _ib, _jb, _kb, _lb, _mb, _nb, _ob, _pb, _qb, _rb, _sb, _tb, _ub, _vb, _wb;
|
|
3145
|
+
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, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __, _$, _aa, _ba, _ca, _da, _ea, _fa, _ga, _ha, _ia, _ja, _ka, _la, _ma, _na, _oa, _pa, _qa, _ra, _sa, _ta, _ua, _va, _wa, _xa, _ya, _za, _Aa, _Ba, _Ca, _Da, _Ea, _Fa, _Ga, _Ha, _Ia, _Ja, _Ka, _La, _Ma, _Na, _Oa, _Pa, _Qa, _Ra, _Sa, _Ta, _Ua, _Va, _Wa, _Xa, _Ya, _Za, __a, _$a, _ab, _bb, _cb, _db, _eb, _fb, _gb, _hb, _ib, _jb, _kb, _lb, _mb, _nb, _ob, _pb, _qb, _rb, _sb, _tb, _ub, _vb, _wb, _xb, _yb, _zb, _Ab, _Bb, _Cb, _Db, _Eb, _Fb, _Gb, _Hb, _Ib;
|
|
3117
3146
|
const projectId = (_c = (_b = (_a2 = readString(env, "RAG_PROJECT_ID")) != null ? _a2 : readString(env, "NEXT_PUBLIC_PROJECT_ID")) != null ? _b : base == null ? void 0 : base.projectId) != null ? _c : "__default__";
|
|
3118
3147
|
const licenseKey = (_g2 = (_f = (_e = (_d = readString(env, "RAG_LICENSE_KEY")) != null ? _d : readString(env, "RETRIVORA_LICENSE_KEY")) != null ? _e : readString(env, "NEXT_PUBLIC_RETRIVORA_LICENSE_KEY")) != null ? _f : readString(env, "LICENSE_KEY")) != null ? _g2 : base == null ? void 0 : base.licenseKey;
|
|
3119
3148
|
const telemetryEnabled = readString(env, "TELEMETRY_ENABLED") === "true" || readString(env, "NEXT_PUBLIC_TELEMETRY_ENABLED") === "true" || ((_h = base == null ? void 0 : base.telemetry) == null ? void 0 : _h.enabled) || Boolean(licenseKey);
|
|
@@ -3121,38 +3150,38 @@ function getEnvConfig(env = process.env, base) {
|
|
|
3121
3150
|
const embeddingDimensions = readNumber(env, "EMBEDDING_DIMENSIONS", 768);
|
|
3122
3151
|
const vectorDbOptions = {};
|
|
3123
3152
|
if (vectorProvider === "pinecone") {
|
|
3124
|
-
vectorDbOptions.apiKey = (_l = (_k = readString(env, "PINECONE_API_KEY")) != null ? _k : (_j = (_i = base == null ? void 0 : base.vectorDb) == null ? void 0 : _i.options) == null ? void 0 : _j.apiKey) != null ? _l : "";
|
|
3125
|
-
vectorDbOptions.indexName = (
|
|
3153
|
+
vectorDbOptions.apiKey = (_m = (_l = (_k = readString(env, "PINECONE_API_KEY")) != null ? _k : (_j = (_i = base == null ? void 0 : base.vectorDb) == null ? void 0 : _i.options) == null ? void 0 : _j.apiKey) != null ? _l : process.env.PINECONE_API_KEY) != null ? _m : "";
|
|
3154
|
+
vectorDbOptions.indexName = (_t = (_s = (_r = (_o = readString(env, "PINECONE_INDEX")) != null ? _o : (_n = base == null ? void 0 : base.vectorDb) == null ? void 0 : _n.indexName) != null ? _r : (_q = (_p = base == null ? void 0 : base.vectorDb) == null ? void 0 : _p.options) == null ? void 0 : _q.indexName) != null ? _s : process.env.PINECONE_INDEX) != null ? _t : "retrivora-free";
|
|
3126
3155
|
} else if (vectorProvider === "pgvector" || vectorProvider === "postgresql") {
|
|
3127
|
-
vectorDbOptions.connectionString = (
|
|
3128
|
-
vectorDbOptions.tables = (
|
|
3129
|
-
vectorDbOptions.searchFields = (
|
|
3156
|
+
vectorDbOptions.connectionString = (_y = (_x = (_u = readString(env, "PGVECTOR_CONNECTION_STRING")) != null ? _u : readString(env, "POSTGRES_URL")) != null ? _x : (_w = (_v = base == null ? void 0 : base.vectorDb) == null ? void 0 : _v.options) == null ? void 0 : _w.connectionString) != null ? _y : "";
|
|
3157
|
+
vectorDbOptions.tables = (_D = (_A = (_z = readString(env, "VECTOR_DB_TABLES")) != null ? _z : readString(env, "POSTGRES_TABLES")) == null ? void 0 : _A.split(",").map((t) => t.trim())) != null ? _D : (_C = (_B = base == null ? void 0 : base.vectorDb) == null ? void 0 : _B.options) == null ? void 0 : _C.tables;
|
|
3158
|
+
vectorDbOptions.searchFields = (_H = (_E = readString(env, "POSTGRES_SEARCH_FIELDS")) == null ? void 0 : _E.split(",").map((f) => f.trim())) != null ? _H : (_G = (_F = base == null ? void 0 : base.vectorDb) == null ? void 0 : _F.options) == null ? void 0 : _G.searchFields;
|
|
3130
3159
|
vectorDbOptions.dimensions = embeddingDimensions;
|
|
3131
3160
|
} else if (vectorProvider === "mongodb") {
|
|
3132
|
-
vectorDbOptions.uri = (
|
|
3133
|
-
vectorDbOptions.database = (
|
|
3134
|
-
vectorDbOptions.collection = (
|
|
3135
|
-
vectorDbOptions.indexName = (
|
|
3161
|
+
vectorDbOptions.uri = (_L = (_K = readString(env, "MONGODB_URI")) != null ? _K : (_J = (_I = base == null ? void 0 : base.vectorDb) == null ? void 0 : _I.options) == null ? void 0 : _J.uri) != null ? _L : "";
|
|
3162
|
+
vectorDbOptions.database = (_P = (_O = readString(env, "MONGODB_DB")) != null ? _O : (_N = (_M = base == null ? void 0 : base.vectorDb) == null ? void 0 : _M.options) == null ? void 0 : _N.database) != null ? _P : "";
|
|
3163
|
+
vectorDbOptions.collection = (_T = (_S = readString(env, "MONGODB_COLLECTION")) != null ? _S : (_R = (_Q = base == null ? void 0 : base.vectorDb) == null ? void 0 : _Q.options) == null ? void 0 : _R.collection) != null ? _T : "";
|
|
3164
|
+
vectorDbOptions.indexName = (_Z = (_Y = (_V = readString(env, "MONGODB_INDEX_NAME")) != null ? _V : (_U = base == null ? void 0 : base.vectorDb) == null ? void 0 : _U.indexName) != null ? _Y : (_X = (_W = base == null ? void 0 : base.vectorDb) == null ? void 0 : _W.options) == null ? void 0 : _X.indexName) != null ? _Z : "vector_index";
|
|
3136
3165
|
} else if (vectorProvider === "qdrant") {
|
|
3137
|
-
vectorDbOptions.baseUrl = (
|
|
3138
|
-
vectorDbOptions.apiKey = (
|
|
3166
|
+
vectorDbOptions.baseUrl = (_ba = (_aa = readString(env, "QDRANT_URL")) != null ? _aa : (_$ = (__ = base == null ? void 0 : base.vectorDb) == null ? void 0 : __.options) == null ? void 0 : _$.baseUrl) != null ? _ba : "http://localhost:6333";
|
|
3167
|
+
vectorDbOptions.apiKey = (_ea = readString(env, "QDRANT_API_KEY")) != null ? _ea : (_da = (_ca = base == null ? void 0 : base.vectorDb) == null ? void 0 : _ca.options) == null ? void 0 : _da.apiKey;
|
|
3139
3168
|
vectorDbOptions.dimensions = embeddingDimensions;
|
|
3140
3169
|
} else if (vectorProvider === "milvus") {
|
|
3141
|
-
vectorDbOptions.baseUrl = (
|
|
3170
|
+
vectorDbOptions.baseUrl = (_fa = readString(env, "MILVUS_URL")) != null ? _fa : "http://localhost:19530";
|
|
3142
3171
|
vectorDbOptions.apiKey = readString(env, "MILVUS_API_KEY");
|
|
3143
3172
|
} else if (vectorProvider === "chromadb") {
|
|
3144
|
-
vectorDbOptions.baseUrl = (
|
|
3173
|
+
vectorDbOptions.baseUrl = (_ga = readString(env, "CHROMADB_URL")) != null ? _ga : "http://localhost:8000";
|
|
3145
3174
|
} else if (vectorProvider === "weaviate") {
|
|
3146
|
-
vectorDbOptions.baseUrl = (
|
|
3175
|
+
vectorDbOptions.baseUrl = (_ha = readString(env, "WEAVIATE_URL")) != null ? _ha : "http://localhost:8080";
|
|
3147
3176
|
vectorDbOptions.apiKey = readString(env, "WEAVIATE_API_KEY");
|
|
3148
3177
|
} else if (vectorProvider === "redis") {
|
|
3149
|
-
vectorDbOptions.baseUrl = (
|
|
3178
|
+
vectorDbOptions.baseUrl = (_ia = readString(env, "REDIS_URL")) != null ? _ia : "";
|
|
3150
3179
|
vectorDbOptions.apiKey = readString(env, "REDIS_API_KEY");
|
|
3151
3180
|
} else if (vectorProvider === "rest") {
|
|
3152
|
-
vectorDbOptions.baseUrl = (
|
|
3181
|
+
vectorDbOptions.baseUrl = (_ja = readString(env, "VECTOR_DB_REST_URL")) != null ? _ja : "";
|
|
3153
3182
|
vectorDbOptions.headers = readString(env, "VECTOR_DB_REST_API_KEY") ? { "api-key": readString(env, "VECTOR_DB_REST_API_KEY") } : {};
|
|
3154
3183
|
} else if (vectorProvider === "universal_rest") {
|
|
3155
|
-
vectorDbOptions.baseUrl = (
|
|
3184
|
+
vectorDbOptions.baseUrl = (_la = (_ka = readString(env, "VECTOR_BASE_URL")) != null ? _ka : readString(env, "VECTOR_DB_REST_URL")) != null ? _la : "";
|
|
3156
3185
|
vectorDbOptions.profile = readString(env, "VECTOR_UNIVERSAL_PROFILE");
|
|
3157
3186
|
vectorDbOptions.headers = readString(env, "VECTOR_DB_REST_API_KEY") ? { Authorization: `Bearer ${readString(env, "VECTOR_DB_REST_API_KEY")}` } : {};
|
|
3158
3187
|
}
|
|
@@ -3171,8 +3200,8 @@ function getEnvConfig(env = process.env, base) {
|
|
|
3171
3200
|
// Anthropic needs a separate embedding provider; key kept for completeness
|
|
3172
3201
|
gemini: readString(env, "GEMINI_API_KEY"),
|
|
3173
3202
|
ollama: void 0,
|
|
3174
|
-
universal_rest: (
|
|
3175
|
-
custom: (
|
|
3203
|
+
universal_rest: (_ma = readString(env, "EMBEDDING_API_KEY")) != null ? _ma : readString(env, "OPENAI_API_KEY"),
|
|
3204
|
+
custom: (_na = readString(env, "EMBEDDING_API_KEY")) != null ? _na : readString(env, "OPENAI_API_KEY")
|
|
3176
3205
|
};
|
|
3177
3206
|
const DEFAULT_MODEL_BY_PROVIDER = {
|
|
3178
3207
|
openai: "gpt-4o",
|
|
@@ -3193,25 +3222,25 @@ function getEnvConfig(env = process.env, base) {
|
|
|
3193
3222
|
return true;
|
|
3194
3223
|
}
|
|
3195
3224
|
})();
|
|
3196
|
-
const
|
|
3225
|
+
const defaultGatewayUrl = (_pa = (_oa = readString(env, "LITELLM_BASE_URL")) != null ? _oa : readString(env, "LLM_BASE_URL")) != null ? _pa : "https://llm.retrivora.com/api/v1";
|
|
3197
3226
|
const defaultLlmProvider = isFreeTier ? "universal_rest" : "universal_rest";
|
|
3198
|
-
const llmProvider = (
|
|
3199
|
-
const llmBaseUrl = (
|
|
3200
|
-
const llmModel = (
|
|
3201
|
-
const llmApiKey = (
|
|
3202
|
-
const llmProfile = (
|
|
3227
|
+
const llmProvider = (_sa = (_ra = readEnum(env, "LLM_PROVIDER", defaultLlmProvider, LLM_PROVIDERS)) != null ? _ra : (_qa = base == null ? void 0 : base.llm) == null ? void 0 : _qa.provider) != null ? _sa : defaultLlmProvider;
|
|
3228
|
+
const llmBaseUrl = (_wa = (_va = (_ta = readString(env, "LITELLM_BASE_URL")) != null ? _ta : readString(env, "LLM_BASE_URL")) != null ? _va : (_ua = base == null ? void 0 : base.llm) == null ? void 0 : _ua.baseUrl) != null ? _wa : defaultGatewayUrl;
|
|
3229
|
+
const llmModel = (_Aa = (_ya = readString(env, "LLM_MODEL")) != null ? _ya : (_xa = base == null ? void 0 : base.llm) == null ? void 0 : _xa.model) != null ? _Aa : isFreeTier ? "llama-3.1-8b-instant" : (_za = DEFAULT_MODEL_BY_PROVIDER[llmProvider]) != null ? _za : "gpt-4o";
|
|
3230
|
+
const llmApiKey = (_Ga = (_Fa = (_Da = (_Ca = (_Ba = llmApiKeyByProvider[llmProvider]) != null ? _Ba : readString(env, "LLM_API_KEY")) != null ? _Ca : readString(env, "LITELLM_MASTER_KEY")) != null ? _Da : readString(env, "LITELLM_API_KEY")) != null ? _Fa : (_Ea = base == null ? void 0 : base.llm) == null ? void 0 : _Ea.apiKey) != null ? _Ga : licenseKey;
|
|
3231
|
+
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";
|
|
3203
3232
|
const defaultEmbeddingProvider = isFreeTier ? "universal_rest" : "universal_rest";
|
|
3204
|
-
const embeddingProvider = (
|
|
3205
|
-
const embeddingBaseUrl = (
|
|
3206
|
-
const embeddingModel = (
|
|
3207
|
-
const embeddingApiKey = (
|
|
3208
|
-
const embeddingProfile = (
|
|
3233
|
+
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;
|
|
3234
|
+
const embeddingBaseUrl = (_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 : defaultGatewayUrl;
|
|
3235
|
+
const embeddingModel = (_Va = (_Ua = readString(env, "EMBEDDING_MODEL")) != null ? _Ua : (_Ta = base == null ? void 0 : base.embedding) == null ? void 0 : _Ta.model) != null ? _Va : "text-embedding-004";
|
|
3236
|
+
const embeddingApiKey = (_ab = (_$a = (_Za = (_Ya = (_Xa = (_Wa = embeddingApiKeyByProvider[embeddingProvider]) != null ? _Wa : readString(env, "EMBEDDING_API_KEY")) != null ? _Xa : readString(env, "LLM_API_KEY")) != null ? _Ya : readString(env, "LITELLM_MASTER_KEY")) != null ? _Za : readString(env, "LITELLM_API_KEY")) != null ? _$a : (__a = base == null ? void 0 : base.embedding) == null ? void 0 : __a.apiKey) != null ? _ab : licenseKey;
|
|
3237
|
+
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";
|
|
3209
3238
|
return __spreadProps(__spreadValues({
|
|
3210
3239
|
projectId,
|
|
3211
3240
|
licenseKey,
|
|
3212
3241
|
vectorDb: {
|
|
3213
3242
|
provider: vectorProvider,
|
|
3214
|
-
indexName: (
|
|
3243
|
+
indexName: (_gb = (_fb = readString(env, "VECTOR_DB_INDEX")) != null ? _fb : vectorDbOptions.indexName) != null ? _gb : "rag-index",
|
|
3215
3244
|
options: vectorDbOptions
|
|
3216
3245
|
},
|
|
3217
3246
|
llm: {
|
|
@@ -3241,30 +3270,30 @@ function getEnvConfig(env = process.env, base) {
|
|
|
3241
3270
|
}
|
|
3242
3271
|
},
|
|
3243
3272
|
ui: {
|
|
3244
|
-
title: (
|
|
3245
|
-
subtitle: (
|
|
3246
|
-
primaryColor: (
|
|
3247
|
-
accentColor: (
|
|
3248
|
-
logoUrl: (
|
|
3249
|
-
placeholder: (
|
|
3250
|
-
showSources: ((
|
|
3251
|
-
welcomeMessage: (
|
|
3252
|
-
visualStyle: (
|
|
3253
|
-
borderRadius: (
|
|
3254
|
-
allowUpload: ((
|
|
3273
|
+
title: (_ib = (_hb = readString(env, "NEXT_PUBLIC_UI_TITLE")) != null ? _hb : readString(env, "UI_TITLE")) != null ? _ib : "AI Assistant",
|
|
3274
|
+
subtitle: (_kb = (_jb = readString(env, "NEXT_PUBLIC_UI_SUBTITLE")) != null ? _jb : readString(env, "UI_SUBTITLE")) != null ? _kb : "Powered by RAG",
|
|
3275
|
+
primaryColor: (_mb = (_lb = readString(env, "NEXT_PUBLIC_PRIMARY_COLOR")) != null ? _lb : readString(env, "UI_PRIMARY_COLOR")) != null ? _mb : "#10b981",
|
|
3276
|
+
accentColor: (_ob = (_nb = readString(env, "NEXT_PUBLIC_ACCENT_COLOR")) != null ? _nb : readString(env, "UI_ACCENT_COLOR")) != null ? _ob : "#3b82f6",
|
|
3277
|
+
logoUrl: (_pb = readString(env, "NEXT_PUBLIC_LOGO_URL")) != null ? _pb : readString(env, "UI_LOGO_URL"),
|
|
3278
|
+
placeholder: (_rb = (_qb = readString(env, "NEXT_PUBLIC_PLACEHOLDER")) != null ? _qb : readString(env, "UI_PLACEHOLDER")) != null ? _rb : "Ask me anything\u2026",
|
|
3279
|
+
showSources: ((_tb = (_sb = readString(env, "NEXT_PUBLIC_SHOW_SOURCES")) != null ? _sb : readString(env, "UI_SHOW_SOURCES")) != null ? _tb : "true") !== "false",
|
|
3280
|
+
welcomeMessage: (_vb = (_ub = readString(env, "NEXT_PUBLIC_WELCOME_MESSAGE")) != null ? _ub : readString(env, "UI_WELCOME_MESSAGE")) != null ? _vb : "Hello! I'm your AI assistant. Ask me anything about your documents.",
|
|
3281
|
+
visualStyle: (_xb = (_wb = readString(env, "NEXT_PUBLIC_UI_VISUAL_STYLE")) != null ? _wb : readString(env, "UI_VISUAL_STYLE")) != null ? _xb : "glass",
|
|
3282
|
+
borderRadius: (_zb = (_yb = readString(env, "NEXT_PUBLIC_UI_BORDER_RADIUS")) != null ? _yb : readString(env, "UI_BORDER_RADIUS")) != null ? _zb : "xl",
|
|
3283
|
+
allowUpload: ((_Bb = (_Ab = readString(env, "NEXT_PUBLIC_ALLOW_UPLOAD")) != null ? _Ab : readString(env, "UI_ALLOW_UPLOAD")) != null ? _Bb : "false") === "true"
|
|
3255
3284
|
},
|
|
3256
3285
|
rag: {
|
|
3257
3286
|
topK: readNumber(env, "RAG_TOP_K", 5),
|
|
3258
3287
|
scoreThreshold: readNumber(env, "RAG_SCORE_THRESHOLD", 0),
|
|
3259
3288
|
chunkSize: readNumber(env, "RAG_CHUNK_SIZE", 1e3),
|
|
3260
3289
|
chunkOverlap: readNumber(env, "RAG_CHUNK_OVERLAP", 200),
|
|
3261
|
-
filterableFields: (
|
|
3290
|
+
filterableFields: (_Cb = readString(env, "RAG_FILTERABLE_FIELDS")) == null ? void 0 : _Cb.split(",").map((f) => f.trim()),
|
|
3262
3291
|
// Query pipeline toggles — read from .env.local
|
|
3263
3292
|
useQueryTransformation: readString(env, "RAG_USE_QUERY_TRANSFORMATION") === "true",
|
|
3264
3293
|
useReranking: readString(env, "RAG_USE_RERANKING") === "true",
|
|
3265
3294
|
useGraphRetrieval: readString(env, "RAG_USE_GRAPH_RETRIEVAL") === "true",
|
|
3266
|
-
architecture: (
|
|
3267
|
-
chunkingStrategy: (
|
|
3295
|
+
architecture: (_Db = readString(env, "RAG_ARCHITECTURE")) != null ? _Db : "simple",
|
|
3296
|
+
chunkingStrategy: (_Eb = readString(env, "RAG_CHUNKING_STRATEGY")) != null ? _Eb : "recursive",
|
|
3268
3297
|
uiMapping: (() => {
|
|
3269
3298
|
const raw = readString(env, "RAG_UI_MAPPING");
|
|
3270
3299
|
if (!raw) return void 0;
|
|
@@ -3277,7 +3306,7 @@ function getEnvConfig(env = process.env, base) {
|
|
|
3277
3306
|
},
|
|
3278
3307
|
telemetry: {
|
|
3279
3308
|
enabled: telemetryEnabled,
|
|
3280
|
-
url: (
|
|
3309
|
+
url: (_Ib = (_Hb = (_Fb = readString(env, "TELEMETRY_URL")) != null ? _Fb : readString(env, "NEXT_PUBLIC_TELEMETRY_URL")) != null ? _Hb : (_Gb = base == null ? void 0 : base.telemetry) == null ? void 0 : _Gb.url) != null ? _Ib : process.env.NODE_ENV === "development" ? "http://localhost:3001/api/telemetry" : "https://retrivora.com/api/telemetry"
|
|
3281
3310
|
}
|
|
3282
3311
|
}, readString(env, "GRAPH_DB_PROVIDER") ? {
|
|
3283
3312
|
graphDb: {
|
|
@@ -5316,6 +5345,147 @@ var ConfigValidator = class {
|
|
|
5316
5345
|
}
|
|
5317
5346
|
};
|
|
5318
5347
|
|
|
5348
|
+
// package.json
|
|
5349
|
+
var package_default = {
|
|
5350
|
+
name: "@retrivora-ai/rag-engine",
|
|
5351
|
+
version: "2.1.4",
|
|
5352
|
+
description: "Retrivora AI is a plug-and-play AI engine for RAG chat experiences \u2014 generic vector DB + LLM provider, embeddable or standalone.",
|
|
5353
|
+
author: "Abhinav Alkuchi",
|
|
5354
|
+
license: "UNLICENSED",
|
|
5355
|
+
keywords: [
|
|
5356
|
+
"rag",
|
|
5357
|
+
"retrieval-augmented-generation",
|
|
5358
|
+
"chatbot",
|
|
5359
|
+
"vector-database",
|
|
5360
|
+
"pinecone",
|
|
5361
|
+
"pgvector",
|
|
5362
|
+
"postgresql",
|
|
5363
|
+
"milvus",
|
|
5364
|
+
"qdrant",
|
|
5365
|
+
"chromadb",
|
|
5366
|
+
"redis",
|
|
5367
|
+
"weaviate",
|
|
5368
|
+
"mongodb",
|
|
5369
|
+
"openai",
|
|
5370
|
+
"anthropic",
|
|
5371
|
+
"ollama",
|
|
5372
|
+
"nextjs",
|
|
5373
|
+
"react",
|
|
5374
|
+
"ai",
|
|
5375
|
+
"llm",
|
|
5376
|
+
"embeddings"
|
|
5377
|
+
],
|
|
5378
|
+
main: "dist/index.js",
|
|
5379
|
+
module: "dist/index.mjs",
|
|
5380
|
+
types: "dist/index.d.ts",
|
|
5381
|
+
exports: {
|
|
5382
|
+
".": {
|
|
5383
|
+
types: "./dist/index.d.ts",
|
|
5384
|
+
require: "./dist/index.js",
|
|
5385
|
+
import: "./dist/index.mjs"
|
|
5386
|
+
},
|
|
5387
|
+
"./style.css": "./dist/index.css",
|
|
5388
|
+
"./handlers": {
|
|
5389
|
+
types: "./dist/handlers/index.d.ts",
|
|
5390
|
+
require: "./dist/handlers/index.js",
|
|
5391
|
+
import: "./dist/handlers/index.mjs"
|
|
5392
|
+
},
|
|
5393
|
+
"./server": {
|
|
5394
|
+
types: "./dist/server.d.ts",
|
|
5395
|
+
require: "./dist/server.js",
|
|
5396
|
+
import: "./dist/server.mjs"
|
|
5397
|
+
}
|
|
5398
|
+
},
|
|
5399
|
+
browser: {
|
|
5400
|
+
child_process: false,
|
|
5401
|
+
fs: false,
|
|
5402
|
+
net: false,
|
|
5403
|
+
tls: false,
|
|
5404
|
+
crypto: false,
|
|
5405
|
+
os: false,
|
|
5406
|
+
path: false,
|
|
5407
|
+
stream: false,
|
|
5408
|
+
http: false,
|
|
5409
|
+
https: false,
|
|
5410
|
+
zlib: false,
|
|
5411
|
+
mongodb: false,
|
|
5412
|
+
pg: false,
|
|
5413
|
+
"pdf-parse": false,
|
|
5414
|
+
mammoth: false
|
|
5415
|
+
},
|
|
5416
|
+
files: [
|
|
5417
|
+
"dist",
|
|
5418
|
+
"src",
|
|
5419
|
+
".env.example",
|
|
5420
|
+
"README.md",
|
|
5421
|
+
"FREE_TIER_ARCHITECTURE.md"
|
|
5422
|
+
],
|
|
5423
|
+
scripts: {
|
|
5424
|
+
dev: "npx @tailwindcss/cli -i src/tailwind.css -o src/index.css && tsup src/index.ts src/handlers/index.ts src/server.ts --format cjs,esm --watch --tsconfig tsconfig.build.json --external react,react-dom,next,mongodb,pg,openai,@anthropic-ai/sdk,@pinecone-database/pinecone,axios,lucide-react,mammoth,pdf-parse,xlsx,react-markdown,remark-gfm,next-themes,langchain,@langchain/core,@langchain/openai,llamaindex --inject-style",
|
|
5425
|
+
build: "npm run build:pkg",
|
|
5426
|
+
"build:pkg": "npx @tailwindcss/cli -i src/tailwind.css -o src/index.css && tsup src/index.ts src/handlers/index.ts src/server.ts --format cjs,esm --dts --clean --no-splitting --tsconfig tsconfig.build.json --external react,react-dom,next,mongodb,pg,openai,@anthropic-ai/sdk,@pinecone-database/pinecone,axios,lucide-react,mammoth,pdf-parse,xlsx,react-markdown,remark-gfm,next-themes,langchain,@langchain/core,@langchain/openai,llamaindex --inject-style && npx @tailwindcss/cli -i src/tailwind.css -o dist/index.css",
|
|
5427
|
+
lint: "eslint",
|
|
5428
|
+
clean: "rm -rf dist"
|
|
5429
|
+
},
|
|
5430
|
+
peerDependencies: {
|
|
5431
|
+
next: ">=15.0.0",
|
|
5432
|
+
react: ">=18.0.0",
|
|
5433
|
+
"react-dom": ">=18.0.0"
|
|
5434
|
+
},
|
|
5435
|
+
peerDependenciesMeta: {
|
|
5436
|
+
next: {
|
|
5437
|
+
optional: true
|
|
5438
|
+
}
|
|
5439
|
+
},
|
|
5440
|
+
dependencies: {
|
|
5441
|
+
"@anthropic-ai/sdk": "^0.95.1",
|
|
5442
|
+
"@google/genai": "^0.8.0",
|
|
5443
|
+
"@google/generative-ai": "^0.24.1",
|
|
5444
|
+
"@pinecone-database/pinecone": "^7.2.0",
|
|
5445
|
+
"@types/papaparse": "^5.5.2",
|
|
5446
|
+
axios: "^1.15.0",
|
|
5447
|
+
"lucide-react": "^1.8.0",
|
|
5448
|
+
"next-themes": "^0.4.6",
|
|
5449
|
+
openai: "^6.34.0",
|
|
5450
|
+
papaparse: "^5.5.3",
|
|
5451
|
+
"react-is": "^18.3.1",
|
|
5452
|
+
"react-markdown": "^10.1.0",
|
|
5453
|
+
recharts: "^3.8.1",
|
|
5454
|
+
"remark-gfm": "^4.0.1",
|
|
5455
|
+
xlsx: "^0.18.5"
|
|
5456
|
+
},
|
|
5457
|
+
optionalDependencies: {
|
|
5458
|
+
"@langchain/core": "^1.1.42",
|
|
5459
|
+
"@langchain/openai": "^1.4.5",
|
|
5460
|
+
langchain: "^1.3.5",
|
|
5461
|
+
llamaindex: "^0.11.9",
|
|
5462
|
+
mammoth: "^1.8.0",
|
|
5463
|
+
mongodb: "^7.1.1",
|
|
5464
|
+
"pdf-parse": "^1.1.1",
|
|
5465
|
+
pg: "^8.20.0"
|
|
5466
|
+
},
|
|
5467
|
+
devDependencies: {
|
|
5468
|
+
"@tailwindcss/cli": "^4",
|
|
5469
|
+
"@tailwindcss/postcss": "^4",
|
|
5470
|
+
"@types/estree": "^1.0.9",
|
|
5471
|
+
"@types/node": "^20",
|
|
5472
|
+
"@types/pdf-parse": "^1.1.5",
|
|
5473
|
+
"@types/pg": "^8.20.0",
|
|
5474
|
+
"@types/react": "^19.2.14",
|
|
5475
|
+
"@types/react-dom": "^19.2.3",
|
|
5476
|
+
dotenv: "^17.4.2",
|
|
5477
|
+
eslint: "^9",
|
|
5478
|
+
"eslint-config-next": "16.2.4",
|
|
5479
|
+
next: "16.2.10",
|
|
5480
|
+
tailwindcss: "^4",
|
|
5481
|
+
tsup: "^8.5.1",
|
|
5482
|
+
typescript: "^5"
|
|
5483
|
+
}
|
|
5484
|
+
};
|
|
5485
|
+
|
|
5486
|
+
// src/version.ts
|
|
5487
|
+
var SDK_VERSION = package_default.version || "2.1.3";
|
|
5488
|
+
|
|
5319
5489
|
// src/rag/DocumentChunker.ts
|
|
5320
5490
|
var DocumentChunker = class {
|
|
5321
5491
|
constructor(chunkSize = 1e3, chunkOverlap = 200, separators = ["\n# ", "\n## ", "\n### ", "\n#### ", "\n\n", "\n", " ", ""]) {
|
|
@@ -9599,6 +9769,7 @@ ${context}`;
|
|
|
9599
9769
|
const telemetryUrl = ((_B = this.config.telemetry) == null ? void 0 : _B.url) || process.env.TELEMETRY_URL || process.env.NEXT_PUBLIC_TELEMETRY_URL || defaultUrl;
|
|
9600
9770
|
const absoluteUrl = telemetryUrl.startsWith("http") ? telemetryUrl : (process.env.NEXT_PUBLIC_APP_URL || `http://localhost:${process.env.PORT || 3e3}`) + telemetryUrl;
|
|
9601
9771
|
(async () => {
|
|
9772
|
+
var _a3, _b2, _c2, _d2, _e2;
|
|
9602
9773
|
try {
|
|
9603
9774
|
let finalTrace = trace;
|
|
9604
9775
|
if (!awaitHallucination && runHallucination) {
|
|
@@ -9607,6 +9778,12 @@ ${context}`;
|
|
|
9607
9778
|
finalTrace = buildTrace(backgroundScoreResult);
|
|
9608
9779
|
}
|
|
9609
9780
|
}
|
|
9781
|
+
const modelName = (finalTrace == null ? void 0 : finalTrace.model) || ((_a3 = this.config.llm) == null ? void 0 : _a3.model) || "llama-3.1-8b-instant";
|
|
9782
|
+
const providerName = (finalTrace == null ? void 0 : finalTrace.provider) || ((_b2 = this.config.llm) == null ? void 0 : _b2.provider) || "groq";
|
|
9783
|
+
const tokenCount = Number(((_c2 = finalTrace == null ? void 0 : finalTrace.tokens) == null ? void 0 : _c2.totalTokens) || 0);
|
|
9784
|
+
const costEst = Number(((_d2 = finalTrace == null ? void 0 : finalTrace.tokens) == null ? void 0 : _d2.estimatedCostUsd) || 0);
|
|
9785
|
+
const latencyDuration = Number(((_e2 = finalTrace == null ? void 0 : finalTrace.latency) == null ? void 0 : _e2.totalMs) || 0);
|
|
9786
|
+
console.log(`[Retrivora Pipeline Telemetry] \u{1F4CA} Dispatching RAG telemetry -> Project: "${ns}", Model: "${providerName}/${modelName}", Tokens: ${tokenCount}, Latency: ${latencyDuration}ms`);
|
|
9610
9787
|
await fetch(absoluteUrl, {
|
|
9611
9788
|
method: "POST",
|
|
9612
9789
|
headers: {
|
|
@@ -9615,7 +9792,20 @@ ${context}`;
|
|
|
9615
9792
|
body: JSON.stringify({
|
|
9616
9793
|
trace: finalTrace,
|
|
9617
9794
|
licenseKey: this.config.licenseKey,
|
|
9618
|
-
projectId: ns
|
|
9795
|
+
projectId: ns,
|
|
9796
|
+
organization: process.env.RETRIVORA_ORGANIZATION || "default-org",
|
|
9797
|
+
sdkVersion: SDK_VERSION,
|
|
9798
|
+
model: modelName,
|
|
9799
|
+
provider: providerName,
|
|
9800
|
+
tokens: tokenCount,
|
|
9801
|
+
cost: costEst,
|
|
9802
|
+
costUsd: costEst,
|
|
9803
|
+
latencyMs: latencyDuration,
|
|
9804
|
+
status: "success",
|
|
9805
|
+
action: "RAG_QUERY",
|
|
9806
|
+
feature: "RAG",
|
|
9807
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
9808
|
+
details: `Org: default-org | Model: ${providerName}/${modelName} | Tokens: ${tokenCount} | Latency: ${latencyDuration}ms | Cost: $${costEst} | SDK: v${SDK_VERSION} | Feature: RAG`
|
|
9619
9809
|
})
|
|
9620
9810
|
});
|
|
9621
9811
|
} catch (err) {
|
|
@@ -11011,7 +11201,7 @@ function getOrCreatePlugin(configOrPlugin) {
|
|
|
11011
11201
|
return _g[cacheKey];
|
|
11012
11202
|
}
|
|
11013
11203
|
function reportTelemetry(req, plugin, action, status, details, trace) {
|
|
11014
|
-
var _a2;
|
|
11204
|
+
var _a2, _b, _c, _d, _e, _f, _g2, _h;
|
|
11015
11205
|
try {
|
|
11016
11206
|
const config = plugin.getConfig();
|
|
11017
11207
|
const licenseKey = config.licenseKey || process.env.RAG_LICENSE_KEY || process.env.RETRIVORA_LICENSE_KEY || process.env.NEXT_PUBLIC_RETRIVORA_LICENSE_KEY;
|
|
@@ -11020,29 +11210,49 @@ function reportTelemetry(req, plugin, action, status, details, trace) {
|
|
|
11020
11210
|
const defaultUrl = process.env.NODE_ENV === "development" && !process.env.TELEMETRY_URL && !process.env.NEXT_PUBLIC_TELEMETRY_URL ? "http://localhost:3001/api/telemetry" : "https://retrivora.com/api/telemetry";
|
|
11021
11211
|
const telemetryUrl = (telemetryConfig == null ? void 0 : telemetryConfig.url) || process.env.TELEMETRY_URL || process.env.NEXT_PUBLIC_TELEMETRY_URL || defaultUrl;
|
|
11022
11212
|
const host = req.headers.get("host") || "localhost";
|
|
11213
|
+
const userAgent = req.headers.get("user-agent") || `Retrivora-SDK/${SDK_VERSION}`;
|
|
11023
11214
|
let absoluteUrl = telemetryUrl;
|
|
11024
11215
|
if (!telemetryUrl.startsWith("http")) {
|
|
11025
11216
|
const proto = req.headers.get("x-forwarded-proto") || "http";
|
|
11026
11217
|
absoluteUrl = `${proto}://${host}${telemetryUrl}`;
|
|
11027
11218
|
}
|
|
11028
11219
|
const projectId = config.projectId || "default";
|
|
11220
|
+
const model = (trace == null ? void 0 : trace.model) || ((_b = config.llm) == null ? void 0 : _b.model) || ((_c = config.embedding) == null ? void 0 : _c.model) || "llama-3.1-8b-instant";
|
|
11221
|
+
const provider = (trace == null ? void 0 : trace.provider) || ((_d = config.llm) == null ? void 0 : _d.provider) || ((_e = config.embedding) == null ? void 0 : _e.provider) || "groq";
|
|
11222
|
+
const tokens = Number(((_f = trace == null ? void 0 : trace.tokens) == null ? void 0 : _f.totalTokens) || (trace == null ? void 0 : trace.totalTokens) || 0);
|
|
11223
|
+
const costUsd = Number(((_g2 = trace == null ? void 0 : trace.tokens) == null ? void 0 : _g2.estimatedCostUsd) || (trace == null ? void 0 : trace.costUsd) || 0);
|
|
11224
|
+
const latencyMs = Number(((_h = trace == null ? void 0 : trace.latency) == null ? void 0 : _h.totalMs) || (trace == null ? void 0 : trace.latencyMs) || 0);
|
|
11225
|
+
const payload = {
|
|
11226
|
+
trace,
|
|
11227
|
+
licenseKey,
|
|
11228
|
+
projectId,
|
|
11229
|
+
organization: process.env.RETRIVORA_ORGANIZATION || "default-org",
|
|
11230
|
+
sdkVersion: SDK_VERSION,
|
|
11231
|
+
model,
|
|
11232
|
+
provider,
|
|
11233
|
+
tokens,
|
|
11234
|
+
cost: costUsd,
|
|
11235
|
+
costUsd,
|
|
11236
|
+
latencyMs,
|
|
11237
|
+
status,
|
|
11238
|
+
action,
|
|
11239
|
+
feature: action,
|
|
11240
|
+
userAgent,
|
|
11241
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
11242
|
+
details
|
|
11243
|
+
};
|
|
11244
|
+
console.log(`[Retrivora SDK Telemetry] \u{1F4CA} Dispatching telemetry -> Feature: "${action}", Status: "${status}", Project: "${projectId}", Model: "${provider}/${model}", Latency: ${latencyMs}ms`);
|
|
11029
11245
|
fetch(absoluteUrl, {
|
|
11030
11246
|
method: "POST",
|
|
11031
11247
|
headers: {
|
|
11032
11248
|
"Content-Type": "application/json",
|
|
11033
11249
|
"x-forwarded-for": req.headers.get("x-forwarded-for") || "",
|
|
11034
|
-
"x-real-ip": req.headers.get("x-real-ip") || ""
|
|
11250
|
+
"x-real-ip": req.headers.get("x-real-ip") || "",
|
|
11251
|
+
"user-agent": userAgent
|
|
11035
11252
|
},
|
|
11036
|
-
body: JSON.stringify(
|
|
11037
|
-
trace,
|
|
11038
|
-
licenseKey,
|
|
11039
|
-
projectId,
|
|
11040
|
-
action,
|
|
11041
|
-
status,
|
|
11042
|
-
details
|
|
11043
|
-
})
|
|
11253
|
+
body: JSON.stringify(payload)
|
|
11044
11254
|
}).catch((err) => {
|
|
11045
|
-
console.warn("[Retrivora Telemetry] Async report warning:", err.message);
|
|
11255
|
+
console.warn("[Retrivora SDK Telemetry] Async report warning:", err.message);
|
|
11046
11256
|
});
|
|
11047
11257
|
} catch (e) {
|
|
11048
11258
|
}
|
|
@@ -11697,6 +11907,7 @@ function createRagHandler(configOrPlugin, options) {
|
|
|
11697
11907
|
Rule6SmallResultSetRule,
|
|
11698
11908
|
Rule7LargeTableRule,
|
|
11699
11909
|
RuleEngine,
|
|
11910
|
+
SDK_VERSION,
|
|
11700
11911
|
TableRendererStrategy,
|
|
11701
11912
|
TextRendererStrategy,
|
|
11702
11913
|
UniversalLLMAdapter,
|