@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.
- package/README.md +127 -135
- package/dist/{ILLMProvider-Bhk6zJOK.d.mts → ILLMProvider-B8ROITYK.d.mts} +57 -2
- package/dist/{ILLMProvider-Bhk6zJOK.d.ts → ILLMProvider-B8ROITYK.d.ts} +57 -2
- package/dist/handlers/index.d.mts +2 -2
- package/dist/handlers/index.d.ts +2 -2
- package/dist/handlers/index.js +2198 -457
- package/dist/handlers/index.mjs +2195 -457
- package/dist/{index-BJ4cd-t5.d.mts → index-B8PbEFSY.d.mts} +12 -2
- package/dist/{index-Bu7T6xgr.d.ts → index-BCPKUAVL.d.ts} +27 -52
- package/dist/{index-C3SVtPYg.d.mts → index-CrxCy36A.d.mts} +27 -52
- package/dist/{index-B9J_XEh0.d.ts → index-DNvoi-sV.d.ts} +12 -2
- package/dist/index.css +578 -273
- package/dist/index.d.mts +29 -7
- package/dist/index.d.ts +29 -7
- package/dist/index.js +1160 -282
- package/dist/index.mjs +1185 -292
- package/dist/server.d.mts +62 -6
- package/dist/server.d.ts +62 -6
- package/dist/server.js +2061 -306
- package/dist/server.mjs +2055 -306
- package/package.json +11 -7
- package/src/app/constants.tsx +37 -7
- package/src/components/AmbientBackground.tsx +10 -10
- package/src/components/ArchitectureCard.tsx +43 -7
- package/src/components/ArchitectureCardsSection.tsx +37 -4
- package/src/components/ChatWidget.tsx +2 -1
- package/src/components/ChatWindow.tsx +4 -1
- package/src/components/CodeViewer.tsx +19 -14
- package/src/components/DocViewer.tsx +43 -49
- package/src/components/Documentation.tsx +71 -51
- package/src/components/Hero.tsx +103 -20
- package/src/components/Lifecycle.tsx +65 -25
- package/src/components/MarkdownComponents.tsx +44 -1
- package/src/components/MessageBubble.tsx +162 -50
- package/src/components/constants.tsx +4 -0
- package/src/config/RagConfig.ts +46 -0
- package/src/config/constants.ts +4 -0
- package/src/config/serverConfig.ts +15 -0
- package/src/core/ConfigResolver.ts +6 -0
- package/src/core/DatabaseStorage.ts +469 -0
- package/src/core/LicenseVerifier.ts +154 -0
- package/src/core/MultiAgentCoordinator.ts +239 -0
- package/src/core/Pipeline.ts +146 -15
- package/src/core/Retrivora.ts +6 -0
- package/src/core/VectorPlugin.ts +12 -3
- package/src/core/mcp.ts +261 -0
- package/src/handlers/index.ts +449 -63
- package/src/hooks/useRagChat.ts +96 -42
- package/src/hooks/useStoredMessages.ts +15 -4
- package/src/index.ts +5 -0
- package/src/llm/LLMFactory.ts +9 -1
- package/src/llm/providers/GroqProvider.ts +176 -0
- package/src/llm/providers/QwenProvider.ts +191 -0
- package/src/server.ts +7 -0
- package/src/types/chat.ts +14 -0
- package/src/types/props.ts +12 -0
- package/.env.example +0 -80
- package/LICENSE.txt +0 -21
package/README.md
CHANGED
|
@@ -1,175 +1,167 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Retrivora RAG Engine SDK
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
[](https://www.npmjs.com/package/@retrivora-ai/rag-engine)
|
|
6
|
-
[](https://www.npmjs.com/package/@retrivora-ai/rag-engine)
|
|
7
|
-
[](https://github.com/abhinav1201/ai-accelerator)
|
|
8
|
-

|
|
9
|
-

|
|
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
|
-
##
|
|
7
|
+
## 1. What is the Retrivora SDK?
|
|
14
8
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
-
##
|
|
17
|
+
## 2. Architecture & Implementation
|
|
27
18
|
|
|
28
|
-
|
|
19
|
+
The SDK is built with modularity, performance, and security at its core:
|
|
29
20
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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
|
-
###
|
|
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
|
-
|
|
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
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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
|
-
|
|
96
|
+
const retrivora = new Retrivora();
|
|
57
97
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
98
|
+
async function runIngestion() {
|
|
99
|
+
// Validate configuration and verify the license key
|
|
100
|
+
await retrivora.initialize();
|
|
61
101
|
|
|
62
|
-
|
|
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
|
-
|
|
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
|
-
|
|
118
|
+
**File**: `app/api/chat/route.ts`
|
|
119
|
+
```typescript
|
|
120
|
+
import { createStreamHandler } from '@retrivora-ai/rag-engine/server';
|
|
69
121
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
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
|
-
###
|
|
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
|
-
|
|
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
|
|
139
|
+
export default function Home() {
|
|
85
140
|
return (
|
|
86
|
-
<ConfigProvider
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
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
|
-
##
|
|
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
|
-
|
|
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
|
-
|
|
175
|
-
|
|
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';
|
package/dist/handlers/index.d.ts
CHANGED
|
@@ -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';
|