@retrivora-ai/rag-engine 2.4.3 → 2.4.6

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 (142) hide show
  1. package/README.md +22 -0
  2. package/dist/{BatchProcessor-zbQMaZHm.d.mts → BatchProcessor-BGslIR5l.d.mts} +65 -4
  3. package/dist/{BatchProcessor-D42E706a.d.ts → BatchProcessor-C3gY6kZ0.d.ts} +65 -4
  4. package/dist/handlers/index.js +668 -837
  5. package/dist/handlers/index.mjs +678 -837
  6. package/dist/index.css +5 -0
  7. package/dist/index.d.mts +4 -28
  8. package/dist/index.d.ts +4 -28
  9. package/dist/index.js +91 -43
  10. package/dist/index.min.css +1 -1
  11. package/dist/index.mjs +91 -43
  12. package/dist/server.d.mts +21 -7
  13. package/dist/server.d.ts +21 -7
  14. package/dist/server.js +731 -875
  15. package/dist/server.mjs +741 -875
  16. package/package.json +11 -4
  17. package/src/LicensedRetrivora.ts +0 -278
  18. package/src/app/api/chat/route.ts +0 -4
  19. package/src/app/api/health/route.ts +0 -5
  20. package/src/app/api/ingest/route.ts +0 -27
  21. package/src/app/api/suggestions/route.ts +0 -5
  22. package/src/app/api/upload/route.ts +0 -5
  23. package/src/app/constants.tsx +0 -270
  24. package/src/app/favicon.ico +0 -0
  25. package/src/app/globals.css +0 -449
  26. package/src/app/layout.tsx +0 -22
  27. package/src/app/page.tsx +0 -64
  28. package/src/app/types.ts +0 -30
  29. package/src/browser.tsx +0 -127
  30. package/src/components/ChatWidget.tsx +0 -393
  31. package/src/components/ChatWindow.tsx +0 -952
  32. package/src/components/CodeViewer.tsx +0 -56
  33. package/src/components/ConfigProvider.tsx +0 -141
  34. package/src/components/DocumentUpload.tsx +0 -354
  35. package/src/components/DynamicChart.tsx +0 -297
  36. package/src/components/HourglassLoader.tsx +0 -87
  37. package/src/components/MarkdownComponents.tsx +0 -186
  38. package/src/components/MessageBubble.tsx +0 -498
  39. package/src/components/ObservabilityPanel.tsx +0 -374
  40. package/src/components/ProductCard.tsx +0 -107
  41. package/src/components/ProductCarousel.tsx +0 -97
  42. package/src/components/SourceCard.tsx +0 -61
  43. package/src/components/ThemeProvider.tsx +0 -8
  44. package/src/components/ThemeToggle.tsx +0 -29
  45. package/src/components/ThinkingBlock.tsx +0 -75
  46. package/src/components/UIDispatcher.tsx +0 -342
  47. package/src/components/VisualizationRenderer.tsx +0 -621
  48. package/src/components/constants.tsx +0 -503
  49. package/src/config/ConfigBuilder.ts +0 -285
  50. package/src/config/EmbeddingStrategy.ts +0 -148
  51. package/src/config/LicenseConfigResolver.ts +0 -298
  52. package/src/config/RagConfig.ts +0 -328
  53. package/src/config/UniversalProfiles.ts +0 -82
  54. package/src/config/constants.ts +0 -64
  55. package/src/config/serverConfig.ts +0 -378
  56. package/src/config/uiConstants.ts +0 -47
  57. package/src/core/BatchProcessor.ts +0 -385
  58. package/src/core/CircuitBreaker.ts +0 -118
  59. package/src/core/ConfigFetcher.ts +0 -220
  60. package/src/core/ConfigResolver.ts +0 -165
  61. package/src/core/ConfigValidator.ts +0 -197
  62. package/src/core/DatabaseStorage.ts +0 -526
  63. package/src/core/FreeTierLimitsGuard.ts +0 -281
  64. package/src/core/LLMRouter.ts +0 -79
  65. package/src/core/LangChainAgent.ts +0 -132
  66. package/src/core/LicenseValidator.ts +0 -284
  67. package/src/core/LicenseVerifier.ts +0 -261
  68. package/src/core/MultiAgentCoordinator.ts +0 -239
  69. package/src/core/Pipeline.ts +0 -1279
  70. package/src/core/PluginManager.ts +0 -277
  71. package/src/core/ProjectSettings.ts +0 -247
  72. package/src/core/ProviderHealthCheck.ts +0 -133
  73. package/src/core/ProviderInterfaces.ts +0 -37
  74. package/src/core/ProviderRegistry.ts +0 -156
  75. package/src/core/QueryProcessor.ts +0 -399
  76. package/src/core/Retrivora.ts +0 -98
  77. package/src/core/VectorPlugin.ts +0 -193
  78. package/src/core/mcp.ts +0 -261
  79. package/src/exceptions/index.ts +0 -131
  80. package/src/handlers/index.ts +0 -1625
  81. package/src/hooks/useHydrated.ts +0 -13
  82. package/src/hooks/useProjectSettings.ts +0 -105
  83. package/src/hooks/useRagChat.ts +0 -436
  84. package/src/hooks/useStoredMessages.ts +0 -64
  85. package/src/index.css +0 -4269
  86. package/src/index.ts +0 -137
  87. package/src/lib/plugin.ts +0 -24
  88. package/src/llm/ILLMProvider.ts +0 -60
  89. package/src/llm/LLMFactory.ts +0 -141
  90. package/src/llm/providers/AnthropicProvider.ts +0 -215
  91. package/src/llm/providers/GeminiProvider.ts +0 -311
  92. package/src/llm/providers/GroqProvider.ts +0 -184
  93. package/src/llm/providers/OllamaProvider.ts +0 -232
  94. package/src/llm/providers/OpenAIProvider.ts +0 -188
  95. package/src/llm/providers/QwenProvider.ts +0 -199
  96. package/src/llm/providers/UniversalLLMAdapter.ts +0 -422
  97. package/src/llm/utils.ts +0 -46
  98. package/src/providers/graphdb/BaseGraphProvider.ts +0 -43
  99. package/src/providers/graphdb/SimpleGraphProvider.ts +0 -66
  100. package/src/providers/vectordb/BaseVectorProvider.ts +0 -98
  101. package/src/providers/vectordb/ChromaDBProvider.ts +0 -130
  102. package/src/providers/vectordb/MilvusProvider.ts +0 -134
  103. package/src/providers/vectordb/MongoDBProvider.ts +0 -250
  104. package/src/providers/vectordb/MultiTablePostgresProvider.ts +0 -461
  105. package/src/providers/vectordb/PineconeProvider.ts +0 -295
  106. package/src/providers/vectordb/PostgreSQLProvider.ts +0 -227
  107. package/src/providers/vectordb/QdrantProvider.ts +0 -294
  108. package/src/providers/vectordb/RedisProvider.ts +0 -105
  109. package/src/providers/vectordb/UniversalVectorProvider.ts +0 -221
  110. package/src/providers/vectordb/WeaviateProvider.ts +0 -172
  111. package/src/rag/DocumentChunker.ts +0 -144
  112. package/src/rag/EntityExtractor.ts +0 -90
  113. package/src/rag/LlamaIndexIngestor.ts +0 -60
  114. package/src/rag/Reranker.ts +0 -106
  115. package/src/rendering/IntentClassifier.ts +0 -167
  116. package/src/rendering/RendererRegistry.ts +0 -164
  117. package/src/rendering/RuleEngine.ts +0 -67
  118. package/src/rendering/VisualizationDecisionEngine.ts +0 -164
  119. package/src/rendering/__tests__/VisualizationDecisionEngine.test.ts +0 -237
  120. package/src/rendering/index.ts +0 -12
  121. package/src/rendering/rules/Rule1SpecificInfoRule.ts +0 -28
  122. package/src/rendering/rules/Rule2ComparisonRule.ts +0 -24
  123. package/src/rendering/rules/Rule3ProductDiscoveryRule.ts +0 -28
  124. package/src/rendering/rules/Rule4AnalyticalRule.ts +0 -38
  125. package/src/rendering/rules/Rule5MixedResponseRule.ts +0 -29
  126. package/src/rendering/rules/Rule6SmallResultSetRule.ts +0 -24
  127. package/src/rendering/rules/Rule7LargeTableRule.ts +0 -35
  128. package/src/rendering/types.ts +0 -96
  129. package/src/server.ts +0 -156
  130. package/src/tailwind.css +0 -194
  131. package/src/telemetry/TelemetryService.ts +0 -330
  132. package/src/types/chat.ts +0 -89
  133. package/src/types/index.ts +0 -278
  134. package/src/types/pdf-parse.d.ts +0 -13
  135. package/src/types/props.ts +0 -169
  136. package/src/utils/DocumentParser.ts +0 -111
  137. package/src/utils/ProductExtractor.ts +0 -350
  138. package/src/utils/SchemaMapper.ts +0 -176
  139. package/src/utils/UITransformer.ts +0 -1812
  140. package/src/utils/synonyms.ts +0 -80
  141. package/src/utils/templateUtils.ts +0 -78
  142. 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.3",
3
+ "version": "2.4.6",
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",
@@ -72,8 +72,6 @@
72
72
  },
73
73
  "files": [
74
74
  "dist",
75
- "src",
76
- ".env.example",
77
75
  "README.md",
78
76
  "FREE_TIER_ARCHITECTURE.md"
79
77
  ],
@@ -83,14 +81,19 @@
83
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",
84
82
  "lint": "eslint",
85
83
  "typecheck": "tsc --noEmit -p tsconfig.build.json",
84
+ "test": "jest",
86
85
  "clean": "rm -rf dist"
87
86
  },
88
87
  "peerDependencies": {
88
+ "axios": ">=1.0.0",
89
89
  "next": ">=15.0.0",
90
90
  "react": ">=18.0.0",
91
91
  "react-dom": ">=18.0.0"
92
92
  },
93
93
  "peerDependenciesMeta": {
94
+ "axios": {
95
+ "optional": true
96
+ },
94
97
  "next": {
95
98
  "optional": true
96
99
  }
@@ -99,9 +102,9 @@
99
102
  "@anthropic-ai/sdk": "^0.95.1",
100
103
  "@google/genai": "^0.8.0",
101
104
  "@google/generative-ai": "^0.24.1",
105
+ "@retrivora-ai/billing-guards": "*",
102
106
  "@pinecone-database/pinecone": "^7.2.0",
103
107
  "@types/papaparse": "^5.5.2",
104
- "axios": "^1.15.0",
105
108
  "lucide-react": "^1.8.0",
106
109
  "next-themes": "^0.4.6",
107
110
  "openai": "^6.34.0",
@@ -126,16 +129,20 @@
126
129
  "@tailwindcss/cli": "^4",
127
130
  "@tailwindcss/postcss": "^4",
128
131
  "@types/estree": "^1.0.9",
132
+ "@types/jest": "^30.0.0",
129
133
  "@types/node": "^20",
130
134
  "@types/pdf-parse": "^1.1.5",
131
135
  "@types/pg": "^8.20.0",
132
136
  "@types/react": "^19.2.14",
133
137
  "@types/react-dom": "^19.2.3",
138
+ "axios": "^1.15.0",
134
139
  "dotenv": "^17.4.2",
135
140
  "eslint": "^9",
136
141
  "eslint-config-next": "16.2.4",
142
+ "jest": "^30.4.2",
137
143
  "next": "16.2.10",
138
144
  "tailwindcss": "^4",
145
+ "ts-jest": "^29.4.12",
139
146
  "tsup": "^8.5.1",
140
147
  "typescript": "^5"
141
148
  }
@@ -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