@retrivora-ai/rag-engine 1.9.7 → 1.9.8

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 (58) hide show
  1. package/README.md +127 -135
  2. package/dist/{ILLMProvider-Bhk6zJOK.d.mts → ILLMProvider-B8ROITYK.d.mts} +57 -2
  3. package/dist/{ILLMProvider-Bhk6zJOK.d.ts → ILLMProvider-B8ROITYK.d.ts} +57 -2
  4. package/dist/handlers/index.d.mts +2 -2
  5. package/dist/handlers/index.d.ts +2 -2
  6. package/dist/handlers/index.js +2198 -457
  7. package/dist/handlers/index.mjs +2195 -457
  8. package/dist/{index-BJ4cd-t5.d.mts → index-B8PbEFSY.d.mts} +12 -2
  9. package/dist/{index-Bu7T6xgr.d.ts → index-BCPKUAVL.d.ts} +27 -52
  10. package/dist/{index-C3SVtPYg.d.mts → index-CrxCy36A.d.mts} +27 -52
  11. package/dist/{index-B9J_XEh0.d.ts → index-DNvoi-sV.d.ts} +12 -2
  12. package/dist/index.css +578 -273
  13. package/dist/index.d.mts +29 -7
  14. package/dist/index.d.ts +29 -7
  15. package/dist/index.js +1160 -282
  16. package/dist/index.mjs +1185 -292
  17. package/dist/server.d.mts +62 -6
  18. package/dist/server.d.ts +62 -6
  19. package/dist/server.js +2061 -306
  20. package/dist/server.mjs +2055 -306
  21. package/package.json +11 -7
  22. package/src/app/constants.tsx +37 -7
  23. package/src/components/AmbientBackground.tsx +10 -10
  24. package/src/components/ArchitectureCard.tsx +43 -7
  25. package/src/components/ArchitectureCardsSection.tsx +37 -4
  26. package/src/components/ChatWidget.tsx +2 -1
  27. package/src/components/ChatWindow.tsx +4 -1
  28. package/src/components/CodeViewer.tsx +19 -14
  29. package/src/components/DocViewer.tsx +43 -49
  30. package/src/components/Documentation.tsx +71 -51
  31. package/src/components/Hero.tsx +103 -20
  32. package/src/components/Lifecycle.tsx +65 -25
  33. package/src/components/MarkdownComponents.tsx +44 -1
  34. package/src/components/MessageBubble.tsx +162 -50
  35. package/src/components/constants.tsx +4 -0
  36. package/src/config/RagConfig.ts +46 -0
  37. package/src/config/constants.ts +4 -0
  38. package/src/config/serverConfig.ts +15 -0
  39. package/src/core/ConfigResolver.ts +6 -0
  40. package/src/core/DatabaseStorage.ts +469 -0
  41. package/src/core/LicenseVerifier.ts +154 -0
  42. package/src/core/MultiAgentCoordinator.ts +239 -0
  43. package/src/core/Pipeline.ts +146 -15
  44. package/src/core/Retrivora.ts +6 -0
  45. package/src/core/VectorPlugin.ts +12 -3
  46. package/src/core/mcp.ts +261 -0
  47. package/src/handlers/index.ts +449 -63
  48. package/src/hooks/useRagChat.ts +96 -42
  49. package/src/hooks/useStoredMessages.ts +15 -4
  50. package/src/index.ts +5 -0
  51. package/src/llm/LLMFactory.ts +9 -1
  52. package/src/llm/providers/GroqProvider.ts +176 -0
  53. package/src/llm/providers/QwenProvider.ts +191 -0
  54. package/src/server.ts +7 -0
  55. package/src/types/chat.ts +14 -0
  56. package/src/types/props.ts +12 -0
  57. package/.env.example +0 -80
  58. package/LICENSE.txt +0 -21
package/README.md CHANGED
@@ -1,175 +1,167 @@
1
- # @retrivora-ai/rag-engine
1
+ # Retrivora RAG Engine SDK
2
2
 
3
- > **Retrivora AI is a plug-and-play AI engine for RAG chat experiences** that can be embedded into Next.js apps or used as a standalone demo app. Bring your own vector database, LLM, embeddings, and UI branding.
4
-
5
- [![NPM Version](https://img.shields.io/npm/v/@retrivora-ai/rag-engine?style=flat-square&color=10b981)](https://www.npmjs.com/package/@retrivora-ai/rag-engine)
6
- [![NPM Downloads](https://img.shields.io/npm/dm/@retrivora-ai/rag-engine?style=flat-square&color=3b82f6)](https://www.npmjs.com/package/@retrivora-ai/rag-engine)
7
- [![GitHub](https://img.shields.io/badge/GitHub-Repository-black?style=flat-square&logo=github)](https://github.com/abhinav1201/ai-accelerator)
8
- ![Next.js](https://img.shields.io/badge/Next.js-14+-black?style=flat-square&logo=next.js)
9
- ![TailwindCSS](https://img.shields.io/badge/TailwindCSS-v4-38bdf8?style=flat-square&logo=tailwindcss)
3
+ Retrivora is a developer-first, vendor-agnostic Retrieval-Augmented Generation (RAG) SDK. It bridges any document source to leading vector databases and LLMs with a clean, standardized API and pre-built, responsive React UI components.
10
4
 
11
5
  ---
12
6
 
13
- ## Features (v1.0.0)
7
+ ## 1. What is the Retrivora SDK?
14
8
 
15
- | Category | Options |
16
- |---|---|
17
- | **Vector DBs** | Pinecone, pgVector (PostgreSQL), MongoDB Atlas, ChromaDB, Qdrant, Milvus, Weaviate, Redis |
18
- | **LLM Providers** | OpenAI, Anthropic Claude, Google Gemini, Ollama, LiteLLM, Universal REST |
19
- | **Integrations** | **LangChain** (Agentic orchestration), **LlamaIndex** (Semantic chunking) |
20
- | **Document Ingestion** | Universal support for **PDF**, **DOCX**, **CSV**, **JSON**, **MD**, **TXT** |
21
- | **Architecture** | **Modular & Pluggable** registry-based system with static health checks & validators |
22
- | **RAG Patterns** | Simple, Hybrid, Graph-based, and Agentic workflows |
9
+ The SDK is a unified suite designed to abstract the complexity of building production-grade RAG systems. It handles:
10
+ - **Document Chunking & Ingestion**: Splits text recursively, extracts semantic embeddings, and uploads vectors in batched operations.
11
+ - **Pluggable Architecture**: Switch vector databases (Pinecone, pgvector, MongoDB Vector, Qdrant, etc.) and LLMs (OpenAI, Anthropic Claude, Google Gemini, Ollama) by changing a single configuration key without rewriting database or chat code.
12
+ - **Client-Safe Proxying**: Exposes clean route handler helpers for Next.js and Node.js backend servers, protecting database connection strings and LLM API keys from frontend exposure.
13
+ - **Drop-in UI Elements**: Exports polished, highly customisable React UI elements (`ChatWidget`, `ChatWindow`, `DocumentUpload`) built with Tailwind CSS v4.
23
14
 
24
15
  ---
25
16
 
26
- ## 🚀 How it Works
17
+ ## 2. Architecture & Implementation
27
18
 
28
- Retrivora AI acts as a universal bridge between your data and your users. It normalizes different AI providers and Vector databases into a single interface using a **registry-based architecture**.
19
+ The SDK is built with modularity, performance, and security at its core:
29
20
 
30
- 1. **Ingest**: Upload or send documents to the `/api/upload` endpoint. They are parsed and chunked using **LlamaIndex** strategies if configured.
31
- 2. **Retrieve**: Queries are processed via the [QueryProcessor](file:///src/core/QueryProcessor.ts) to extract semantic hints and filter criteria.
32
- 3. **Generate**: Context is retrieved and processed through a [Pipeline](file:///src/core/Pipeline.ts) (or [LangChainAgent](file:///src/core/LangChainAgent.ts)) to produce grounded, streaming responses.
21
+ ```
22
+ ┌─────────────────────────────────────────────────────────┐
23
+ │ Host Client │
24
+ │ (Next.js App / React Frontend) │
25
+ └────────────┬───────────────────────────────▲────────────┘
26
+ │ Ingest / Queries │ Render UI
27
+ ┌────────────▼───────────────────────────────┴────────────┐
28
+ │ Retrivora Facade │
29
+ │ (Config Validation & Resolver) │
30
+ └────────────┬────────────────────────────────────────────┘
31
+
32
+
33
+ ┌─────────────────────────────────────────────────────────┐
34
+ │ LicenseVerifier (Local Cryptography) │
35
+ │ Verifies signed JWT with Public Key locally │
36
+ └────────────┬────────────────────────────────────────────┘
37
+
38
+
39
+ ┌─────────────────────────────────────────────────────────┐
40
+ │ Pipeline Engine │
41
+ │ (BatchProcessor, Chunker, Router, LRU Cache) │
42
+ └────────────┬───────────────────────────────┬────────────┘
43
+ │ │
44
+ ▼ ▼
45
+ ┌─────────────────────────┐ ┌─────────────────────────┐
46
+ │ LLM Adapters │ │ Vector DB Providers │
47
+ │ (OpenAI, Gemini, etc.) │ │ (Pinecone, Mongo, SQL) │
48
+ └─────────────────────────┘ └─────────────────────────┘
49
+ ```
33
50
 
34
- ### 📦 Installation
51
+ ### Key Components:
52
+ 1. **Facade Pattern (`Retrivora.ts`)**: Serves as the primary public entry point. It wraps configuration resolution, schema validation, and lifecycle calls into simple methods like `initialize()`, `ingest()`, `ask()`, and `askStream()`.
53
+ 2. **Resilient Batch Operations (`BatchProcessor.ts`)**: Bulk operations (such as vector upserts and document indexing) are managed by a custom concurrency runner that chunks workloads, tracks partial successes, and applies exponential backoff with jitter on transient network/rate-limit failures.
54
+ 3. **Local Cryptographic Licensing (`LicenseVerifier.ts`)**: Production license keys are issued as cryptographically signed JWT tokens. The SDK parses, validates expiration, and ensures matching project namespaces locally using Node's `crypto` module. This provides offline-friendly, zero-latency key verification with local fail-open warnings in dev mode and fail-closed blockades in production.
55
+ 4. **Smart Embedding Cache**: Implements an in-memory LRU-bounded cache within the pipeline to avoid re-embedding identical search queries inside the same process lifecycle, reducing network costs and saving latency.
56
+
57
+ ---
35
58
 
36
- Install the core package using npm:
59
+ ## 3. End-User Integration Guide
37
60
 
61
+ ### Step 1: Installation
62
+ Install the SDK alongside its required peer dependencies:
38
63
  ```bash
39
64
  npm install @retrivora-ai/rag-engine
40
65
  ```
41
66
 
42
- #### 🎨 Auto-Injected Styles
43
- To render the built-in UI components (like `ChatWidget`, `ChatWindow`, `DocumentUpload`) correctly, stylesheet rules are **auto-injected directly into the document `<head>` on load**. No manual CSS imports are required in your application layout!
44
-
45
- *(Note: The raw stylesheet remains exported at `@retrivora-ai/rag-engine/style.css` if your custom bundler or setup requires manual stylesheet referencing).*
46
-
47
- #### 🔌 Peer & Optional Dependencies
48
- Depending on the specific database providers or features you use, you may need to install additional peer dependencies:
49
- * **PostgreSQL / PGVector**: `npm install pg @types/pg`
50
- * **MongoDB Atlas**: `npm install mongodb`
51
- * **Word/PDF parsing capabilities**: `npm install mammoth pdf-parse`
52
- * **Agentic/Semantic Chunking**: `npm install langchain llamaindex`
67
+ ### Step 2: Environment Configuration
68
+ Create a `.env.local` file in your application root to supply your keys and provider selections:
69
+ ```bash
70
+ # General Setup
71
+ RAG_PROJECT_ID=my-rag-application
72
+ RETRIVORA_LICENSE_KEY=ey... # Required for production deployment
73
+
74
+ # Vector Database (MongoDB Atlas Example)
75
+ VECTOR_DB_PROVIDER=mongodb
76
+ MONGODB_URI=mongodb+srv://...
77
+ MONGODB_DB=retrivora_db
78
+ MONGODB_COLLECTION=vectors
79
+ MONGODB_INDEX_NAME=vector_index
80
+
81
+ # LLM Provider (Google Gemini Example)
82
+ LLM_PROVIDER=gemini
83
+ LLM_MODEL=gemini-2.5-flash
84
+ GEMINI_API_KEY=AIzaSy...
85
+
86
+ # Embedding Provider
87
+ EMBEDDING_PROVIDER=gemini
88
+ EMBEDDING_MODEL=text-embedding-004
89
+ ```
53
90
 
54
- ---
91
+ ### Step 3: Server-Side Ingestion
92
+ Initialize the SDK instance on your server-side scripts or background workers to parse and index documents:
93
+ ```typescript
94
+ import { Retrivora } from '@retrivora-ai/rag-engine/server';
55
95
 
56
- ## 🛠️ Pluggable Architecture
96
+ const retrivora = new Retrivora();
57
97
 
58
- Starting with v1.0.0, the engine uses a modular registry for all providers. Every provider now exposes:
59
- - **Static Validators**: `getValidator()` for deep configuration schema checks.
60
- - **Static Health Checkers**: `getHealthChecker()` for real-time connectivity and capability validation.
98
+ async function runIngestion() {
99
+ // Validate configuration and verify the license key
100
+ await retrivora.initialize();
61
101
 
62
- This decoupling allows you to add custom providers without modifying the core engine logic.
102
+ const documents = [
103
+ {
104
+ docId: 'doc-001',
105
+ content: 'Retrivora supports Pinecone, MongoDB Vector, pgvector, and Qdrant out-of-the-box.',
106
+ metadata: { category: 'features', source: 'docs' }
107
+ }
108
+ ];
63
109
 
64
- ---
110
+ const results = await retrivora.ingest(documents, 'default-namespace');
111
+ console.log(`Successfully ingested ${results.length} documents.`);
112
+ }
113
+ ```
65
114
 
66
- ## NPM Package Usage
115
+ ### Step 4: Next.js API Routes (Server Proxy)
116
+ Setup Next.js route handlers to stream conversational RAG answers to the frontend client securely:
67
117
 
68
- The package exports are split between **client-side** and **server-side** entry points to keep server secrets/native packages safe from your React browser bundle.
118
+ **File**: `app/api/chat/route.ts`
119
+ ```typescript
120
+ import { createStreamHandler } from '@retrivora-ai/rag-engine/server';
69
121
 
70
- | Import Path | Context | Exports |
71
- |---|---|---|
72
- | `@retrivora-ai/rag-engine` | **Client/Browser** | `ChatWidget`, `ChatWindow`, `ConfigProvider`, `useRagChat` |
73
- | `@retrivora-ai/rag-engine/server` | **Server Only** | `Retrivora` (SDK facade), `Pipeline`, `ConfigBuilder`, custom exceptions |
74
- | `@retrivora-ai/rag-engine/handlers` | **Server Only** | Next.js API Route Handler factories (e.g. `createRagHandler`, `createChatHandler`) |
75
- | `@retrivora-ai/rag-engine/style.css` | **Universal** | Required CSS styles for custom bundler setups (auto-injected by default) |
122
+ // createStreamHandler automatically instantiates the Retrivora pipeline
123
+ // and handles HTTP stream chunking (SSE) transparently.
124
+ export const POST = createStreamHandler({
125
+ projectId: process.env.RAG_PROJECT_ID ?? 'default-project'
126
+ });
127
+ ```
76
128
 
77
- ### 1. Embed the ChatWidget
129
+ ### Step 5: Client-Side UI Components
130
+ Import the Retrivora CSS styles and render the interactive widget in your layout or page:
78
131
 
79
- Drop the widget inside your application layout:
132
+ **File**: `app/layout.tsx` (or `app/page.tsx`)
133
+ ```typescript
134
+ 'use client';
80
135
 
81
- ```tsx
82
136
  import { ConfigProvider, ChatWidget } from '@retrivora-ai/rag-engine';
137
+ import '@retrivora-ai/rag-engine/style.css'; // Load Tailwind styles
83
138
 
84
- export default function Layout({ children }) {
139
+ export default function Home() {
85
140
  return (
86
- <ConfigProvider
87
- config={{
88
- projectId: 'my-project',
89
- ui: {
90
- title: 'Support Bot',
91
- primaryColor: '#6366f1',
92
- accentColor: '#8b5cf6',
93
- welcomeMessage: 'Hi! How can I help you today?',
94
- },
95
- }}
96
- >
97
- {children}
98
- <ChatWidget position="bottom-right" />
141
+ <ConfigProvider apiEndpoint="/api/chat">
142
+ <main className="min-h-screen p-10 bg-slate-50">
143
+ <h1>My Corporate Knowledge Base</h1>
144
+
145
+ {/* Drop-in float widget */}
146
+ <ChatWidget
147
+ title="Retrivora Assistant"
148
+ subtitle="Ready to search your documents"
149
+ visualStyle="glass"
150
+ />
151
+ </main>
99
152
  </ConfigProvider>
100
153
  );
101
154
  }
102
155
  ```
103
156
 
104
- ### 2. Mount Catch-All API Handler
105
-
106
- Create a single dynamic catch-all route file to handle chat streaming, document upload, and suggestions automatically:
107
-
108
- ```ts
109
- // src/app/api/retrivora/[[...retrivora]]/route.ts
110
- import { createRagHandler } from '@retrivora-ai/rag-engine/handlers';
111
-
112
- // Handles GET /api/retrivora/health and POST /api/retrivora/chat, upload, suggestions
113
- export const { GET, POST } = createRagHandler();
114
- ```
115
-
116
- ### 3. Use Pipeline programmatically
117
-
118
- ```ts
119
- import { Pipeline, getRagConfig } from '@retrivora-ai/rag-engine/server';
120
-
121
- const config = getRagConfig();
122
- const pipeline = new Pipeline(config);
123
-
124
- // Ingest documents
125
- await pipeline.ingest([{ docId: 'readme', content: 'Your document text here' }]);
126
-
127
- // Ask questions
128
- const { reply, sources } = await pipeline.ask('What is the refund policy?');
129
- ```
130
-
131
- ### 4. Use the Retrivora SDK facade
132
-
133
- ```ts
134
- import { Retrivora } from '@retrivora-ai/rag-engine/server';
135
-
136
- const ai = new Retrivora({
137
- llm: {
138
- provider: 'openai',
139
- model: 'gpt-5',
140
- },
141
- embedding: {
142
- provider: 'openai',
143
- },
144
- vectorDatabase: {
145
- provider: 'pinecone',
146
- },
147
- retrieval: {
148
- strategy: 'hybrid',
149
- },
150
- workflow: {
151
- type: 'agentic-rag',
152
- },
153
- });
154
-
155
- const { reply, sources } = await ai.ask('What is the refund policy?');
156
- ```
157
-
158
157
  ---
159
158
 
160
- ## Configuration Reference
161
-
162
- The library is entirely dynamic. You can switch between providers simply by updating your environment variables.
159
+ ## 4. Licensing and Environments
163
160
 
164
- | Variable | Description |
165
- |---|---|
166
- | `RAG_PROJECT_ID` | Project namespace for data isolation |
167
- | `VECTOR_DB_PROVIDER` | `pinecone`, `pgvector`, `mongodb`, `milvus`, `qdrant`, `weaviate` |
168
- | `LLM_PROVIDER` | `openai`, `anthropic`, `gemini`, `ollama` |
169
- | `EMBEDDING_PROVIDER` | `openai`, `ollama`, `google-gemini` |
170
- | `RAG_ARCHITECTURE` | `simple`, `hybrid`, `graph`, `agentic` |
171
-
172
- ---
161
+ The SDK enforces license key verification at runtime depending on the hosting environment:
173
162
 
174
- ## License
175
- MIT
163
+ | Host Environment | License Key Status | SDK Behavior |
164
+ | :--- | :--- | :--- |
165
+ | **Development** (`process.env.NODE_ENV !== 'production'`) | **Missing / Expired** | **Fail-Open**: Outputs a yellow warning message in the node console. Operations continue. |
166
+ | **Production** (`process.env.NODE_ENV === 'production'`) | **Missing / Expired** | **Fail-Closed**: Throws `ConfigurationException` on `initialize()`. Ingestion/Chat routes are blocked. |
167
+ | **Air-Gapped / Offline** | **Valid Signed JWT** | **Fail-Open on Telemetry**: Verifies signature cryptographically offline. Works with no internet connection. |
@@ -35,6 +35,12 @@ interface ChatOptions {
35
35
  interface UseRagChatOptions {
36
36
  /** Override the chat API endpoint (default: /api/chat) */
37
37
  apiUrl?: string;
38
+ /**
39
+ * Base URL for the Retrivora SDK catch-all route used for history, feedback,
40
+ * and sessions endpoints. Defaults to '/api/retrivora'.
41
+ * e.g. if your catch-all is at /api/retrivora/[[...retrivora]], set this to '/api/retrivora'.
42
+ */
43
+ retrivoraApiBase?: string;
38
44
  /** Override project namespace */
39
45
  namespace?: string;
40
46
  /** Persist chat history to localStorage (default: true) */
@@ -45,6 +51,8 @@ interface UseRagChatOptions {
45
51
  onError?: (error: string) => void;
46
52
  /** Optional custom headers to send with the chat request */
47
53
  headers?: Record<string, string>;
54
+ /** Session ID for history and feedback tracking (default: 'default') */
55
+ sessionId?: string;
48
56
  }
49
57
  interface UseRagChatReturn {
50
58
  /** All messages in the current conversation */
@@ -63,11 +71,17 @@ interface UseRagChatReturn {
63
71
  setMessages: React.Dispatch<React.SetStateAction<RagMessage[]>>;
64
72
  /** Abort the current active stream request */
65
73
  stop: () => void;
74
+ /** Load message history from database storage */
75
+ loadHistory: (sessionId: string) => Promise<void>;
76
+ /** Clear conversation history from database and locally */
77
+ clearHistory: (sessionId: string) => Promise<void>;
78
+ /** Submit rating and optional comment for a specific assistant message */
79
+ submitFeedback: (messageId: string, rating: 'thumbs_up' | 'thumbs_down', comment?: string) => Promise<void>;
66
80
  }
67
81
 
68
82
  declare const VECTOR_DB_PROVIDERS: readonly ["pinecone", "pgvector", "postgresql", "mongodb", "qdrant", "milvus", "chromadb", "redis", "weaviate", "rest", "universal_rest", "custom"];
69
- declare const LLM_PROVIDERS: readonly ["openai", "anthropic", "ollama", "gemini", "rest", "universal_rest", "custom"];
70
- declare const EMBEDDING_PROVIDERS: readonly ["openai", "ollama", "gemini", "rest", "universal_rest", "custom"];
83
+ declare const LLM_PROVIDERS: readonly ["openai", "anthropic", "ollama", "gemini", "groq", "qwen", "rest", "universal_rest", "custom"];
84
+ declare const EMBEDDING_PROVIDERS: readonly ["openai", "ollama", "gemini", "qwen", "rest", "universal_rest", "custom"];
71
85
  declare const GRAPH_DB_PROVIDERS: readonly ["neo4j", "memgraph", "simple", "custom"];
72
86
 
73
87
  /**
@@ -189,6 +203,18 @@ interface UIConfig {
189
203
  /** Whether to enable voice search input. Defaults to true. */
190
204
  enableVoiceInput?: boolean;
191
205
  }
206
+ interface CAGConfig {
207
+ /** Enable Cold RAG (Cache Augmented Generation) */
208
+ enabled?: boolean;
209
+ /** Namespace containing the cold data (e.g., static manuals/guides) */
210
+ coldNamespace?: string;
211
+ /** Limit of cold documents to retrieve at initialization and keep in cache/context */
212
+ coldLimit?: number;
213
+ /** Specific search query to retrieve the cold documents (e.g., "manual", "documentation") */
214
+ coldQuery?: string;
215
+ /** Specific document IDs to load as cold context */
216
+ coldDocumentIds?: string[];
217
+ }
192
218
  interface RAGConfig {
193
219
  /** Number of top-K chunks retrieved per query */
194
220
  topK?: number;
@@ -229,6 +255,18 @@ interface RAGConfig {
229
255
  * Defaults to built-in list (find, search, tell me about, etc.).
230
256
  */
231
257
  vectorKeywords?: string[];
258
+ /** Cold RAG (Cache Augmented Generation) configuration */
259
+ cag?: CAGConfig;
260
+ /** Chat history configuration */
261
+ history?: {
262
+ enabled?: boolean;
263
+ tableName?: string;
264
+ };
265
+ /** User feedback configuration */
266
+ feedback?: {
267
+ enabled?: boolean;
268
+ tableName?: string;
269
+ };
232
270
  }
233
271
  interface RetrievalConfig {
234
272
  /** Retrieval strategy selected by the host app. */
@@ -248,7 +286,17 @@ interface WorkflowConfig {
248
286
  /** Future workflow/provider-specific options. */
249
287
  options?: Record<string, unknown>;
250
288
  }
289
+ interface MCPServerConfig {
290
+ name: string;
291
+ transport: 'stdio' | 'sse';
292
+ url?: string;
293
+ command?: string;
294
+ args?: string[];
295
+ env?: Record<string, string>;
296
+ }
251
297
  interface RagConfig {
298
+ /** License key for commercial production validation */
299
+ licenseKey?: string;
252
300
  /**
253
301
  * Unique identifier for the consuming project.
254
302
  * Used as the vector DB namespace to achieve multi-tenancy.
@@ -266,6 +314,13 @@ interface RagConfig {
266
314
  rag?: RAGConfig;
267
315
  /** Optional Graph database configuration */
268
316
  graphDb?: GraphDBConfig;
317
+ /** Optional Telemetry configuration for observability logging */
318
+ telemetry?: {
319
+ enabled?: boolean;
320
+ url?: string;
321
+ };
322
+ /** Optional Model Context Protocol (MCP) server configurations */
323
+ mcpServers?: MCPServerConfig[];
269
324
  }
270
325
  /**
271
326
  * Friendly SDK configuration accepted by the top-level Retrivora facade.
@@ -35,6 +35,12 @@ interface ChatOptions {
35
35
  interface UseRagChatOptions {
36
36
  /** Override the chat API endpoint (default: /api/chat) */
37
37
  apiUrl?: string;
38
+ /**
39
+ * Base URL for the Retrivora SDK catch-all route used for history, feedback,
40
+ * and sessions endpoints. Defaults to '/api/retrivora'.
41
+ * e.g. if your catch-all is at /api/retrivora/[[...retrivora]], set this to '/api/retrivora'.
42
+ */
43
+ retrivoraApiBase?: string;
38
44
  /** Override project namespace */
39
45
  namespace?: string;
40
46
  /** Persist chat history to localStorage (default: true) */
@@ -45,6 +51,8 @@ interface UseRagChatOptions {
45
51
  onError?: (error: string) => void;
46
52
  /** Optional custom headers to send with the chat request */
47
53
  headers?: Record<string, string>;
54
+ /** Session ID for history and feedback tracking (default: 'default') */
55
+ sessionId?: string;
48
56
  }
49
57
  interface UseRagChatReturn {
50
58
  /** All messages in the current conversation */
@@ -63,11 +71,17 @@ interface UseRagChatReturn {
63
71
  setMessages: React.Dispatch<React.SetStateAction<RagMessage[]>>;
64
72
  /** Abort the current active stream request */
65
73
  stop: () => void;
74
+ /** Load message history from database storage */
75
+ loadHistory: (sessionId: string) => Promise<void>;
76
+ /** Clear conversation history from database and locally */
77
+ clearHistory: (sessionId: string) => Promise<void>;
78
+ /** Submit rating and optional comment for a specific assistant message */
79
+ submitFeedback: (messageId: string, rating: 'thumbs_up' | 'thumbs_down', comment?: string) => Promise<void>;
66
80
  }
67
81
 
68
82
  declare const VECTOR_DB_PROVIDERS: readonly ["pinecone", "pgvector", "postgresql", "mongodb", "qdrant", "milvus", "chromadb", "redis", "weaviate", "rest", "universal_rest", "custom"];
69
- declare const LLM_PROVIDERS: readonly ["openai", "anthropic", "ollama", "gemini", "rest", "universal_rest", "custom"];
70
- declare const EMBEDDING_PROVIDERS: readonly ["openai", "ollama", "gemini", "rest", "universal_rest", "custom"];
83
+ declare const LLM_PROVIDERS: readonly ["openai", "anthropic", "ollama", "gemini", "groq", "qwen", "rest", "universal_rest", "custom"];
84
+ declare const EMBEDDING_PROVIDERS: readonly ["openai", "ollama", "gemini", "qwen", "rest", "universal_rest", "custom"];
71
85
  declare const GRAPH_DB_PROVIDERS: readonly ["neo4j", "memgraph", "simple", "custom"];
72
86
 
73
87
  /**
@@ -189,6 +203,18 @@ interface UIConfig {
189
203
  /** Whether to enable voice search input. Defaults to true. */
190
204
  enableVoiceInput?: boolean;
191
205
  }
206
+ interface CAGConfig {
207
+ /** Enable Cold RAG (Cache Augmented Generation) */
208
+ enabled?: boolean;
209
+ /** Namespace containing the cold data (e.g., static manuals/guides) */
210
+ coldNamespace?: string;
211
+ /** Limit of cold documents to retrieve at initialization and keep in cache/context */
212
+ coldLimit?: number;
213
+ /** Specific search query to retrieve the cold documents (e.g., "manual", "documentation") */
214
+ coldQuery?: string;
215
+ /** Specific document IDs to load as cold context */
216
+ coldDocumentIds?: string[];
217
+ }
192
218
  interface RAGConfig {
193
219
  /** Number of top-K chunks retrieved per query */
194
220
  topK?: number;
@@ -229,6 +255,18 @@ interface RAGConfig {
229
255
  * Defaults to built-in list (find, search, tell me about, etc.).
230
256
  */
231
257
  vectorKeywords?: string[];
258
+ /** Cold RAG (Cache Augmented Generation) configuration */
259
+ cag?: CAGConfig;
260
+ /** Chat history configuration */
261
+ history?: {
262
+ enabled?: boolean;
263
+ tableName?: string;
264
+ };
265
+ /** User feedback configuration */
266
+ feedback?: {
267
+ enabled?: boolean;
268
+ tableName?: string;
269
+ };
232
270
  }
233
271
  interface RetrievalConfig {
234
272
  /** Retrieval strategy selected by the host app. */
@@ -248,7 +286,17 @@ interface WorkflowConfig {
248
286
  /** Future workflow/provider-specific options. */
249
287
  options?: Record<string, unknown>;
250
288
  }
289
+ interface MCPServerConfig {
290
+ name: string;
291
+ transport: 'stdio' | 'sse';
292
+ url?: string;
293
+ command?: string;
294
+ args?: string[];
295
+ env?: Record<string, string>;
296
+ }
251
297
  interface RagConfig {
298
+ /** License key for commercial production validation */
299
+ licenseKey?: string;
252
300
  /**
253
301
  * Unique identifier for the consuming project.
254
302
  * Used as the vector DB namespace to achieve multi-tenancy.
@@ -266,6 +314,13 @@ interface RagConfig {
266
314
  rag?: RAGConfig;
267
315
  /** Optional Graph database configuration */
268
316
  graphDb?: GraphDBConfig;
317
+ /** Optional Telemetry configuration for observability logging */
318
+ telemetry?: {
319
+ enabled?: boolean;
320
+ url?: string;
321
+ };
322
+ /** Optional Model Context Protocol (MCP) server configurations */
323
+ mcpServers?: MCPServerConfig[];
269
324
  }
270
325
  /**
271
326
  * Friendly SDK configuration accepted by the top-level Retrivora facade.
@@ -1,3 +1,3 @@
1
- import '../ILLMProvider-Bhk6zJOK.mjs';
2
- export { c as createChatHandler, d as createHealthHandler, e as createIngestHandler, f as createRagHandler, g as createStreamHandler, l as createSuggestionsHandler, h as createUploadHandler, s as sseErrorFrame, i as sseFrame, j as sseMetaFrame, m as sseObservabilityFrame, k as sseTextFrame, n as sseUIFrame } from '../index-C3SVtPYg.mjs';
3
1
  import 'next/server';
2
+ export { o as HandlerOptions, c as createChatHandler, d as createFeedbackHandler, e as createHealthHandler, f as createHistoryHandler, g as createIngestHandler, h as createRagHandler, i as createSessionsHandler, j as createStreamHandler, p as createSuggestionsHandler, k as createUploadHandler, s as sseErrorFrame, l as sseFrame, m as sseMetaFrame, q as sseObservabilityFrame, n as sseTextFrame, r as sseUIFrame } from '../index-CrxCy36A.mjs';
3
+ import '../ILLMProvider-B8ROITYK.mjs';
@@ -1,3 +1,3 @@
1
- import '../ILLMProvider-Bhk6zJOK.js';
2
- export { c as createChatHandler, d as createHealthHandler, e as createIngestHandler, f as createRagHandler, g as createStreamHandler, l as createSuggestionsHandler, h as createUploadHandler, s as sseErrorFrame, i as sseFrame, j as sseMetaFrame, m as sseObservabilityFrame, k as sseTextFrame, n as sseUIFrame } from '../index-Bu7T6xgr.js';
3
1
  import 'next/server';
2
+ export { o as HandlerOptions, c as createChatHandler, d as createFeedbackHandler, e as createHealthHandler, f as createHistoryHandler, g as createIngestHandler, h as createRagHandler, i as createSessionsHandler, j as createStreamHandler, p as createSuggestionsHandler, k as createUploadHandler, s as sseErrorFrame, l as sseFrame, m as sseMetaFrame, q as sseObservabilityFrame, n as sseTextFrame, r as sseUIFrame } from '../index-BCPKUAVL.js';
3
+ import '../ILLMProvider-B8ROITYK.js';