@retrivora-ai/rag-engine 1.9.7 → 1.9.9

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 (60) hide show
  1. package/README.md +136 -136
  2. package/dist/{ILLMProvider-Bhk6zJOK.d.mts → ILLMProvider-DMxLyTdq.d.mts} +59 -4
  3. package/dist/{ILLMProvider-Bhk6zJOK.d.ts → ILLMProvider-DMxLyTdq.d.ts} +59 -4
  4. package/dist/handlers/index.d.mts +2 -2
  5. package/dist/handlers/index.d.ts +2 -2
  6. package/dist/handlers/index.js +2327 -474
  7. package/dist/handlers/index.mjs +2329 -473
  8. package/dist/{index-B9J_XEh0.d.ts → index-CfkqZd2Y.d.ts} +12 -2
  9. package/dist/{index-C3SVtPYg.d.mts → index-DXd29KMq.d.mts} +27 -52
  10. package/dist/{index-Bu7T6xgr.d.ts → index-D_bOdJML.d.ts} +27 -52
  11. package/dist/{index-BJ4cd-t5.d.mts → index-xygonxpW.d.mts} +12 -2
  12. package/dist/index.css +783 -550
  13. package/dist/index.d.mts +35 -7
  14. package/dist/index.d.ts +35 -7
  15. package/dist/index.js +419 -282
  16. package/dist/index.mjs +426 -292
  17. package/dist/server.d.mts +65 -6
  18. package/dist/server.d.ts +65 -6
  19. package/dist/server.js +2185 -317
  20. package/dist/server.mjs +2185 -317
  21. package/package.json +13 -8
  22. package/src/app/constants.tsx +37 -7
  23. package/src/app/page.tsx +2 -0
  24. package/src/components/ChatWidget.tsx +2 -1
  25. package/src/components/ChatWindow.tsx +4 -1
  26. package/src/components/CodeViewer.tsx +19 -14
  27. package/src/components/MarkdownComponents.tsx +44 -1
  28. package/src/components/MessageBubble.tsx +162 -50
  29. package/src/components/constants.tsx +228 -0
  30. package/src/config/RagConfig.ts +48 -2
  31. package/src/config/constants.ts +4 -0
  32. package/src/config/serverConfig.ts +15 -0
  33. package/src/core/ConfigResolver.ts +38 -6
  34. package/src/core/DatabaseStorage.ts +469 -0
  35. package/src/core/LicenseVerifier.ts +260 -0
  36. package/src/core/MultiAgentCoordinator.ts +239 -0
  37. package/src/core/Pipeline.ts +151 -18
  38. package/src/core/Retrivora.ts +7 -0
  39. package/src/core/VectorPlugin.ts +12 -3
  40. package/src/core/mcp.ts +261 -0
  41. package/src/handlers/index.ts +449 -63
  42. package/src/hooks/useRagChat.ts +96 -42
  43. package/src/hooks/useStoredMessages.ts +15 -4
  44. package/src/index.ts +3 -0
  45. package/src/llm/LLMFactory.ts +9 -1
  46. package/src/llm/providers/GroqProvider.ts +176 -0
  47. package/src/llm/providers/QwenProvider.ts +191 -0
  48. package/src/server.ts +7 -0
  49. package/src/types/chat.ts +14 -0
  50. package/src/types/props.ts +12 -0
  51. package/.env.example +0 -80
  52. package/LICENSE.txt +0 -21
  53. package/src/components/AmbientBackground.tsx +0 -29
  54. package/src/components/ArchitectureCard.tsx +0 -17
  55. package/src/components/ArchitectureCardsSection.tsx +0 -15
  56. package/src/components/DocViewer.tsx +0 -103
  57. package/src/components/Documentation.tsx +0 -121
  58. package/src/components/Hero.tsx +0 -59
  59. package/src/components/Lifecycle.tsx +0 -37
  60. package/src/components/Navbar.tsx +0 -55
package/README.md CHANGED
@@ -1,175 +1,175 @@
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
27
-
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**.
17
+ ## 2. Architecture & Implementation
18
+
19
+ The SDK is built with modularity, performance, and security at its core:
20
+
21
+ ```mermaid
22
+ sequenceDiagram
23
+ autonumber
24
+ actor Client as Host Client (Next.js/React)
25
+ participant Facade as Retrivora Facade
26
+ participant Lic as LicenseVerifier
27
+ participant Pipe as Pipeline Engine
28
+ participant DB as Vector Database
29
+ participant LLM as LLM Provider
30
+
31
+ Client->>Facade: initialize(config)
32
+ activate Facade
33
+ Facade->>Lic: verify(licenseKey, projectId)
34
+ activate Lic
35
+ Note over Lic: Offline RS256 JWT Decryption
36
+ Lic-->>Facade: Valid Signature (Green)
37
+ deactivate Lic
38
+ Facade-->>Client: Ready
39
+ deactivate Facade
40
+
41
+ Client->>Facade: ask(question, history)
42
+ activate Facade
43
+ Facade->>Pipe: ask(question, history)
44
+ activate Pipe
45
+ Pipe->>DB: search(queryVector)
46
+ activate DB
47
+ DB-->>Pipe: relevant chunks & meta
48
+ deactivate DB
49
+ Pipe->>LLM: chatCompletion(context, prompt)
50
+ activate LLM
51
+ LLM-->>Pipe: generated response
52
+ deactivate LLM
53
+ Pipe-->>Facade: ChatResponse (reply + sources)
54
+ deactivate Pipe
55
+ Facade-->>Client: SSE Streaming Chunk / JSON
56
+ deactivate Facade
57
+ ```
29
58
 
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.
59
+ ### Key Components:
60
+ 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()`.
61
+ 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.
62
+ 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.
63
+ 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.
33
64
 
34
- ### 📦 Installation
65
+ ---
35
66
 
36
- Install the core package using npm:
67
+ ## 3. End-User Integration Guide
37
68
 
69
+ ### Step 1: Installation
70
+ Install the SDK alongside its required peer dependencies:
38
71
  ```bash
39
72
  npm install @retrivora-ai/rag-engine
40
73
  ```
41
74
 
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`
75
+ ### Step 2: Environment Configuration
76
+ Create a `.env.local` file in your application root to supply your keys and provider selections:
77
+ ```bash
78
+ # General Setup
79
+ RAG_PROJECT_ID=my-rag-application
80
+ RETRIVORA_LICENSE_KEY=ey... # Required for production deployment
81
+
82
+ # Vector Database (MongoDB Atlas Example)
83
+ VECTOR_DB_PROVIDER=mongodb
84
+ MONGODB_URI=mongodb+srv://...
85
+ MONGODB_DB=retrivora_db
86
+ MONGODB_COLLECTION=vectors
87
+ MONGODB_INDEX_NAME=vector_index
88
+
89
+ # LLM Provider (Google Gemini Example)
90
+ LLM_PROVIDER=gemini
91
+ LLM_MODEL=gemini-2.5-flash
92
+ GEMINI_API_KEY=AIzaSy...
93
+
94
+ # Embedding Provider
95
+ EMBEDDING_PROVIDER=gemini
96
+ EMBEDDING_MODEL=text-embedding-004
97
+ ```
53
98
 
54
- ---
99
+ ### Step 3: Server-Side Ingestion
100
+ Initialize the SDK instance on your server-side scripts or background workers to parse and index documents:
101
+ ```typescript
102
+ import { Retrivora } from '@retrivora-ai/rag-engine/server';
55
103
 
56
- ## 🛠️ Pluggable Architecture
104
+ const retrivora = new Retrivora();
57
105
 
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.
106
+ async function runIngestion() {
107
+ // Validate configuration and verify the license key
108
+ await retrivora.initialize();
61
109
 
62
- This decoupling allows you to add custom providers without modifying the core engine logic.
110
+ const documents = [
111
+ {
112
+ docId: 'doc-001',
113
+ content: 'Retrivora supports Pinecone, MongoDB Vector, pgvector, and Qdrant out-of-the-box.',
114
+ metadata: { category: 'features', source: 'docs' }
115
+ }
116
+ ];
63
117
 
64
- ---
118
+ const results = await retrivora.ingest(documents, 'default-namespace');
119
+ console.log(`Successfully ingested ${results.length} documents.`);
120
+ }
121
+ ```
65
122
 
66
- ## NPM Package Usage
123
+ ### Step 4: Next.js API Routes (Server Proxy)
124
+ Setup Next.js route handlers to stream conversational RAG answers to the frontend client securely:
67
125
 
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.
126
+ **File**: `app/api/chat/route.ts`
127
+ ```typescript
128
+ import { createStreamHandler } from '@retrivora-ai/rag-engine/server';
69
129
 
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) |
130
+ // createStreamHandler automatically instantiates the Retrivora pipeline
131
+ // and handles HTTP stream chunking (SSE) transparently.
132
+ export const POST = createStreamHandler({
133
+ projectId: process.env.RAG_PROJECT_ID ?? 'default-project'
134
+ });
135
+ ```
76
136
 
77
- ### 1. Embed the ChatWidget
137
+ ### Step 5: Client-Side UI Components
138
+ Import the Retrivora CSS styles and render the interactive widget in your layout or page:
78
139
 
79
- Drop the widget inside your application layout:
140
+ **File**: `app/layout.tsx` (or `app/page.tsx`)
141
+ ```typescript
142
+ 'use client';
80
143
 
81
- ```tsx
82
144
  import { ConfigProvider, ChatWidget } from '@retrivora-ai/rag-engine';
145
+ import '@retrivora-ai/rag-engine/style.css'; // Load Tailwind styles
83
146
 
84
- export default function Layout({ children }) {
147
+ export default function Home() {
85
148
  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" />
149
+ <ConfigProvider apiEndpoint="/api/chat">
150
+ <main className="min-h-screen p-10 bg-slate-50">
151
+ <h1>My Corporate Knowledge Base</h1>
152
+
153
+ {/* Drop-in float widget */}
154
+ <ChatWidget
155
+ title="Retrivora Assistant"
156
+ subtitle="Ready to search your documents"
157
+ visualStyle="glass"
158
+ />
159
+ </main>
99
160
  </ConfigProvider>
100
161
  );
101
162
  }
102
163
  ```
103
164
 
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
165
  ---
159
166
 
160
- ## Configuration Reference
161
-
162
- The library is entirely dynamic. You can switch between providers simply by updating your environment variables.
167
+ ## 4. Licensing and Environments
163
168
 
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
- ---
169
+ The SDK enforces license key verification at runtime depending on the hosting environment:
173
170
 
174
- ## License
175
- MIT
171
+ | Host Environment | License Key Status | SDK Behavior |
172
+ | :--- | :--- | :--- |
173
+ | **Development** (`process.env.NODE_ENV !== 'production'`) | **Missing / Expired** | **Fail-Open**: Outputs a yellow warning message in the node console. Operations continue. |
174
+ | **Production** (`process.env.NODE_ENV === 'production'`) | **Missing / Expired** | **Fail-Closed**: Throws `ConfigurationException` on `initialize()`. Ingestion/Chat routes are blocked. |
175
+ | **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;
@@ -201,7 +227,7 @@ interface RAGConfig {
201
227
  /** Characters used to split text, in order of priority */
202
228
  separators?: string[];
203
229
  /** Overall RAG architecture pattern */
204
- architecture?: 'simple' | 'graph' | 'hybrid' | 'agentic';
230
+ architecture?: 'simple' | 'graph' | 'hybrid' | 'agentic' | 'naive' | 'retrieve-and-rerank' | 'multimodal' | 'agentic-router' | 'multi-agent';
205
231
  /** Chunking strategy to use during ingestion */
206
232
  chunkingStrategy?: 'recursive' | 'markdown' | 'semantic' | 'llamaindex';
207
233
  /** Whether to use query transformation (e.g. HyDE) */
@@ -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. */
@@ -244,11 +282,21 @@ interface RetrievalConfig {
244
282
  }
245
283
  interface WorkflowConfig {
246
284
  /** High-level workflow selector from the SDK prompt. */
247
- type?: 'simple-rag' | 'rag' | 'hybrid-rag' | 'graph-rag' | 'agentic-rag' | 'agentic';
285
+ type?: 'simple-rag' | 'rag' | 'hybrid-rag' | 'graph-rag' | 'agentic-rag' | 'agentic' | 'naive-rag' | 'retrieve-and-rerank' | 'multimodal-rag' | 'agentic-router' | 'multi-agent-rag' | 'multi-agent';
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;
@@ -201,7 +227,7 @@ interface RAGConfig {
201
227
  /** Characters used to split text, in order of priority */
202
228
  separators?: string[];
203
229
  /** Overall RAG architecture pattern */
204
- architecture?: 'simple' | 'graph' | 'hybrid' | 'agentic';
230
+ architecture?: 'simple' | 'graph' | 'hybrid' | 'agentic' | 'naive' | 'retrieve-and-rerank' | 'multimodal' | 'agentic-router' | 'multi-agent';
205
231
  /** Chunking strategy to use during ingestion */
206
232
  chunkingStrategy?: 'recursive' | 'markdown' | 'semantic' | 'llamaindex';
207
233
  /** Whether to use query transformation (e.g. HyDE) */
@@ -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. */
@@ -244,11 +282,21 @@ interface RetrievalConfig {
244
282
  }
245
283
  interface WorkflowConfig {
246
284
  /** High-level workflow selector from the SDK prompt. */
247
- type?: 'simple-rag' | 'rag' | 'hybrid-rag' | 'graph-rag' | 'agentic-rag' | 'agentic';
285
+ type?: 'simple-rag' | 'rag' | 'hybrid-rag' | 'graph-rag' | 'agentic-rag' | 'agentic' | 'naive-rag' | 'retrieve-and-rerank' | 'multimodal-rag' | 'agentic-router' | 'multi-agent-rag' | 'multi-agent';
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-DXd29KMq.mjs';
3
+ import '../ILLMProvider-DMxLyTdq.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-D_bOdJML.js';
3
+ import '../ILLMProvider-DMxLyTdq.js';