@retrivora-ai/rag-engine 2.1.3 → 2.1.5
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 +271 -67
- package/dist/handlers/index.mjs +271 -67
- 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 +273 -67
- package/dist/server.mjs +272 -67
- package/package.json +1 -1
- package/src/components/DocumentUpload.tsx +50 -18
- package/src/config/serverConfig.ts +2 -2
- package/src/core/Pipeline.ts +23 -1
- package/src/handlers/index.ts +65 -15
- 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
|
@@ -2759,6 +2759,7 @@ __export(server_exports, {
|
|
|
2759
2759
|
Rule6SmallResultSetRule: () => Rule6SmallResultSetRule,
|
|
2760
2760
|
Rule7LargeTableRule: () => Rule7LargeTableRule,
|
|
2761
2761
|
RuleEngine: () => RuleEngine,
|
|
2762
|
+
SDK_VERSION: () => SDK_VERSION,
|
|
2762
2763
|
TableRendererStrategy: () => TableRendererStrategy,
|
|
2763
2764
|
TextRendererStrategy: () => TextRendererStrategy,
|
|
2764
2765
|
UniversalLLMAdapter: () => UniversalLLMAdapter,
|
|
@@ -3141,7 +3142,7 @@ function getRagConfig(baseConfig, env = process.env) {
|
|
|
3141
3142
|
return getEnvConfig(env, baseConfig);
|
|
3142
3143
|
}
|
|
3143
3144
|
function getEnvConfig(env = process.env, base) {
|
|
3144
|
-
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;
|
|
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;
|
|
3145
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__";
|
|
3146
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;
|
|
3147
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);
|
|
@@ -3149,38 +3150,38 @@ function getEnvConfig(env = process.env, base) {
|
|
|
3149
3150
|
const embeddingDimensions = readNumber(env, "EMBEDDING_DIMENSIONS", 768);
|
|
3150
3151
|
const vectorDbOptions = {};
|
|
3151
3152
|
if (vectorProvider === "pinecone") {
|
|
3152
|
-
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 : "";
|
|
3153
|
-
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";
|
|
3154
3155
|
} else if (vectorProvider === "pgvector" || vectorProvider === "postgresql") {
|
|
3155
|
-
vectorDbOptions.connectionString = (
|
|
3156
|
-
vectorDbOptions.tables = (
|
|
3157
|
-
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;
|
|
3158
3159
|
vectorDbOptions.dimensions = embeddingDimensions;
|
|
3159
3160
|
} else if (vectorProvider === "mongodb") {
|
|
3160
|
-
vectorDbOptions.uri = (
|
|
3161
|
-
vectorDbOptions.database = (
|
|
3162
|
-
vectorDbOptions.collection = (
|
|
3163
|
-
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";
|
|
3164
3165
|
} else if (vectorProvider === "qdrant") {
|
|
3165
|
-
vectorDbOptions.baseUrl = (
|
|
3166
|
-
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;
|
|
3167
3168
|
vectorDbOptions.dimensions = embeddingDimensions;
|
|
3168
3169
|
} else if (vectorProvider === "milvus") {
|
|
3169
|
-
vectorDbOptions.baseUrl = (
|
|
3170
|
+
vectorDbOptions.baseUrl = (_fa = readString(env, "MILVUS_URL")) != null ? _fa : "http://localhost:19530";
|
|
3170
3171
|
vectorDbOptions.apiKey = readString(env, "MILVUS_API_KEY");
|
|
3171
3172
|
} else if (vectorProvider === "chromadb") {
|
|
3172
|
-
vectorDbOptions.baseUrl = (
|
|
3173
|
+
vectorDbOptions.baseUrl = (_ga = readString(env, "CHROMADB_URL")) != null ? _ga : "http://localhost:8000";
|
|
3173
3174
|
} else if (vectorProvider === "weaviate") {
|
|
3174
|
-
vectorDbOptions.baseUrl = (
|
|
3175
|
+
vectorDbOptions.baseUrl = (_ha = readString(env, "WEAVIATE_URL")) != null ? _ha : "http://localhost:8080";
|
|
3175
3176
|
vectorDbOptions.apiKey = readString(env, "WEAVIATE_API_KEY");
|
|
3176
3177
|
} else if (vectorProvider === "redis") {
|
|
3177
|
-
vectorDbOptions.baseUrl = (
|
|
3178
|
+
vectorDbOptions.baseUrl = (_ia = readString(env, "REDIS_URL")) != null ? _ia : "";
|
|
3178
3179
|
vectorDbOptions.apiKey = readString(env, "REDIS_API_KEY");
|
|
3179
3180
|
} else if (vectorProvider === "rest") {
|
|
3180
|
-
vectorDbOptions.baseUrl = (
|
|
3181
|
+
vectorDbOptions.baseUrl = (_ja = readString(env, "VECTOR_DB_REST_URL")) != null ? _ja : "";
|
|
3181
3182
|
vectorDbOptions.headers = readString(env, "VECTOR_DB_REST_API_KEY") ? { "api-key": readString(env, "VECTOR_DB_REST_API_KEY") } : {};
|
|
3182
3183
|
} else if (vectorProvider === "universal_rest") {
|
|
3183
|
-
vectorDbOptions.baseUrl = (
|
|
3184
|
+
vectorDbOptions.baseUrl = (_la = (_ka = readString(env, "VECTOR_BASE_URL")) != null ? _ka : readString(env, "VECTOR_DB_REST_URL")) != null ? _la : "";
|
|
3184
3185
|
vectorDbOptions.profile = readString(env, "VECTOR_UNIVERSAL_PROFILE");
|
|
3185
3186
|
vectorDbOptions.headers = readString(env, "VECTOR_DB_REST_API_KEY") ? { Authorization: `Bearer ${readString(env, "VECTOR_DB_REST_API_KEY")}` } : {};
|
|
3186
3187
|
}
|
|
@@ -3199,8 +3200,8 @@ function getEnvConfig(env = process.env, base) {
|
|
|
3199
3200
|
// Anthropic needs a separate embedding provider; key kept for completeness
|
|
3200
3201
|
gemini: readString(env, "GEMINI_API_KEY"),
|
|
3201
3202
|
ollama: void 0,
|
|
3202
|
-
universal_rest: (
|
|
3203
|
-
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")
|
|
3204
3205
|
};
|
|
3205
3206
|
const DEFAULT_MODEL_BY_PROVIDER = {
|
|
3206
3207
|
openai: "gpt-4o",
|
|
@@ -3221,25 +3222,25 @@ function getEnvConfig(env = process.env, base) {
|
|
|
3221
3222
|
return true;
|
|
3222
3223
|
}
|
|
3223
3224
|
})();
|
|
3224
|
-
const defaultGatewayUrl = (
|
|
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";
|
|
3225
3226
|
const defaultLlmProvider = isFreeTier ? "universal_rest" : "universal_rest";
|
|
3226
|
-
const llmProvider = (
|
|
3227
|
-
const llmBaseUrl = (
|
|
3228
|
-
const llmModel = (
|
|
3229
|
-
const llmApiKey = (
|
|
3230
|
-
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";
|
|
3231
3232
|
const defaultEmbeddingProvider = isFreeTier ? "universal_rest" : "universal_rest";
|
|
3232
|
-
const embeddingProvider = (
|
|
3233
|
-
const embeddingBaseUrl = (
|
|
3234
|
-
const embeddingModel = (
|
|
3235
|
-
const embeddingApiKey = (
|
|
3236
|
-
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";
|
|
3237
3238
|
return __spreadProps(__spreadValues({
|
|
3238
3239
|
projectId,
|
|
3239
3240
|
licenseKey,
|
|
3240
3241
|
vectorDb: {
|
|
3241
3242
|
provider: vectorProvider,
|
|
3242
|
-
indexName: (
|
|
3243
|
+
indexName: (_gb = (_fb = readString(env, "VECTOR_DB_INDEX")) != null ? _fb : vectorDbOptions.indexName) != null ? _gb : "rag-index",
|
|
3243
3244
|
options: vectorDbOptions
|
|
3244
3245
|
},
|
|
3245
3246
|
llm: {
|
|
@@ -3269,30 +3270,30 @@ function getEnvConfig(env = process.env, base) {
|
|
|
3269
3270
|
}
|
|
3270
3271
|
},
|
|
3271
3272
|
ui: {
|
|
3272
|
-
title: (
|
|
3273
|
-
subtitle: (
|
|
3274
|
-
primaryColor: (
|
|
3275
|
-
accentColor: (
|
|
3276
|
-
logoUrl: (
|
|
3277
|
-
placeholder: (
|
|
3278
|
-
showSources: ((
|
|
3279
|
-
welcomeMessage: (
|
|
3280
|
-
visualStyle: (
|
|
3281
|
-
borderRadius: (
|
|
3282
|
-
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"
|
|
3283
3284
|
},
|
|
3284
3285
|
rag: {
|
|
3285
3286
|
topK: readNumber(env, "RAG_TOP_K", 5),
|
|
3286
3287
|
scoreThreshold: readNumber(env, "RAG_SCORE_THRESHOLD", 0),
|
|
3287
3288
|
chunkSize: readNumber(env, "RAG_CHUNK_SIZE", 1e3),
|
|
3288
3289
|
chunkOverlap: readNumber(env, "RAG_CHUNK_OVERLAP", 200),
|
|
3289
|
-
filterableFields: (
|
|
3290
|
+
filterableFields: (_Cb = readString(env, "RAG_FILTERABLE_FIELDS")) == null ? void 0 : _Cb.split(",").map((f) => f.trim()),
|
|
3290
3291
|
// Query pipeline toggles — read from .env.local
|
|
3291
3292
|
useQueryTransformation: readString(env, "RAG_USE_QUERY_TRANSFORMATION") === "true",
|
|
3292
3293
|
useReranking: readString(env, "RAG_USE_RERANKING") === "true",
|
|
3293
3294
|
useGraphRetrieval: readString(env, "RAG_USE_GRAPH_RETRIEVAL") === "true",
|
|
3294
|
-
architecture: (
|
|
3295
|
-
chunkingStrategy: (
|
|
3295
|
+
architecture: (_Db = readString(env, "RAG_ARCHITECTURE")) != null ? _Db : "simple",
|
|
3296
|
+
chunkingStrategy: (_Eb = readString(env, "RAG_CHUNKING_STRATEGY")) != null ? _Eb : "recursive",
|
|
3296
3297
|
uiMapping: (() => {
|
|
3297
3298
|
const raw = readString(env, "RAG_UI_MAPPING");
|
|
3298
3299
|
if (!raw) return void 0;
|
|
@@ -3305,7 +3306,7 @@ function getEnvConfig(env = process.env, base) {
|
|
|
3305
3306
|
},
|
|
3306
3307
|
telemetry: {
|
|
3307
3308
|
enabled: telemetryEnabled,
|
|
3308
|
-
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"
|
|
3309
3310
|
}
|
|
3310
3311
|
}, readString(env, "GRAPH_DB_PROVIDER") ? {
|
|
3311
3312
|
graphDb: {
|
|
@@ -5344,6 +5345,147 @@ var ConfigValidator = class {
|
|
|
5344
5345
|
}
|
|
5345
5346
|
};
|
|
5346
5347
|
|
|
5348
|
+
// package.json
|
|
5349
|
+
var package_default = {
|
|
5350
|
+
name: "@retrivora-ai/rag-engine",
|
|
5351
|
+
version: "2.1.5",
|
|
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
|
+
|
|
5347
5489
|
// src/rag/DocumentChunker.ts
|
|
5348
5490
|
var DocumentChunker = class {
|
|
5349
5491
|
constructor(chunkSize = 1e3, chunkOverlap = 200, separators = ["\n# ", "\n## ", "\n### ", "\n#### ", "\n\n", "\n", " ", ""]) {
|
|
@@ -9627,6 +9769,7 @@ ${context}`;
|
|
|
9627
9769
|
const telemetryUrl = ((_B = this.config.telemetry) == null ? void 0 : _B.url) || process.env.TELEMETRY_URL || process.env.NEXT_PUBLIC_TELEMETRY_URL || defaultUrl;
|
|
9628
9770
|
const absoluteUrl = telemetryUrl.startsWith("http") ? telemetryUrl : (process.env.NEXT_PUBLIC_APP_URL || `http://localhost:${process.env.PORT || 3e3}`) + telemetryUrl;
|
|
9629
9771
|
(async () => {
|
|
9772
|
+
var _a3, _b2, _c2, _d2, _e2;
|
|
9630
9773
|
try {
|
|
9631
9774
|
let finalTrace = trace;
|
|
9632
9775
|
if (!awaitHallucination && runHallucination) {
|
|
@@ -9635,6 +9778,12 @@ ${context}`;
|
|
|
9635
9778
|
finalTrace = buildTrace(backgroundScoreResult);
|
|
9636
9779
|
}
|
|
9637
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`);
|
|
9638
9787
|
await fetch(absoluteUrl, {
|
|
9639
9788
|
method: "POST",
|
|
9640
9789
|
headers: {
|
|
@@ -9643,7 +9792,20 @@ ${context}`;
|
|
|
9643
9792
|
body: JSON.stringify({
|
|
9644
9793
|
trace: finalTrace,
|
|
9645
9794
|
licenseKey: this.config.licenseKey,
|
|
9646
|
-
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`
|
|
9647
9809
|
})
|
|
9648
9810
|
});
|
|
9649
9811
|
} catch (err) {
|
|
@@ -11039,7 +11201,7 @@ function getOrCreatePlugin(configOrPlugin) {
|
|
|
11039
11201
|
return _g[cacheKey];
|
|
11040
11202
|
}
|
|
11041
11203
|
function reportTelemetry(req, plugin, action, status, details, trace) {
|
|
11042
|
-
var _a2;
|
|
11204
|
+
var _a2, _b, _c, _d, _e, _f, _g2, _h;
|
|
11043
11205
|
try {
|
|
11044
11206
|
const config = plugin.getConfig();
|
|
11045
11207
|
const licenseKey = config.licenseKey || process.env.RAG_LICENSE_KEY || process.env.RETRIVORA_LICENSE_KEY || process.env.NEXT_PUBLIC_RETRIVORA_LICENSE_KEY;
|
|
@@ -11048,29 +11210,49 @@ function reportTelemetry(req, plugin, action, status, details, trace) {
|
|
|
11048
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";
|
|
11049
11211
|
const telemetryUrl = (telemetryConfig == null ? void 0 : telemetryConfig.url) || process.env.TELEMETRY_URL || process.env.NEXT_PUBLIC_TELEMETRY_URL || defaultUrl;
|
|
11050
11212
|
const host = req.headers.get("host") || "localhost";
|
|
11213
|
+
const userAgent = req.headers.get("user-agent") || `Retrivora-SDK/${SDK_VERSION}`;
|
|
11051
11214
|
let absoluteUrl = telemetryUrl;
|
|
11052
11215
|
if (!telemetryUrl.startsWith("http")) {
|
|
11053
11216
|
const proto = req.headers.get("x-forwarded-proto") || "http";
|
|
11054
11217
|
absoluteUrl = `${proto}://${host}${telemetryUrl}`;
|
|
11055
11218
|
}
|
|
11056
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`);
|
|
11057
11245
|
fetch(absoluteUrl, {
|
|
11058
11246
|
method: "POST",
|
|
11059
11247
|
headers: {
|
|
11060
11248
|
"Content-Type": "application/json",
|
|
11061
11249
|
"x-forwarded-for": req.headers.get("x-forwarded-for") || "",
|
|
11062
|
-
"x-real-ip": req.headers.get("x-real-ip") || ""
|
|
11250
|
+
"x-real-ip": req.headers.get("x-real-ip") || "",
|
|
11251
|
+
"user-agent": userAgent
|
|
11063
11252
|
},
|
|
11064
|
-
body: JSON.stringify(
|
|
11065
|
-
trace,
|
|
11066
|
-
licenseKey,
|
|
11067
|
-
projectId,
|
|
11068
|
-
action,
|
|
11069
|
-
status,
|
|
11070
|
-
details
|
|
11071
|
-
})
|
|
11253
|
+
body: JSON.stringify(payload)
|
|
11072
11254
|
}).catch((err) => {
|
|
11073
|
-
console.warn("[Retrivora Telemetry] Async report warning:", err.message);
|
|
11255
|
+
console.warn("[Retrivora SDK Telemetry] Async report warning:", err.message);
|
|
11074
11256
|
});
|
|
11075
11257
|
} catch (e) {
|
|
11076
11258
|
}
|
|
@@ -11173,12 +11355,19 @@ function createStreamHandler(configOrPlugin, options) {
|
|
|
11173
11355
|
const storage = new DatabaseStorage(plugin.getConfig());
|
|
11174
11356
|
const onAuthorize = options == null ? void 0 : options.onAuthorize;
|
|
11175
11357
|
return async function POST(req) {
|
|
11358
|
+
var _a2;
|
|
11176
11359
|
const authResult = await checkAuth(req, onAuthorize);
|
|
11177
11360
|
if (authResult) return authResult;
|
|
11178
11361
|
const rateLimited = checkRateLimit(req);
|
|
11179
11362
|
if (rateLimited) return rateLimited;
|
|
11180
11363
|
let body;
|
|
11181
11364
|
try {
|
|
11365
|
+
if ((_a2 = req.headers.get("content-type")) == null ? void 0 : _a2.includes("multipart/form-data")) {
|
|
11366
|
+
return new Response(JSON.stringify({ error: { code: "INVALID_ENDPOINT", message: "Multipart file upload requests must be sent to the /upload endpoint." } }), {
|
|
11367
|
+
status: 400,
|
|
11368
|
+
headers: { "Content-Type": "application/json" }
|
|
11369
|
+
});
|
|
11370
|
+
}
|
|
11182
11371
|
body = await req.json();
|
|
11183
11372
|
} catch (e) {
|
|
11184
11373
|
return new Response(JSON.stringify({ error: { code: "INVALID_JSON", message: "Invalid JSON body" } }), {
|
|
@@ -11216,7 +11405,7 @@ function createStreamHandler(configOrPlugin, options) {
|
|
|
11216
11405
|
let isActive = true;
|
|
11217
11406
|
const stream = new ReadableStream({
|
|
11218
11407
|
async start(controller) {
|
|
11219
|
-
var
|
|
11408
|
+
var _a3, _b, _c, _d, _e;
|
|
11220
11409
|
const enqueue = (text) => {
|
|
11221
11410
|
if (!isActive) return;
|
|
11222
11411
|
try {
|
|
@@ -11249,7 +11438,7 @@ function createStreamHandler(configOrPlugin, options) {
|
|
|
11249
11438
|
let uiTransformation = responseChunk == null ? void 0 : responseChunk.ui_transformation;
|
|
11250
11439
|
if (sources.length > 0) {
|
|
11251
11440
|
try {
|
|
11252
|
-
uiTransformation = (
|
|
11441
|
+
uiTransformation = (_a3 = responseChunk == null ? void 0 : responseChunk.ui_transformation) != null ? _a3 : UITransformer.transform(message, sources, plugin.getConfig());
|
|
11253
11442
|
if (uiTransformation) {
|
|
11254
11443
|
enqueue(sseUIFrame(uiTransformation));
|
|
11255
11444
|
}
|
|
@@ -11646,16 +11835,32 @@ function createRagHandler(configOrPlugin, options) {
|
|
|
11646
11835
|
return import_server.NextResponse.json({ error: `Method Not Allowed: GET segment "${segment}" not supported.` }, { status: 405 });
|
|
11647
11836
|
}
|
|
11648
11837
|
}
|
|
11649
|
-
async function getSegment(context) {
|
|
11650
|
-
var _a2;
|
|
11838
|
+
async function getSegment(req, context) {
|
|
11839
|
+
var _a2, _b;
|
|
11840
|
+
const contentType = req.headers.get("content-type") || "";
|
|
11841
|
+
if (contentType.includes("multipart/form-data")) {
|
|
11842
|
+
return "upload";
|
|
11843
|
+
}
|
|
11844
|
+
try {
|
|
11845
|
+
const url = new URL(req.url);
|
|
11846
|
+
const pathname = url.pathname;
|
|
11847
|
+
if (pathname.endsWith("/upload")) return "upload";
|
|
11848
|
+
if (pathname.endsWith("/chat") || pathname.endsWith("/chat-sync")) return "chat";
|
|
11849
|
+
if (pathname.endsWith("/health")) return "health";
|
|
11850
|
+
if (pathname.endsWith("/suggestions")) return "suggestions";
|
|
11851
|
+
if (pathname.endsWith("/feedback")) return "feedback";
|
|
11852
|
+
if (pathname.endsWith("/history")) return "history";
|
|
11853
|
+
} catch (e) {
|
|
11854
|
+
}
|
|
11651
11855
|
const resolvedParams = typeof ((_a2 = context == null ? void 0 : context.params) == null ? void 0 : _a2.then) === "function" ? await context.params : context == null ? void 0 : context.params;
|
|
11652
|
-
const segments = (resolvedParams == null ? void 0 : resolvedParams.retrivora) || [];
|
|
11653
|
-
|
|
11856
|
+
const segments = (resolvedParams == null ? void 0 : resolvedParams.retrivora) || ((_b = resolvedParams == null ? void 0 : resolvedParams.params) == null ? void 0 : _b.retrivora) || [];
|
|
11857
|
+
const joined = segments.join("/");
|
|
11858
|
+
return joined || "chat";
|
|
11654
11859
|
}
|
|
11655
11860
|
return {
|
|
11656
11861
|
GET: async (req, context) => {
|
|
11657
11862
|
try {
|
|
11658
|
-
const segment = await getSegment(context);
|
|
11863
|
+
const segment = await getSegment(req, context);
|
|
11659
11864
|
return await routeGetRequest(req, segment);
|
|
11660
11865
|
} catch (err) {
|
|
11661
11866
|
const msg = err instanceof Error ? err.message : "GET Routing failed";
|
|
@@ -11664,7 +11869,7 @@ function createRagHandler(configOrPlugin, options) {
|
|
|
11664
11869
|
},
|
|
11665
11870
|
POST: async (req, context) => {
|
|
11666
11871
|
try {
|
|
11667
|
-
const segment = await getSegment(context);
|
|
11872
|
+
const segment = await getSegment(req, context);
|
|
11668
11873
|
return await routePostRequest(req, segment);
|
|
11669
11874
|
} catch (err) {
|
|
11670
11875
|
const msg = err instanceof Error ? err.message : "POST Routing failed";
|
|
@@ -11725,6 +11930,7 @@ function createRagHandler(configOrPlugin, options) {
|
|
|
11725
11930
|
Rule6SmallResultSetRule,
|
|
11726
11931
|
Rule7LargeTableRule,
|
|
11727
11932
|
RuleEngine,
|
|
11933
|
+
SDK_VERSION,
|
|
11728
11934
|
TableRendererStrategy,
|
|
11729
11935
|
TextRendererStrategy,
|
|
11730
11936
|
UniversalLLMAdapter,
|