@retrivora-ai/rag-engine 2.4.2 → 2.4.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.
Files changed (140) hide show
  1. package/dist/{BatchProcessor-zbQMaZHm.d.mts → BatchProcessor-Csy_K1qQ.d.mts} +2 -0
  2. package/dist/{BatchProcessor-D42E706a.d.ts → BatchProcessor-Dg18zZGk.d.ts} +2 -0
  3. package/dist/handlers/index.js +31 -5
  4. package/dist/handlers/index.mjs +31 -5
  5. package/dist/index.d.mts +3 -3
  6. package/dist/index.d.ts +3 -3
  7. package/dist/index.js +41 -21
  8. package/dist/index.min.css +2 -0
  9. package/dist/index.mjs +41 -21
  10. package/dist/server.d.mts +2 -2
  11. package/dist/server.d.ts +2 -2
  12. package/dist/server.js +32 -5
  13. package/dist/server.mjs +32 -5
  14. package/package.json +5 -4
  15. package/src/LicensedRetrivora.ts +0 -278
  16. package/src/app/api/chat/route.ts +0 -4
  17. package/src/app/api/health/route.ts +0 -5
  18. package/src/app/api/ingest/route.ts +0 -27
  19. package/src/app/api/suggestions/route.ts +0 -5
  20. package/src/app/api/upload/route.ts +0 -5
  21. package/src/app/constants.tsx +0 -270
  22. package/src/app/favicon.ico +0 -0
  23. package/src/app/globals.css +0 -449
  24. package/src/app/layout.tsx +0 -22
  25. package/src/app/page.tsx +0 -64
  26. package/src/app/types.ts +0 -30
  27. package/src/browser.tsx +0 -139
  28. package/src/components/ChatWidget.tsx +0 -393
  29. package/src/components/ChatWindow.tsx +0 -952
  30. package/src/components/CodeViewer.tsx +0 -56
  31. package/src/components/ConfigProvider.tsx +0 -123
  32. package/src/components/DocumentUpload.tsx +0 -354
  33. package/src/components/DynamicChart.tsx +0 -297
  34. package/src/components/HourglassLoader.tsx +0 -87
  35. package/src/components/MarkdownComponents.tsx +0 -186
  36. package/src/components/MessageBubble.tsx +0 -498
  37. package/src/components/ObservabilityPanel.tsx +0 -374
  38. package/src/components/ProductCard.tsx +0 -107
  39. package/src/components/ProductCarousel.tsx +0 -97
  40. package/src/components/SourceCard.tsx +0 -61
  41. package/src/components/ThemeProvider.tsx +0 -8
  42. package/src/components/ThemeToggle.tsx +0 -29
  43. package/src/components/ThinkingBlock.tsx +0 -75
  44. package/src/components/UIDispatcher.tsx +0 -342
  45. package/src/components/VisualizationRenderer.tsx +0 -621
  46. package/src/components/constants.tsx +0 -503
  47. package/src/config/ConfigBuilder.ts +0 -285
  48. package/src/config/EmbeddingStrategy.ts +0 -148
  49. package/src/config/LicenseConfigResolver.ts +0 -298
  50. package/src/config/RagConfig.ts +0 -328
  51. package/src/config/UniversalProfiles.ts +0 -82
  52. package/src/config/constants.ts +0 -64
  53. package/src/config/serverConfig.ts +0 -378
  54. package/src/config/uiConstants.ts +0 -47
  55. package/src/core/BatchProcessor.ts +0 -385
  56. package/src/core/CircuitBreaker.ts +0 -118
  57. package/src/core/ConfigFetcher.ts +0 -220
  58. package/src/core/ConfigResolver.ts +0 -165
  59. package/src/core/ConfigValidator.ts +0 -197
  60. package/src/core/DatabaseStorage.ts +0 -526
  61. package/src/core/FreeTierLimitsGuard.ts +0 -281
  62. package/src/core/LLMRouter.ts +0 -79
  63. package/src/core/LangChainAgent.ts +0 -132
  64. package/src/core/LicenseValidator.ts +0 -284
  65. package/src/core/LicenseVerifier.ts +0 -261
  66. package/src/core/MultiAgentCoordinator.ts +0 -239
  67. package/src/core/Pipeline.ts +0 -1279
  68. package/src/core/PluginManager.ts +0 -277
  69. package/src/core/ProjectSettings.ts +0 -247
  70. package/src/core/ProviderHealthCheck.ts +0 -133
  71. package/src/core/ProviderInterfaces.ts +0 -37
  72. package/src/core/ProviderRegistry.ts +0 -156
  73. package/src/core/QueryProcessor.ts +0 -399
  74. package/src/core/Retrivora.ts +0 -98
  75. package/src/core/VectorPlugin.ts +0 -193
  76. package/src/core/mcp.ts +0 -261
  77. package/src/exceptions/index.ts +0 -131
  78. package/src/handlers/index.ts +0 -1625
  79. package/src/hooks/useHydrated.ts +0 -13
  80. package/src/hooks/useProjectSettings.ts +0 -105
  81. package/src/hooks/useRagChat.ts +0 -436
  82. package/src/hooks/useStoredMessages.ts +0 -64
  83. package/src/index.css +0 -4269
  84. package/src/index.ts +0 -137
  85. package/src/lib/plugin.ts +0 -24
  86. package/src/llm/ILLMProvider.ts +0 -60
  87. package/src/llm/LLMFactory.ts +0 -141
  88. package/src/llm/providers/AnthropicProvider.ts +0 -215
  89. package/src/llm/providers/GeminiProvider.ts +0 -311
  90. package/src/llm/providers/GroqProvider.ts +0 -184
  91. package/src/llm/providers/OllamaProvider.ts +0 -232
  92. package/src/llm/providers/OpenAIProvider.ts +0 -188
  93. package/src/llm/providers/QwenProvider.ts +0 -199
  94. package/src/llm/providers/UniversalLLMAdapter.ts +0 -422
  95. package/src/llm/utils.ts +0 -46
  96. package/src/providers/graphdb/BaseGraphProvider.ts +0 -43
  97. package/src/providers/graphdb/SimpleGraphProvider.ts +0 -66
  98. package/src/providers/vectordb/BaseVectorProvider.ts +0 -98
  99. package/src/providers/vectordb/ChromaDBProvider.ts +0 -130
  100. package/src/providers/vectordb/MilvusProvider.ts +0 -134
  101. package/src/providers/vectordb/MongoDBProvider.ts +0 -250
  102. package/src/providers/vectordb/MultiTablePostgresProvider.ts +0 -461
  103. package/src/providers/vectordb/PineconeProvider.ts +0 -295
  104. package/src/providers/vectordb/PostgreSQLProvider.ts +0 -227
  105. package/src/providers/vectordb/QdrantProvider.ts +0 -294
  106. package/src/providers/vectordb/RedisProvider.ts +0 -105
  107. package/src/providers/vectordb/UniversalVectorProvider.ts +0 -221
  108. package/src/providers/vectordb/WeaviateProvider.ts +0 -172
  109. package/src/rag/DocumentChunker.ts +0 -144
  110. package/src/rag/EntityExtractor.ts +0 -90
  111. package/src/rag/LlamaIndexIngestor.ts +0 -60
  112. package/src/rag/Reranker.ts +0 -106
  113. package/src/rendering/IntentClassifier.ts +0 -167
  114. package/src/rendering/RendererRegistry.ts +0 -164
  115. package/src/rendering/RuleEngine.ts +0 -67
  116. package/src/rendering/VisualizationDecisionEngine.ts +0 -164
  117. package/src/rendering/__tests__/VisualizationDecisionEngine.test.ts +0 -237
  118. package/src/rendering/index.ts +0 -12
  119. package/src/rendering/rules/Rule1SpecificInfoRule.ts +0 -28
  120. package/src/rendering/rules/Rule2ComparisonRule.ts +0 -24
  121. package/src/rendering/rules/Rule3ProductDiscoveryRule.ts +0 -28
  122. package/src/rendering/rules/Rule4AnalyticalRule.ts +0 -38
  123. package/src/rendering/rules/Rule5MixedResponseRule.ts +0 -29
  124. package/src/rendering/rules/Rule6SmallResultSetRule.ts +0 -24
  125. package/src/rendering/rules/Rule7LargeTableRule.ts +0 -35
  126. package/src/rendering/types.ts +0 -96
  127. package/src/server.ts +0 -156
  128. package/src/tailwind.css +0 -194
  129. package/src/telemetry/TelemetryService.ts +0 -330
  130. package/src/types/chat.ts +0 -89
  131. package/src/types/index.ts +0 -278
  132. package/src/types/pdf-parse.d.ts +0 -13
  133. package/src/types/props.ts +0 -169
  134. package/src/utils/DocumentParser.ts +0 -111
  135. package/src/utils/ProductExtractor.ts +0 -350
  136. package/src/utils/SchemaMapper.ts +0 -176
  137. package/src/utils/UITransformer.ts +0 -1812
  138. package/src/utils/synonyms.ts +0 -80
  139. package/src/utils/templateUtils.ts +0 -78
  140. package/src/version.ts +0 -6
@@ -91,6 +91,8 @@ interface MessageBubbleProps {
91
91
  accentColor: string;
92
92
  onAddToCart?: (product: Product) => void;
93
93
  viewportSize?: ChatViewportSize;
94
+ /** Whether to show the sources toggle and cards (respects dashboard citations setting) */
95
+ showSources?: boolean;
94
96
  /** Called when the user clicks thumbs up or thumbs down on an assistant message */
95
97
  onFeedback?: (messageId: string, rating: 'thumbs_up' | 'thumbs_down') => void;
96
98
  }
@@ -91,6 +91,8 @@ interface MessageBubbleProps {
91
91
  accentColor: string;
92
92
  onAddToCart?: (product: Product) => void;
93
93
  viewportSize?: ChatViewportSize;
94
+ /** Whether to show the sources toggle and cards (respects dashboard citations setting) */
95
+ showSources?: boolean;
94
96
  /** Called when the user clicks thumbs up or thumbs down on an assistant message */
95
97
  onFeedback?: (messageId: string, rating: 'thumbs_up' | 'thumbs_down') => void;
96
98
  }
@@ -317,7 +317,7 @@ var init_package = __esm({
317
317
  "package.json"() {
318
318
  package_default = {
319
319
  name: "@retrivora-ai/rag-engine",
320
- version: "2.4.2",
320
+ version: "2.4.5",
321
321
  description: "Retrivora AI is a plug-and-play AI engine for RAG chat experiences \u2014 generic vector DB + LLM provider, embeddable or standalone.",
322
322
  author: "Abhinav Alkuchi",
323
323
  license: "UNLICENSED",
@@ -354,8 +354,11 @@ var init_package = __esm({
354
354
  import: "./dist/index.mjs"
355
355
  },
356
356
  "./style.css": "./dist/index.css",
357
+ "./style.min.css": "./dist/index.min.css",
357
358
  "./index.css": "./dist/index.css",
359
+ "./index.min.css": "./dist/index.min.css",
358
360
  "./styles.css": "./dist/index.css",
361
+ "./styles.min.css": "./dist/index.min.css",
359
362
  "./handlers": {
360
363
  types: "./dist/handlers/index.d.ts",
361
364
  require: "./dist/handlers/index.js",
@@ -386,15 +389,13 @@ var init_package = __esm({
386
389
  },
387
390
  files: [
388
391
  "dist",
389
- "src",
390
- ".env.example",
391
392
  "README.md",
392
393
  "FREE_TIER_ARCHITECTURE.md"
393
394
  ],
394
395
  scripts: {
395
396
  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",
396
397
  build: "npm run build:pkg",
397
- "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",
398
+ "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 && npx @tailwindcss/cli -i src/tailwind.css -o dist/index.min.css --minify",
398
399
  lint: "eslint",
399
400
  typecheck: "tsc --noEmit -p tsconfig.build.json",
400
401
  clean: "rm -rf dist"
@@ -10958,10 +10959,35 @@ function resolveLicenseKey(req, config, bodyLicenseKey) {
10958
10959
  var _a3;
10959
10960
  return req.headers.get("x-license-key") || bodyLicenseKey || ((_a3 = req.headers.get("authorization")) == null ? void 0 : _a3.replace(/^Bearer\s+/i, "")) || config.licenseKey || process.env.NEXT_PUBLIC_RETRIVORA_LICENSE_KEY || process.env.RETRIVORA_LICENSE_KEY || process.env.RAG_LICENSE_KEY || "";
10960
10961
  }
10962
+ function extractProjectIdFromLicenseKey(licenseKey) {
10963
+ try {
10964
+ const sanitizedKey = licenseKey.trim().replace(/^["']|["']$/g, "").trim();
10965
+ const rawToken = sanitizedKey.replace(/^rtv_/i, "").trim();
10966
+ const parts = rawToken.split(".");
10967
+ if (parts.length === 3) {
10968
+ const decodedPayload = JSON.parse(Buffer.from(parts[1], "base64url").toString("utf8"));
10969
+ return decodedPayload.projectId;
10970
+ }
10971
+ } catch (e) {
10972
+ }
10973
+ return void 0;
10974
+ }
10961
10975
  async function enforceLicense(req, config, bodyLicenseKey) {
10962
10976
  const rawKey = resolveLicenseKey(req, config, bodyLicenseKey);
10963
10977
  const licenseKey = (rawKey || "").trim().replace(/^["']|["']$/g, "").trim();
10964
- const projectId = config.projectId || "";
10978
+ const url = new URL(req.url);
10979
+ const queryProjectId = url.searchParams.get("projectId") || url.searchParams.get("project-id");
10980
+ const headerProjectId = req.headers.get("x-project-id") || req.headers.get("X-Project-Id");
10981
+ const jwtProjectId = extractProjectIdFromLicenseKey(licenseKey);
10982
+ let bodyProjectId = "";
10983
+ if (req.method === "POST") {
10984
+ try {
10985
+ const body = await req.clone().json();
10986
+ bodyProjectId = (body == null ? void 0 : body.projectId) || "";
10987
+ } catch (e) {
10988
+ }
10989
+ }
10990
+ const projectId = queryProjectId || headerProjectId || bodyProjectId || jwtProjectId || config.projectId || "";
10965
10991
  try {
10966
10992
  let payload;
10967
10993
  try {
@@ -302,7 +302,7 @@ var init_package = __esm({
302
302
  "package.json"() {
303
303
  package_default = {
304
304
  name: "@retrivora-ai/rag-engine",
305
- version: "2.4.2",
305
+ version: "2.4.5",
306
306
  description: "Retrivora AI is a plug-and-play AI engine for RAG chat experiences \u2014 generic vector DB + LLM provider, embeddable or standalone.",
307
307
  author: "Abhinav Alkuchi",
308
308
  license: "UNLICENSED",
@@ -339,8 +339,11 @@ var init_package = __esm({
339
339
  import: "./dist/index.mjs"
340
340
  },
341
341
  "./style.css": "./dist/index.css",
342
+ "./style.min.css": "./dist/index.min.css",
342
343
  "./index.css": "./dist/index.css",
344
+ "./index.min.css": "./dist/index.min.css",
343
345
  "./styles.css": "./dist/index.css",
346
+ "./styles.min.css": "./dist/index.min.css",
344
347
  "./handlers": {
345
348
  types: "./dist/handlers/index.d.ts",
346
349
  require: "./dist/handlers/index.js",
@@ -371,15 +374,13 @@ var init_package = __esm({
371
374
  },
372
375
  files: [
373
376
  "dist",
374
- "src",
375
- ".env.example",
376
377
  "README.md",
377
378
  "FREE_TIER_ARCHITECTURE.md"
378
379
  ],
379
380
  scripts: {
380
381
  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",
381
382
  build: "npm run build:pkg",
382
- "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",
383
+ "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 && npx @tailwindcss/cli -i src/tailwind.css -o dist/index.min.css --minify",
383
384
  lint: "eslint",
384
385
  typecheck: "tsc --noEmit -p tsconfig.build.json",
385
386
  clean: "rm -rf dist"
@@ -10922,10 +10923,35 @@ function resolveLicenseKey(req, config, bodyLicenseKey) {
10922
10923
  var _a3;
10923
10924
  return req.headers.get("x-license-key") || bodyLicenseKey || ((_a3 = req.headers.get("authorization")) == null ? void 0 : _a3.replace(/^Bearer\s+/i, "")) || config.licenseKey || process.env.NEXT_PUBLIC_RETRIVORA_LICENSE_KEY || process.env.RETRIVORA_LICENSE_KEY || process.env.RAG_LICENSE_KEY || "";
10924
10925
  }
10926
+ function extractProjectIdFromLicenseKey(licenseKey) {
10927
+ try {
10928
+ const sanitizedKey = licenseKey.trim().replace(/^["']|["']$/g, "").trim();
10929
+ const rawToken = sanitizedKey.replace(/^rtv_/i, "").trim();
10930
+ const parts = rawToken.split(".");
10931
+ if (parts.length === 3) {
10932
+ const decodedPayload = JSON.parse(Buffer.from(parts[1], "base64url").toString("utf8"));
10933
+ return decodedPayload.projectId;
10934
+ }
10935
+ } catch (e) {
10936
+ }
10937
+ return void 0;
10938
+ }
10925
10939
  async function enforceLicense(req, config, bodyLicenseKey) {
10926
10940
  const rawKey = resolveLicenseKey(req, config, bodyLicenseKey);
10927
10941
  const licenseKey = (rawKey || "").trim().replace(/^["']|["']$/g, "").trim();
10928
- const projectId = config.projectId || "";
10942
+ const url = new URL(req.url);
10943
+ const queryProjectId = url.searchParams.get("projectId") || url.searchParams.get("project-id");
10944
+ const headerProjectId = req.headers.get("x-project-id") || req.headers.get("X-Project-Id");
10945
+ const jwtProjectId = extractProjectIdFromLicenseKey(licenseKey);
10946
+ let bodyProjectId = "";
10947
+ if (req.method === "POST") {
10948
+ try {
10949
+ const body = await req.clone().json();
10950
+ bodyProjectId = (body == null ? void 0 : body.projectId) || "";
10951
+ } catch (e) {
10952
+ }
10953
+ }
10954
+ const projectId = queryProjectId || headerProjectId || bodyProjectId || jwtProjectId || config.projectId || "";
10929
10955
  try {
10930
10956
  let payload;
10931
10957
  try {
package/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { C as ChatWidgetProps, a as ChatWindowProps, D as DocumentUploadProps, M as MessageBubbleProps, S as SourceCardProps, b as ConfigProviderProps, c as ClientConfig, P as ProductCardProps, d as ProductCarouselProps, R as RemoteConfig } from './BatchProcessor-zbQMaZHm.mjs';
3
- export { A as AuthenticationException, B as BatchOptions, e as BatchProcessor, f as BatchResult, g as ChartType, h as Chunk, i as ChunkOptions, j as ConfigFetcher, k as ConfigurationException, l as DecisionContext, E as EmbeddingFailedException, I as IRenderRule, m as IRendererStrategy, n as IntentCategory, L as LicenseTierConfig, o as LicenseValidationError, p as LicenseValidationRequest, q as LicenseValidationResponse, r as LicenseValidator, s as ProviderCredentials, t as ProviderNotFoundException, u as RateLimitException, v as RemoteEmbeddingConfig, w as RemoteLLMConfig, x as RemoteVectorConfig, y as RenderDecision, z as RenderType, F as RetrievalException, G as Retrivora, H as RetrivoraError, J as RetrivoraErrorCode, K as SDKVersionUnsupportedError, N as SDK_VERSION, O as isTransientError } from './BatchProcessor-zbQMaZHm.mjs';
2
+ import { C as ChatWidgetProps, a as ChatWindowProps, D as DocumentUploadProps, M as MessageBubbleProps, S as SourceCardProps, b as ConfigProviderProps, c as ClientConfig, P as ProductCardProps, d as ProductCarouselProps, R as RemoteConfig } from './BatchProcessor-Csy_K1qQ.mjs';
3
+ export { A as AuthenticationException, B as BatchOptions, e as BatchProcessor, f as BatchResult, g as ChartType, h as Chunk, i as ChunkOptions, j as ConfigFetcher, k as ConfigurationException, l as DecisionContext, E as EmbeddingFailedException, I as IRenderRule, m as IRendererStrategy, n as IntentCategory, L as LicenseTierConfig, o as LicenseValidationError, p as LicenseValidationRequest, q as LicenseValidationResponse, r as LicenseValidator, s as ProviderCredentials, t as ProviderNotFoundException, u as RateLimitException, v as RemoteEmbeddingConfig, w as RemoteLLMConfig, x as RemoteVectorConfig, y as RenderDecision, z as RenderType, F as RetrievalException, G as Retrivora, H as RetrivoraError, J as RetrivoraErrorCode, K as SDKVersionUnsupportedError, N as SDK_VERSION, O as isTransientError } from './BatchProcessor-Csy_K1qQ.mjs';
4
4
  import { O as ObservabilityTrace, U as UseRagChatOptions, a as UseRagChatReturn, P as ProjectChatSettings } from './ILLMProvider-Y6aL5N8J.mjs';
5
5
  export { A as AuthMode, C as ChatMessage, b as ChatOptions, c as ChatResponse, E as EmbedOptions, d as EmbeddingConfig, e as EmbeddingProvider, I as ILLMProvider, f as IngestDocument, L as LLMConfig, g as LLMProvider, h as LatencyBreakdown, i as ProjectAiSettings, j as ProjectAuthSettings, k as ProjectBrandingSettings, l as ProjectTelemetrySettings, m as ProjectWidgetSettings, R as RAGConfig, n as RagConfig, o as RagMessage, p as RetrievalConfig, q as RetrievedChunk, T as ThemeMode, r as TokenUsage, s as UIConfig, t as UniversalRagConfig, u as UpsertDocument, V as VectorDBConfig, v as VectorDBProvider, w as VectorMatch, W as WidgetPosition, x as WorkflowConfig, y as createDefaultProjectSettings, z as normalizeProjectSettings, B as projectSettingsToUiConfig } from './ILLMProvider-Y6aL5N8J.mjs';
6
6
  import 'react';
@@ -47,7 +47,7 @@ declare function ChatWindow({ className, style, onClose, showClose, onResizeStar
47
47
 
48
48
  declare function DocumentUpload({ namespace, uploadUrl, retrivoraApiBase, onUploadComplete, className }: DocumentUploadProps): react_jsx_runtime.JSX.Element;
49
49
 
50
- declare function MessageBubble({ message, sources, isStreaming, primaryColor, accentColor, onAddToCart, viewportSize, onFeedback, }: MessageBubbleProps): react_jsx_runtime.JSX.Element;
50
+ declare function MessageBubble({ message, sources, isStreaming, primaryColor, accentColor, onAddToCart, viewportSize, showSources: showSourcesProp, onFeedback, }: MessageBubbleProps): react_jsx_runtime.JSX.Element;
51
51
 
52
52
  declare function SourceCard({ source, index }: SourceCardProps): react_jsx_runtime.JSX.Element;
53
53
 
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { C as ChatWidgetProps, a as ChatWindowProps, D as DocumentUploadProps, M as MessageBubbleProps, S as SourceCardProps, b as ConfigProviderProps, c as ClientConfig, P as ProductCardProps, d as ProductCarouselProps, R as RemoteConfig } from './BatchProcessor-D42E706a.js';
3
- export { A as AuthenticationException, B as BatchOptions, e as BatchProcessor, f as BatchResult, g as ChartType, h as Chunk, i as ChunkOptions, j as ConfigFetcher, k as ConfigurationException, l as DecisionContext, E as EmbeddingFailedException, I as IRenderRule, m as IRendererStrategy, n as IntentCategory, L as LicenseTierConfig, o as LicenseValidationError, p as LicenseValidationRequest, q as LicenseValidationResponse, r as LicenseValidator, s as ProviderCredentials, t as ProviderNotFoundException, u as RateLimitException, v as RemoteEmbeddingConfig, w as RemoteLLMConfig, x as RemoteVectorConfig, y as RenderDecision, z as RenderType, F as RetrievalException, G as Retrivora, H as RetrivoraError, J as RetrivoraErrorCode, K as SDKVersionUnsupportedError, N as SDK_VERSION, O as isTransientError } from './BatchProcessor-D42E706a.js';
2
+ import { C as ChatWidgetProps, a as ChatWindowProps, D as DocumentUploadProps, M as MessageBubbleProps, S as SourceCardProps, b as ConfigProviderProps, c as ClientConfig, P as ProductCardProps, d as ProductCarouselProps, R as RemoteConfig } from './BatchProcessor-Dg18zZGk.js';
3
+ export { A as AuthenticationException, B as BatchOptions, e as BatchProcessor, f as BatchResult, g as ChartType, h as Chunk, i as ChunkOptions, j as ConfigFetcher, k as ConfigurationException, l as DecisionContext, E as EmbeddingFailedException, I as IRenderRule, m as IRendererStrategy, n as IntentCategory, L as LicenseTierConfig, o as LicenseValidationError, p as LicenseValidationRequest, q as LicenseValidationResponse, r as LicenseValidator, s as ProviderCredentials, t as ProviderNotFoundException, u as RateLimitException, v as RemoteEmbeddingConfig, w as RemoteLLMConfig, x as RemoteVectorConfig, y as RenderDecision, z as RenderType, F as RetrievalException, G as Retrivora, H as RetrivoraError, J as RetrivoraErrorCode, K as SDKVersionUnsupportedError, N as SDK_VERSION, O as isTransientError } from './BatchProcessor-Dg18zZGk.js';
4
4
  import { O as ObservabilityTrace, U as UseRagChatOptions, a as UseRagChatReturn, P as ProjectChatSettings } from './ILLMProvider-Y6aL5N8J.js';
5
5
  export { A as AuthMode, C as ChatMessage, b as ChatOptions, c as ChatResponse, E as EmbedOptions, d as EmbeddingConfig, e as EmbeddingProvider, I as ILLMProvider, f as IngestDocument, L as LLMConfig, g as LLMProvider, h as LatencyBreakdown, i as ProjectAiSettings, j as ProjectAuthSettings, k as ProjectBrandingSettings, l as ProjectTelemetrySettings, m as ProjectWidgetSettings, R as RAGConfig, n as RagConfig, o as RagMessage, p as RetrievalConfig, q as RetrievedChunk, T as ThemeMode, r as TokenUsage, s as UIConfig, t as UniversalRagConfig, u as UpsertDocument, V as VectorDBConfig, v as VectorDBProvider, w as VectorMatch, W as WidgetPosition, x as WorkflowConfig, y as createDefaultProjectSettings, z as normalizeProjectSettings, B as projectSettingsToUiConfig } from './ILLMProvider-Y6aL5N8J.js';
6
6
  import 'react';
@@ -47,7 +47,7 @@ declare function ChatWindow({ className, style, onClose, showClose, onResizeStar
47
47
 
48
48
  declare function DocumentUpload({ namespace, uploadUrl, retrivoraApiBase, onUploadComplete, className }: DocumentUploadProps): react_jsx_runtime.JSX.Element;
49
49
 
50
- declare function MessageBubble({ message, sources, isStreaming, primaryColor, accentColor, onAddToCart, viewportSize, onFeedback, }: MessageBubbleProps): react_jsx_runtime.JSX.Element;
50
+ declare function MessageBubble({ message, sources, isStreaming, primaryColor, accentColor, onAddToCart, viewportSize, showSources: showSourcesProp, onFeedback, }: MessageBubbleProps): react_jsx_runtime.JSX.Element;
51
51
 
52
52
  declare function SourceCard({ source, index }: SourceCardProps): react_jsx_runtime.JSX.Element;
53
53
 
package/dist/index.js CHANGED
@@ -345,6 +345,7 @@ function projectSettingsToUiConfig(settings) {
345
345
  welcomeMessage: settings.branding.welcomeMessage,
346
346
  poweredBy: settings.widget.showRetrivoraBranding ? "Retrivora AI" : "",
347
347
  allowUpload: settings.ai.fileUploadEnabled,
348
+ showSources: settings.ai.citationsEnabled,
348
349
  borderRadius: settings.branding.borderRadius <= 4 ? "sm" : settings.branding.borderRadius <= 8 ? "md" : settings.branding.borderRadius <= 16 ? "xl" : "full"
349
350
  };
350
351
  }
@@ -352,7 +353,7 @@ function projectSettingsToUiConfig(settings) {
352
353
  // package.json
353
354
  var package_default = {
354
355
  name: "@retrivora-ai/rag-engine",
355
- version: "2.4.2",
356
+ version: "2.4.5",
356
357
  description: "Retrivora AI is a plug-and-play AI engine for RAG chat experiences \u2014 generic vector DB + LLM provider, embeddable or standalone.",
357
358
  author: "Abhinav Alkuchi",
358
359
  license: "UNLICENSED",
@@ -389,8 +390,11 @@ var package_default = {
389
390
  import: "./dist/index.mjs"
390
391
  },
391
392
  "./style.css": "./dist/index.css",
393
+ "./style.min.css": "./dist/index.min.css",
392
394
  "./index.css": "./dist/index.css",
395
+ "./index.min.css": "./dist/index.min.css",
393
396
  "./styles.css": "./dist/index.css",
397
+ "./styles.min.css": "./dist/index.min.css",
394
398
  "./handlers": {
395
399
  types: "./dist/handlers/index.d.ts",
396
400
  require: "./dist/handlers/index.js",
@@ -421,15 +425,13 @@ var package_default = {
421
425
  },
422
426
  files: [
423
427
  "dist",
424
- "src",
425
- ".env.example",
426
428
  "README.md",
427
429
  "FREE_TIER_ARCHITECTURE.md"
428
430
  ],
429
431
  scripts: {
430
432
  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",
431
433
  build: "npm run build:pkg",
432
- "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",
434
+ "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 && npx @tailwindcss/cli -i src/tailwind.css -o dist/index.min.css --minify",
433
435
  lint: "eslint",
434
436
  typecheck: "tsc --noEmit -p tsconfig.build.json",
435
437
  clean: "rm -rf dist"
@@ -662,31 +664,46 @@ function ConfigProvider({
662
664
  if (config == null ? void 0 : config.visualStyle) flatUi.visualStyle = config.visualStyle;
663
665
  return __spreadValues(__spreadValues({}, flatUi), config == null ? void 0 : config.ui);
664
666
  }, [config]);
665
- const explicitSettings = (0, import_react.useMemo)(
666
- () => projectSettingsInput ? normalizeProjectSettings(projectId, projectSettingsInput) : void 0,
667
- [projectSettingsInput, projectId]
667
+ const [remoteSettings, setRemoteSettings] = (0, import_react.useState)(
668
+ () => projectSettingsInput ? normalizeProjectSettings(projectId, projectSettingsInput) : void 0
668
669
  );
669
- const [remoteSettings, setRemoteSettings] = (0, import_react.useState)(explicitSettings);
670
670
  const [isLoading, setIsLoading] = (0, import_react.useState)(false);
671
671
  (0, import_react.useEffect)(() => {
672
672
  var _a;
673
673
  let cancelled = false;
674
- const shouldLoad = autoLoadProjectSettings !== false && !explicitSettings && Boolean(licenseKeyInput || resolveHeader(headersInput, "x-license-key") || resolveHeader(headersInput, "authorization"));
674
+ const shouldLoad = autoLoadProjectSettings !== false && (!projectSettingsInput || autoLoadProjectSettings === true) && Boolean(licenseKeyInput || resolveHeader(headersInput, "x-license-key") || resolveHeader(headersInput, "authorization"));
675
675
  if (!shouldLoad) {
676
- setRemoteSettings(explicitSettings);
676
+ setRemoteSettings(projectSettingsInput ? normalizeProjectSettings(projectId, projectSettingsInput) : void 0);
677
677
  setIsLoading(false);
678
678
  return;
679
679
  }
680
680
  const licenseKey = licenseKeyInput || resolveHeader(headersInput, "x-license-key") || ((_a = resolveHeader(headersInput, "authorization")) == null ? void 0 : _a.replace(/^Bearer\s+/i, "")) || "";
681
+ function mergeOverrides(base, overrides) {
682
+ if (!overrides) return base;
683
+ return __spreadProps(__spreadValues({}, base), {
684
+ branding: overrides.branding ? __spreadValues(__spreadValues({}, base.branding), overrides.branding) : base.branding,
685
+ ai: overrides.ai ? __spreadValues(__spreadValues({}, base.ai), overrides.ai) : base.ai,
686
+ auth: overrides.auth ? __spreadValues(__spreadValues({}, base.auth), overrides.auth) : base.auth,
687
+ widget: overrides.widget ? __spreadValues(__spreadValues({}, base.widget), overrides.widget) : base.widget,
688
+ telemetry: overrides.telemetry ? __spreadValues(__spreadValues({}, base.telemetry), overrides.telemetry) : base.telemetry,
689
+ lifecycleHooks: overrides.lifecycleHooks || base.lifecycleHooks,
690
+ conversationFeatures: overrides.conversationFeatures || base.conversationFeatures
691
+ });
692
+ }
681
693
  async function loadProjectSettings() {
682
694
  setIsLoading(true);
683
695
  try {
684
696
  const remoteConfig = await ConfigFetcher.fetchRemoteConfig(projectId, licenseKey);
685
- if (!cancelled) {
686
- setRemoteSettings((remoteConfig == null ? void 0 : remoteConfig.projectSettings) || explicitSettings);
697
+ if (!cancelled && (remoteConfig == null ? void 0 : remoteConfig.projectSettings)) {
698
+ const merged2 = mergeOverrides(remoteConfig.projectSettings, projectSettingsInput);
699
+ setRemoteSettings(normalizeProjectSettings(projectId, merged2));
700
+ } else if (!cancelled) {
701
+ setRemoteSettings(projectSettingsInput ? normalizeProjectSettings(projectId, projectSettingsInput) : void 0);
687
702
  }
688
703
  } catch (e) {
689
- if (!cancelled) setRemoteSettings(explicitSettings);
704
+ if (!cancelled) {
705
+ setRemoteSettings(projectSettingsInput ? normalizeProjectSettings(projectId, projectSettingsInput) : void 0);
706
+ }
690
707
  } finally {
691
708
  if (!cancelled) setIsLoading(false);
692
709
  }
@@ -695,7 +712,7 @@ function ConfigProvider({
695
712
  return () => {
696
713
  cancelled = true;
697
714
  };
698
- }, [autoLoadProjectSettings, headersInput, licenseKeyInput, explicitSettings, projectId]);
715
+ }, [autoLoadProjectSettings, headersInput, licenseKeyInput, projectSettingsInput, projectId]);
699
716
  const merged = (0, import_react.useMemo)(() => {
700
717
  const settingsUi = remoteSettings ? projectSettingsToUiConfig(remoteSettings) : void 0;
701
718
  return {
@@ -793,7 +810,7 @@ function DocumentUpload({ namespace, uploadUrl, retrivoraApiBase, onUploadComple
793
810
  const targetNs = namespace || projectId || "default";
794
811
  if (targetNs) formData.append("namespace", targetNs);
795
812
  formData.append("dimension", dimension.toString());
796
- const apiBase = retrivoraApiBase || configuredApiBase || "/api/retrivora";
813
+ const apiBase = retrivoraApiBase || configuredApiBase || "https://www.retrivora.com/api/retrivora";
797
814
  const primaryUrl = uploadUrl || `${apiBase.replace(/\/$/, "")}/upload`;
798
815
  const uploadHeaders = __spreadValues(__spreadValues({}, configHeaders || {}), licenseKey ? { "x-license-key": licenseKey } : {});
799
816
  try {
@@ -2956,6 +2973,7 @@ function MessageBubble({
2956
2973
  accentColor = "#8b5cf6",
2957
2974
  onAddToCart,
2958
2975
  viewportSize = "large",
2976
+ showSources: showSourcesProp = true,
2959
2977
  onFeedback
2960
2978
  }) {
2961
2979
  var _a;
@@ -3161,7 +3179,7 @@ ${match.trim()}
3161
3179
  }
3162
3180
  ) }),
3163
3181
  !isUser && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: `flex items-center gap-3 mt-1.5 w-full flex-wrap ${isCompact ? "gap-2" : "gap-3"}`, children: [
3164
- sources && sources.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
3182
+ showSourcesProp && sources && sources.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
3165
3183
  "button",
3166
3184
  {
3167
3185
  onClick: () => setShowSources((s) => !s),
@@ -3200,7 +3218,7 @@ ${match.trim()}
3200
3218
  )
3201
3219
  ] }),
3202
3220
  /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "w-full flex flex-col gap-2 min-w-0", children: [
3203
- showSources && sources && sources.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "mt-1 flex flex-col gap-2", children: sources.map((src, i) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(SourceCard, { source: src, index: i }, src.id)) }),
3221
+ showSourcesProp && showSources && sources && sources.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "mt-1 flex flex-col gap-2", children: sources.map((src, i) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(SourceCard, { source: src, index: i }, src.id)) }),
3204
3222
  showTrace && message.trace && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ObservabilityPanel, { trace: message.trace, primaryColor })
3205
3223
  ] })
3206
3224
  ] })
@@ -3272,7 +3290,7 @@ function parseSseChunk(raw) {
3272
3290
  function useRagChat(projectId, options = {}) {
3273
3291
  const {
3274
3292
  apiUrl,
3275
- retrivoraApiBase = "/api/retrivora",
3293
+ retrivoraApiBase = "https://www.retrivora.com/api/retrivora",
3276
3294
  namespace,
3277
3295
  persist = true,
3278
3296
  onReply,
@@ -4066,7 +4084,7 @@ function ChatWindow({
4066
4084
  const [sessions, setSessions] = (0, import_react12.useState)([]);
4067
4085
  const fetchSessions = (0, import_react12.useCallback)(async () => {
4068
4086
  try {
4069
- const base = effectiveApiBase || "/api/retrivora";
4087
+ const base = effectiveApiBase || "https://www.retrivora.com/api/retrivora";
4070
4088
  const res = await fetch(`${base}/sessions`);
4071
4089
  if (res.ok) {
4072
4090
  const data = await res.json();
@@ -4278,7 +4296,7 @@ function ChatWindow({
4278
4296
  const timer = setTimeout(async () => {
4279
4297
  setIsSuggesting(true);
4280
4298
  try {
4281
- const base = effectiveApiBase || "/api/retrivora";
4299
+ const base = effectiveApiBase || "https://www.retrivora.com/api/retrivora";
4282
4300
  const primaryUrl = `${base}/suggestions`;
4283
4301
  const suggestionHeaders = __spreadValues(__spreadValues({
4284
4302
  "Content-Type": "application/json"
@@ -4566,6 +4584,7 @@ function ChatWindow({
4566
4584
  accentColor: ui.accentColor,
4567
4585
  onAddToCart,
4568
4586
  viewportSize,
4587
+ showSources: ui.showSources,
4569
4588
  onFeedback: submitFeedback
4570
4589
  }
4571
4590
  )
@@ -4580,7 +4599,8 @@ function ChatWindow({
4580
4599
  primaryColor: ui.primaryColor,
4581
4600
  accentColor: ui.accentColor,
4582
4601
  onAddToCart,
4583
- viewportSize
4602
+ viewportSize,
4603
+ showSources: ui.showSources
4584
4604
  }
4585
4605
  ),
4586
4606
  error && !licenseError && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex items-center gap-2 text-rose-500 dark:text-rose-400 text-sm bg-rose-50 dark:bg-rose-400/10 border border-rose-200 dark:border-rose-400/20 rounded-xl px-4 py-3", children: [