@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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@retrivora-ai/rag-engine",
3
- "version": "2.4.2",
3
+ "version": "2.4.5",
4
4
  "description": "Retrivora AI is a plug-and-play AI engine for RAG chat experiences — generic vector DB + LLM provider, embeddable or standalone.",
5
5
  "author": "Abhinav Alkuchi",
6
6
  "license": "UNLICENSED",
@@ -37,8 +37,11 @@
37
37
  "import": "./dist/index.mjs"
38
38
  },
39
39
  "./style.css": "./dist/index.css",
40
+ "./style.min.css": "./dist/index.min.css",
40
41
  "./index.css": "./dist/index.css",
42
+ "./index.min.css": "./dist/index.min.css",
41
43
  "./styles.css": "./dist/index.css",
44
+ "./styles.min.css": "./dist/index.min.css",
42
45
  "./handlers": {
43
46
  "types": "./dist/handlers/index.d.ts",
44
47
  "require": "./dist/handlers/index.js",
@@ -69,15 +72,13 @@
69
72
  },
70
73
  "files": [
71
74
  "dist",
72
- "src",
73
- ".env.example",
74
75
  "README.md",
75
76
  "FREE_TIER_ARCHITECTURE.md"
76
77
  ],
77
78
  "scripts": {
78
79
  "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",
79
80
  "build": "npm run build:pkg",
80
- "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",
81
+ "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",
81
82
  "lint": "eslint",
82
83
  "typecheck": "tsc --noEmit -p tsconfig.build.json",
83
84
  "clean": "rm -rf dist"
@@ -1,278 +0,0 @@
1
- /**
2
- * LicensedRetrivora — End-user facing SDK that only requires:
3
- * - License Key (JWT from Retrivora)
4
- * - Project ID (workspace identifier)
5
- *
6
- * Everything else (models, vector DB, embeddings) is resolved from
7
- * the Retrivora admin dashboard based on tier.
8
- *
9
- * NOTE: This is a SERVER-ONLY module. Import from '@retrivora-ai/rag-engine/server'
10
- * Do NOT import in client components.
11
- */
12
-
13
- import { LicenseConfigResolver, LicenseTierConfig } from './config/LicenseConfigResolver';
14
- import { Pipeline } from './core/Pipeline';
15
- import { RagConfig, VectorDBConfig, LLMConfig, EmbeddingConfig } from './config/RagConfig';
16
- import {
17
- initializeTelemetryService,
18
- getTelemetryService,
19
- shutdownTelemetryService,
20
- EventType,
21
- } from './telemetry/TelemetryService';
22
- import { IngestDocument, ChatResponse } from './types';
23
-
24
- export interface LicensedRetrivoraOptions {
25
- licenseKey: string;
26
- projectId: string;
27
- userTelemetryUrl?: string; // Optional: user's telemetry endpoint
28
- enableTelemetry?: boolean; // Default: true
29
- }
30
-
31
- /**
32
- * End-user facing SDK for Retrivora RAG engine
33
- */
34
- export class LicensedRetrivora {
35
- private licenseKey: string;
36
- private projectId: string;
37
- private pipeline?: Pipeline;
38
- private ragConfig?: RagConfig;
39
- private tierConfig?: LicenseTierConfig;
40
- private initialized: boolean = false;
41
-
42
- constructor(options: LicensedRetrivoraOptions) {
43
- this.licenseKey = options.licenseKey;
44
- this.projectId = options.projectId;
45
-
46
- // Initialize telemetry if enabled
47
- if (options.enableTelemetry !== false) {
48
- initializeTelemetryService(this.projectId, this.licenseKey, options.userTelemetryUrl);
49
- }
50
- }
51
-
52
- /**
53
- * Initialize the SDK by validating license and fetching config
54
- */
55
- private generateId(): string {
56
- return `${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;
57
- }
58
-
59
- /**
60
- * Initialize the SDK by validating license and fetching config
61
- */
62
- async initialize(): Promise<void> {
63
- if (this.initialized) {
64
- //console.log('[LicensedRetrivora] Already initialized');
65
- return;
66
- }
67
-
68
- //console.log('[LicensedRetrivora] Initializing with license key...');
69
- const operationId = this.generateId();
70
-
71
- try {
72
- // Resolve configuration from license tier
73
- const { llmConfig, embeddingConfig, vectorDbConfig, tierConfig } =
74
- await LicenseConfigResolver.resolveFromLicense(this.licenseKey, this.projectId);
75
-
76
- this.tierConfig = tierConfig;
77
-
78
- // Log successful configuration load
79
- const telemetry = getTelemetryService();
80
- if (telemetry) {
81
- telemetry.recordEvent({
82
- eventType: EventType.CONFIGURATION_LOADED,
83
- operationId,
84
- metadata: {
85
- tier: tierConfig.tier,
86
- llmModel: tierConfig.llmModel,
87
- embeddingModel: tierConfig.embeddingModel,
88
- vectorDb: tierConfig.vectorDb.provider,
89
- },
90
- });
91
- }
92
-
93
- // Build RAG config
94
- this.ragConfig = {
95
- projectId: this.projectId,
96
- licenseKey: this.licenseKey,
97
- llm: llmConfig,
98
- embedding: embeddingConfig,
99
- vectorDb: vectorDbConfig,
100
- rag: {
101
- topK: tierConfig.topK,
102
- chunkSize: tierConfig.chunkSize,
103
- chunkOverlap: tierConfig.chunkOverlap,
104
- scoreThreshold: 0,
105
- },
106
- telemetry: {
107
- enabled: true,
108
- url: 'https://www.retrivora.com/api/telemetry',
109
- },
110
- };
111
-
112
- // Initialize pipeline
113
- this.pipeline = new Pipeline(this.ragConfig);
114
- await this.pipeline.initialize();
115
-
116
- this.initialized = true;
117
- //console.log(`[LicensedRetrivora] Initialized successfully for tier: ${tierConfig.tier}`);
118
- } catch (error) {
119
- const telemetry = getTelemetryService();
120
- if (telemetry && error instanceof Error) {
121
- telemetry.recordError(error, { operationId });
122
- await telemetry.flush();
123
- }
124
- throw error;
125
- }
126
- }
127
-
128
- /**
129
- * Ingest documents (upload files to vector database)
130
- * Returns success/failure status to end-user
131
- */
132
- async ingest(documents: IngestDocument[]): Promise<{ success: boolean; message: string; documentIds?: string[] }> {
133
- if (!this.initialized || !this.pipeline) {
134
- throw new Error('[LicensedRetrivora] SDK not initialized. Call initialize() first.');
135
- }
136
-
137
- const operationId = this.generateId();
138
- const telemetry = getTelemetryService();
139
- const startTime = Date.now();
140
-
141
- try {
142
- //console.log(`[LicensedRetrivora] Starting ingestion of ${documents.length} document(s)`);
143
-
144
- // Ingest documents
145
- const results = await this.pipeline.ingest(documents);
146
-
147
- const durationMs = Date.now() - startTime;
148
-
149
- // Record successful ingestion
150
- if (telemetry) {
151
- for (const result of results) {
152
- const origDoc = documents.find(d => String(d.docId) === String(result.docId));
153
- const size = origDoc ? new TextEncoder().encode(origDoc.content).length : 0;
154
- telemetry.recordDocumentIngested({
155
- documentId: String(result.docId),
156
- documentName: String(result.docId),
157
- documentSize: size,
158
- chunksGenerated: result.chunksIngested,
159
- durationMs,
160
- });
161
- }
162
- }
163
-
164
- const successCount = results.length;
165
- return {
166
- success: successCount > 0,
167
- message: `Successfully ingested ${successCount} document(s). Data is now available for search.`,
168
- documentIds: results.map(r => String(r.docId)),
169
- };
170
- } catch (error) {
171
- const durationMs = Date.now() - startTime;
172
-
173
- if (telemetry && error instanceof Error) {
174
- telemetry.recordError(error, { operationId, durationMs });
175
- await telemetry.flush();
176
- }
177
-
178
- console.error('[LicensedRetrivora] Ingestion failed:', error);
179
- throw error;
180
- }
181
- }
182
-
183
- /**
184
- * Execute a user query and get response
185
- * Returns only the response text and sources (abstracted from underlying models)
186
- */
187
- async query(queryText: string, options?: { topK?: number }): Promise<ChatResponse> {
188
- if (!this.initialized || !this.pipeline) {
189
- throw new Error('[LicensedRetrivora] SDK not initialized. Call initialize() first.');
190
- }
191
-
192
- const operationId = this.generateId();
193
- const telemetry = getTelemetryService();
194
- const startTime = Date.now();
195
-
196
- try {
197
- //console.log(`[LicensedRetrivora] Executing query: "${queryText.substring(0, 100)}..."`);
198
-
199
- // Execute query
200
- const response = await this.pipeline.runNormalQuery(queryText);
201
-
202
- const durationMs = Date.now() - startTime;
203
-
204
- // Record query execution
205
- if (telemetry) {
206
- telemetry.recordQueryExecuted({
207
- queryText,
208
- resultCount: response.sources?.length || 0,
209
- durationMs,
210
- operationId,
211
- });
212
- }
213
-
214
- // Return abstracted response (hide implementation details)
215
- return {
216
- reply: response.reply,
217
- sources: response.sources,
218
- };
219
- } catch (error) {
220
- const durationMs = Date.now() - startTime;
221
-
222
- if (telemetry && error instanceof Error) {
223
- telemetry.recordError(error, { operationId, durationMs });
224
- await telemetry.flush();
225
- }
226
-
227
- console.error('[LicensedRetrivora] Query failed:', error);
228
- throw error;
229
- }
230
- }
231
-
232
- /**
233
- * Get license tier information (for UI display if needed)
234
- */
235
- async getTierInfo(): Promise<{ tier: string; model: string; embeddingModel: string }> {
236
- if (!this.ragConfig || !this.tierConfig) {
237
- throw new Error('[LicensedRetrivora] SDK not initialized.');
238
- }
239
-
240
- return {
241
- tier: this.tierConfig.tier,
242
- model: this.ragConfig.llm.model,
243
- embeddingModel: this.ragConfig.embedding.model,
244
- };
245
- }
246
-
247
- /**
248
- * Cleanup and shutdown
249
- */
250
- async shutdown(): Promise<void> {
251
- await shutdownTelemetryService();
252
- this.initialized = false;
253
- //console.log('[LicensedRetrivora] Shutdown complete');
254
- }
255
-
256
- /**
257
- * Check if SDK is initialized
258
- */
259
- isInitialized(): boolean {
260
- return this.initialized;
261
- }
262
-
263
- /**
264
- * Get current RAG configuration (for debugging)
265
- */
266
- getConfig(): RagConfig | undefined {
267
- return this.ragConfig;
268
- }
269
- }
270
-
271
- /**
272
- * Convenience function to create and initialize SDK in one call
273
- */
274
- export async function createRetrivora(options: LicensedRetrivoraOptions): Promise<LicensedRetrivora> {
275
- const retrivora = new LicensedRetrivora(options);
276
- await retrivora.initialize();
277
- return retrivora;
278
- }
@@ -1,4 +0,0 @@
1
- import { createStreamHandler } from '@/handlers';
2
- import { plugin } from '@/lib/plugin';
3
-
4
- export const POST = createStreamHandler(plugin);
@@ -1,5 +0,0 @@
1
- import { createHealthHandler } from '@/handlers';
2
- import { plugin } from '@/lib/plugin';
3
-
4
- export const GET = createHealthHandler(plugin);
5
-
@@ -1,27 +0,0 @@
1
- /**
2
- * POST /api/ingest
3
- *
4
- * Ingests one or more documents into the vector DB for a project.
5
- *
6
- * Request body:
7
- * {
8
- * documents: Array<{
9
- * docId: string
10
- * content: string
11
- * metadata?: Record<string, unknown>
12
- * }>
13
- * namespace?: string – optional project namespace override
14
- * }
15
- *
16
- * Response:
17
- * {
18
- * results: Array<{ docId: string; chunksIngested: number }>
19
- * totalChunks: number
20
- * }
21
- */
22
-
23
- import { createIngestHandler } from '@/handlers';
24
- import { plugin } from '@/lib/plugin';
25
-
26
- export const POST = createIngestHandler(plugin);
27
-
@@ -1,5 +0,0 @@
1
- import { createSuggestionsHandler } from '@/handlers';
2
- import { plugin } from '@/lib/plugin';
3
-
4
- export const POST = createSuggestionsHandler(plugin);
5
-
@@ -1,5 +0,0 @@
1
- import { createUploadHandler } from '@/handlers';
2
- import { plugin } from '@/lib/plugin';
3
-
4
- export const POST = createUploadHandler(plugin);
5
-
@@ -1,270 +0,0 @@
1
- import React from 'react';
2
- import {
3
- Zap,
4
- Database,
5
- Layers,
6
- Search,
7
- Box,
8
- Package,
9
- Activity,
10
- Hexagon,
11
- Sparkles,
12
- Bot,
13
- Brain,
14
- Rabbit,
15
- Code,
16
- Terminal,
17
- FileText,
18
- Puzzle,
19
- MessageSquare,
20
- Cpu,
21
- Cloud,
22
- } from 'lucide-react';
23
- import { ArchitectureCardProps, Snippet, PipelineStep, ProviderPill } from './types';
24
-
25
- export const LANDING_PAGE_CONTENT = {
26
- hero: {
27
- badge: 'Dynamic & Universal Retrivora AI',
28
- title: 'The Universal Bridge for Generative AI',
29
- subtitle: 'Retrivora AI is a vendor-agnostic RAG engine that connects any Document to any LLM and Vector Database in minutes.',
30
- },
31
- lifecycle: {
32
- title: 'The RAG Lifecycle',
33
- },
34
- guide: {
35
- title: 'Interactive Guide',
36
- subtitle: 'Universal RAG integration for your Next.js applications in minutes.',
37
- }
38
- };
39
-
40
- export const VECTOR_DATABASES: ProviderPill[] = [
41
- { Icon: Zap, label: 'Pinecone' },
42
- { Icon: Database, label: 'PostgreSQL' },
43
- { Icon: Layers, label: 'MongoDB' },
44
- { Icon: Box, label: 'Qdrant' },
45
- { Icon: Search, label: 'Milvus' },
46
- { Icon: Package, label: 'ChromaDB' },
47
- { Icon: Activity, label: 'Redis' },
48
- { Icon: Hexagon, label: 'Weaviate' },
49
- ];
50
-
51
- export const AI_MODELS: ProviderPill[] = [
52
- { Icon: Rabbit, label: 'Ollama' },
53
- { Icon: Sparkles, label: 'OpenAI' },
54
- { Icon: Bot, label: 'Anthropic' },
55
- { Icon: Brain, label: 'Gemini' },
56
- { Icon: Cpu, label: 'Groq' },
57
- { Icon: Cloud, label: 'Qwen' },
58
- { Icon: Code, label: 'Copilot' },
59
- { Icon: Terminal, label: 'LiteLLM' },
60
- ];
61
-
62
- export const PIPELINE_STEPS: PipelineStep[] = [
63
- {
64
- step: '01',
65
- Icon: FileText,
66
- title: 'Ingest',
67
- desc: 'Universal support for PDF, DOCX, CSV, and JSON. Documents are parsed, chunked, and embedded.',
68
- colors: { from: '#10b981', to: '#14b8a6' },
69
- },
70
- {
71
- step: '02',
72
- Icon: Search,
73
- title: 'Retrieve',
74
- desc: 'Queries are converted to vectors. Semantic search finds context across any configured Vector DB.',
75
- colors: { from: '#14b8a6', to: '#06b6d4' },
76
- },
77
- {
78
- step: '03',
79
- Icon: Puzzle,
80
- title: 'Augment',
81
- desc: 'Retrieved context is injected into the LLM prompt with namespaced project isolation.',
82
- colors: { from: '#06b6d4', to: '#3b82f6' },
83
- },
84
- {
85
- step: '04',
86
- Icon: MessageSquare,
87
- title: 'Generate',
88
- desc: 'Providers like OpenAI, Anthropic, or Gemini produce grounded, source-cited responses.',
89
- colors: { from: '#3b82f6', to: '#6366f1' },
90
- },
91
- ];
92
-
93
- export const SNIPPETS: Snippet[] = [
94
- {
95
- id: 'npm-setup',
96
- title: 'NPM Setup',
97
- language: 'typescript',
98
- description: 'How to install and import the client vs server components correctly in your application.',
99
- code: `// ─── TERMINAL / BASH ───
100
- // Run this command to install the package in your project:
101
- // npm install @retrivora-ai/rag-engine
102
-
103
- // ─── SERVER API ROUTER (src/app/api/retrivora/[[...retrivora]]/route.ts) ───
104
- // Create a single catch-all file to handle all server endpoints dynamically:
105
- import { createRagHandler } from '@retrivora-ai/rag-engine/handlers';
106
-
107
- export const { GET, POST } = createRagHandler();
108
-
109
- // ─── CLIENT WIDGET (src/app/layout.tsx) ───
110
- // Import the React widget and config context (styles are auto-injected!):
111
- import { ConfigProvider, ChatWidget } from '@retrivora-ai/rag-engine';`,
112
- },
113
- {
114
- id: 'pipeline',
115
- title: 'Pipeline API',
116
- language: 'typescript',
117
- description: 'Orchestrate the full RAG flow programmatically with the Pipeline class.',
118
- code: `import { Pipeline, getRagConfig } from '@retrivora-ai/rag-engine/server';
119
-
120
- const config = getRagConfig();
121
- const pipeline = new Pipeline(config);
122
-
123
- // Ingest documents
124
- await pipeline.ingest([{
125
- docId: 'doc-1',
126
- content: 'Retrivora AI simplifies RAG...',
127
- metadata: { source: 'docs' }
128
- }]);
129
-
130
- // Ask a question
131
- const { reply, sources } = await pipeline.ask('How does Retrivora work?');`,
132
- },
133
- {
134
- id: 'handlers',
135
- title: 'Route Handlers',
136
- language: 'typescript',
137
- description: 'Mount pre-built API endpoints. Configuration is automatically read from environment variables, or can be passed explicitly.',
138
- code: `// ─── OPTION A: ZERO CONFIG (Reads from environment variables) ───
139
- // src/app/api/chat/route.ts
140
- import { createStreamHandler } from '@retrivora-ai/rag-engine/handlers';
141
- export const POST = createStreamHandler();
142
-
143
- // ─── OPTION B: EXPLICIT CONFIGURATION ───
144
- // src/app/api/chat/route.ts
145
- import { createStreamHandler } from '@retrivora-ai/rag-engine/handlers';
146
-
147
- export const POST = createStreamHandler({
148
- vectorDb: {
149
- provider: 'pinecone',
150
- apiKey: process.env.CUSTOM_PINECONE_KEY,
151
- indexName: 'docs-index',
152
- },
153
- llm: {
154
- provider: 'openai',
155
- apiKey: process.env.CUSTOM_OPENAI_KEY,
156
- model: 'gpt-4o',
157
- }
158
- });`,
159
- },
160
- {
161
- id: 'ui',
162
- title: 'React Components',
163
- language: 'typescript',
164
- description: 'Configure and embed themeable UI widgets using the ConfigProvider context.',
165
- code: `import { ConfigProvider, ChatWidget } from '@retrivora-ai/rag-engine';
166
-
167
- export default function Layout({ children }) {
168
- return (
169
- <ConfigProvider config={{
170
- projectId: 'my-project-id',
171
- ui: {
172
- title: 'Retrivora Assistant',
173
- welcomeMessage: 'Hi! Ask me anything about our software.',
174
- primaryColor: '#4f46e5', // Custom primary brand color
175
- accentColor: '#8b5cf6', // Custom accent gradient color
176
- borderRadius: 'lg', // 'none' | 'sm' | 'md' | 'lg' | 'xl'
177
- allowUpload: true, // Toggle custom file uploading
178
- }
179
- }}>
180
- {children}
181
- <ChatWidget position="bottom-right" />
182
- </ConfigProvider>
183
- );
184
- }`,
185
- },
186
- {
187
- id: 'config',
188
- title: 'Config Builder',
189
- language: 'typescript',
190
- description: 'Fluent, type-safe configuration builder for granular control over providers.',
191
- code: `import { ConfigBuilder } from '@retrivora-ai/rag-engine/server';
192
-
193
- const config = new ConfigBuilder()
194
- .vectorDb('pinecone', { apiKey: '...', indexName: 'docs' })
195
- .llm('ollama', 'llama3.2')
196
- .embedding('ollama', 'nomic-embed-text')
197
- .build();`,
198
- },
199
- {
200
- id: 'env',
201
- title: 'Environment',
202
- language: 'bash',
203
- description: 'The exact environment variable structure required for auto-configuration.',
204
- code: `# Project Identity
205
- RAG_PROJECT_ID=my-project
206
-
207
- # Vector DB
208
- VECTOR_DB_PROVIDER=pinecone
209
- PINECONE_API_KEY=pcsk_...
210
- VECTOR_DB_INDEX=products
211
-
212
- # AI Services
213
- LLM_PROVIDER=openai
214
- LLM_MODEL=gpt-4o
215
- OPENAI_API_KEY=sk-...`,
216
- },
217
- ];
218
-
219
- export const ARCHITECTURE_CARDS: ArchitectureCardProps[] = [
220
- {
221
- icon: <Database className="text-indigo-600" />,
222
- title: 'Vector Store',
223
- description: 'Universal support for Pinecone, PGVector, MongoDB, Milvus, Qdrant, and more.',
224
- badge: 'Vector DB',
225
- badgeColor: 'bg-indigo-50 dark:bg-indigo-500/10 text-indigo-600 dark:text-indigo-400 border-indigo-200 dark:border-indigo-500/20',
226
- },
227
- {
228
- icon: <Zap className="text-amber-500" />,
229
- title: 'Embeddings',
230
- description: 'Seamlessly switch between OpenAI, Ollama, or custom embedding providers.',
231
- badge: 'Models',
232
- badgeColor: 'bg-amber-50 dark:bg-amber-500/10 text-amber-600 dark:text-amber-400 border-amber-200 dark:border-amber-500/20',
233
- },
234
- {
235
- icon: <Bot className="text-emerald-500" />,
236
- title: 'LLM Orchestration',
237
- description: 'Optimized inference across OpenAI, Anthropic, Gemini, and local LLMs.',
238
- badge: 'Inference',
239
- badgeColor: 'bg-emerald-50 dark:bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 border-emerald-200 dark:border-emerald-500/20',
240
- },
241
- ];
242
-
243
- export const QUICK_START_STEPS = [
244
- { id: 'npm-setup', text: 'Install Package & CSS' },
245
- { id: 'env', text: 'Configure .env.local' },
246
- { id: 'handlers', text: 'Mount API Handlers' },
247
- { id: 'ui', text: 'Drop ChatWidget UI' },
248
- ];
249
-
250
- export const ADVANCED_STEPS = [
251
- { id: 'pipeline', text: 'Programmatic SDK' },
252
- { id: 'config', text: 'Fluent Config Builder' },
253
- ];
254
-
255
- export const API_ENDPOINTS = ['chat', 'health', 'ingest', 'upload'];
256
-
257
- export const CHAT_SUGGESTIONS = [
258
- 'What can you help me with?',
259
- 'Summarise the key topics',
260
- 'Show me an example'
261
- ];
262
-
263
- export const BORDER_RADIUS_MAP: Record<string, string> = {
264
- none: 'rounded-none',
265
- sm: 'rounded-sm',
266
- md: 'rounded-md',
267
- lg: 'rounded-lg',
268
- xl: 'rounded-xl',
269
- full: 'rounded-3xl',
270
- };
Binary file