@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
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import React from 'react';
|
|
4
|
-
import { Bot, User, ChevronDown, ChevronRight, Activity, Copy, Check } from 'lucide-react';
|
|
4
|
+
import { Bot, User, ChevronDown, ChevronRight, Activity, Copy, Check, ThumbsUp, ThumbsDown, Clock } from 'lucide-react';
|
|
5
5
|
import ReactMarkdown from 'react-markdown';
|
|
6
6
|
import { MessageBubbleProps, Product, UITransformationResponse } from '../types';
|
|
7
7
|
import { SourceCard } from './SourceCard';
|
|
@@ -39,12 +39,111 @@ function normalizePlusSeparatedLists(raw: string): string {
|
|
|
39
39
|
|
|
40
40
|
function stripLeakedAnswerWrappers(raw: string): string {
|
|
41
41
|
return raw
|
|
42
|
-
.replace(/<prose\s+answer(?:\s+in\s+[^>]*)
|
|
42
|
+
.replace(/<prose\s+answer(?:\s+in\s+[^>]*)?>[\s\S]*?<\/prose>/gi, '$1')
|
|
43
43
|
.replace(/<\/?prose(?:\s+answer)?[^>]*>/gi, '')
|
|
44
44
|
.replace(/\n{3,}/g, '\n\n')
|
|
45
45
|
.trim();
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
+
function formatTime(isoString?: string): string {
|
|
49
|
+
if (!isoString) return '';
|
|
50
|
+
try {
|
|
51
|
+
const d = new Date(isoString);
|
|
52
|
+
return d.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });
|
|
53
|
+
} catch {
|
|
54
|
+
return '';
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// ─── Feedback Buttons ─────────────────────────────────────────────────────────
|
|
59
|
+
|
|
60
|
+
interface FeedbackBarProps {
|
|
61
|
+
messageId: string;
|
|
62
|
+
onFeedback: (messageId: string, rating: 'thumbs_up' | 'thumbs_down') => void;
|
|
63
|
+
primaryColor: string;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function FeedbackBar({ messageId, onFeedback, primaryColor }: FeedbackBarProps) {
|
|
67
|
+
const [rating, setRating] = React.useState<'thumbs_up' | 'thumbs_down' | null>(null);
|
|
68
|
+
const [submitting, setSubmitting] = React.useState(false);
|
|
69
|
+
|
|
70
|
+
const handleRate = async (r: 'thumbs_up' | 'thumbs_down') => {
|
|
71
|
+
if (rating !== null || submitting) return;
|
|
72
|
+
setSubmitting(true);
|
|
73
|
+
setRating(r);
|
|
74
|
+
try {
|
|
75
|
+
await onFeedback(messageId, r);
|
|
76
|
+
} catch {
|
|
77
|
+
// Rating already set optimistically — keep it
|
|
78
|
+
} finally {
|
|
79
|
+
setSubmitting(false);
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
const isLocked = rating !== null;
|
|
84
|
+
|
|
85
|
+
return (
|
|
86
|
+
<div className="flex items-center gap-1">
|
|
87
|
+
{/* Divider */}
|
|
88
|
+
<span className="h-3 w-px bg-slate-200 dark:bg-white/10 mx-1" />
|
|
89
|
+
|
|
90
|
+
{/* Thumbs Up */}
|
|
91
|
+
<button
|
|
92
|
+
onClick={() => handleRate('thumbs_up')}
|
|
93
|
+
disabled={isLocked}
|
|
94
|
+
title={rating === 'thumbs_up' ? 'You liked this' : 'Good response'}
|
|
95
|
+
className={`group relative flex items-center justify-center w-6 h-6 rounded-lg transition-all duration-200 cursor-pointer border ${
|
|
96
|
+
rating === 'thumbs_up'
|
|
97
|
+
? 'bg-emerald-50 dark:bg-emerald-500/10 border-emerald-200 dark:border-emerald-500/25 text-emerald-600 dark:text-emerald-400 scale-110'
|
|
98
|
+
: rating === 'thumbs_down'
|
|
99
|
+
? 'opacity-30 border-transparent text-slate-300 dark:text-white/20 cursor-not-allowed'
|
|
100
|
+
: 'border-transparent text-slate-300 dark:text-white/20 hover:text-emerald-500 dark:hover:text-emerald-400 hover:bg-emerald-50 dark:hover:bg-emerald-500/10 hover:border-emerald-200 dark:hover:border-emerald-500/20 hover:scale-110'
|
|
101
|
+
}`}
|
|
102
|
+
>
|
|
103
|
+
<ThumbsUp className="w-3 h-3" />
|
|
104
|
+
{/* Tooltip */}
|
|
105
|
+
{!isLocked && (
|
|
106
|
+
<span className="absolute -top-8 left-1/2 -translate-x-1/2 px-2 py-1 text-[10px] font-medium bg-slate-800 dark:bg-slate-700 text-white rounded-lg opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none whitespace-nowrap shadow-lg z-10">
|
|
107
|
+
Good response
|
|
108
|
+
</span>
|
|
109
|
+
)}
|
|
110
|
+
</button>
|
|
111
|
+
|
|
112
|
+
{/* Thumbs Down */}
|
|
113
|
+
<button
|
|
114
|
+
onClick={() => handleRate('thumbs_down')}
|
|
115
|
+
disabled={isLocked}
|
|
116
|
+
title={rating === 'thumbs_down' ? 'You disliked this' : 'Bad response'}
|
|
117
|
+
className={`group relative flex items-center justify-center w-6 h-6 rounded-lg transition-all duration-200 cursor-pointer border ${
|
|
118
|
+
rating === 'thumbs_down'
|
|
119
|
+
? 'bg-rose-50 dark:bg-rose-500/10 border-rose-200 dark:border-rose-500/25 text-rose-600 dark:text-rose-400 scale-110'
|
|
120
|
+
: rating === 'thumbs_up'
|
|
121
|
+
? 'opacity-30 border-transparent text-slate-300 dark:text-white/20 cursor-not-allowed'
|
|
122
|
+
: 'border-transparent text-slate-300 dark:text-white/20 hover:text-rose-500 dark:hover:text-rose-400 hover:bg-rose-50 dark:hover:bg-rose-500/10 hover:border-rose-200 dark:hover:border-rose-500/20 hover:scale-110'
|
|
123
|
+
}`}
|
|
124
|
+
>
|
|
125
|
+
<ThumbsDown className="w-3 h-3" />
|
|
126
|
+
{!isLocked && (
|
|
127
|
+
<span className="absolute -top-8 left-1/2 -translate-x-1/2 px-2 py-1 text-[10px] font-medium bg-slate-800 dark:bg-slate-700 text-white rounded-lg opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none whitespace-nowrap shadow-lg z-10">
|
|
128
|
+
Bad response
|
|
129
|
+
</span>
|
|
130
|
+
)}
|
|
131
|
+
</button>
|
|
132
|
+
|
|
133
|
+
{/* Confirmation pill */}
|
|
134
|
+
{isLocked && (
|
|
135
|
+
<span className={`ml-1 text-[10px] font-semibold px-2 py-0.5 rounded-full border transition-all duration-300 ${
|
|
136
|
+
rating === 'thumbs_up'
|
|
137
|
+
? 'text-emerald-600 dark:text-emerald-400 bg-emerald-50 dark:bg-emerald-500/10 border-emerald-200 dark:border-emerald-500/20'
|
|
138
|
+
: 'text-rose-600 dark:text-rose-400 bg-rose-50 dark:bg-rose-500/10 border-rose-200 dark:border-rose-500/20'
|
|
139
|
+
}`}>
|
|
140
|
+
{rating === 'thumbs_up' ? 'Helpful' : 'Not helpful'}
|
|
141
|
+
</span>
|
|
142
|
+
)}
|
|
143
|
+
</div>
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
|
|
48
147
|
// ─── Main component ───────────────────────────────────────────────────────────
|
|
49
148
|
|
|
50
149
|
export function MessageBubble({
|
|
@@ -55,6 +154,7 @@ export function MessageBubble({
|
|
|
55
154
|
accentColor = '#8b5cf6',
|
|
56
155
|
onAddToCart,
|
|
57
156
|
viewportSize = 'large',
|
|
157
|
+
onFeedback,
|
|
58
158
|
}: MessageBubbleProps) {
|
|
59
159
|
const isUser = message.role === 'user';
|
|
60
160
|
const isCompact = viewportSize === 'compact';
|
|
@@ -85,7 +185,7 @@ export function MessageBubble({
|
|
|
85
185
|
if (type && !['text', 'table'].includes(type)) return true;
|
|
86
186
|
}
|
|
87
187
|
if (structuredContent.payload) {
|
|
88
|
-
return
|
|
188
|
+
return /\"?(?:view|type|chartType)\"?\s*:\s*\"?(?:chart|carousel|pie|bar|line|product_carousel)\"?/i.test(structuredContent.payload);
|
|
89
189
|
}
|
|
90
190
|
return false;
|
|
91
191
|
}, [message.uiTransformation, structuredContent.payload]);
|
|
@@ -129,18 +229,10 @@ export function MessageBubble({
|
|
|
129
229
|
const processedMarkdown = React.useMemo<string>(() => {
|
|
130
230
|
let raw = structuredContent.payload ? structuredContent.text : (cleanContent || message.content);
|
|
131
231
|
|
|
132
|
-
// 0. Pre-sanitize: strip $ from non-monetary whole integers.
|
|
133
|
-
// Real prices always have a decimal (e.g. $257.00). A bare $168 or $9680811891595 is NOT a price.
|
|
134
232
|
raw = raw.replace(/\$\s*(\d+)(?!\.\d)/g, '$1');
|
|
135
233
|
raw = normalizePlusSeparatedLists(raw);
|
|
136
234
|
raw = stripLeakedAnswerWrappers(raw);
|
|
137
|
-
|
|
138
|
-
// 0a. Strip bold (**...**) from inline field labels.
|
|
139
|
-
// The LLM wraps field names like **Stock** — 168 or **EAN** — 9680811891595 in bold.
|
|
140
|
-
// We want to strip the ** so it renders as plain text, not bold.
|
|
141
235
|
raw = raw.replace(/\*\*([^*\n]+)\*\*(\s*[—\-–:]\s*)/g, '$1$2');
|
|
142
|
-
|
|
143
|
-
// 0b. Remove duplicate lines (LLM sometimes repeats fields like Stock, EAN twice)
|
|
144
236
|
raw = raw
|
|
145
237
|
.split('\n')
|
|
146
238
|
.filter((line, idx, arr) => {
|
|
@@ -148,13 +240,12 @@ export function MessageBubble({
|
|
|
148
240
|
return !trimmed || arr.findIndex(l => l.trim() === trimmed) === idx;
|
|
149
241
|
})
|
|
150
242
|
.join('\n');
|
|
243
|
+
|
|
151
244
|
const hasStructuredUiBlock = Boolean(structuredContent.payload) || /```(?:ui|json|chart)\s*[\s\S]*?"(?:view|chartType|type|data|items|rows|products|results)"\s*:/i.test(raw);
|
|
152
245
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
.replace(/(\|[^\n]*\|)\n\n+(?=\|)/g, '$1\n'); // Remove blank lines between rows
|
|
246
|
+
raw = raw.replace(/([^\n])\n\|/g, '$1\n\n|')
|
|
247
|
+
.replace(/(\|[^\n]*\|)\n\n+(?=\|)/g, '$1\n');
|
|
156
248
|
|
|
157
|
-
// 2. HEALING: Wrap naked JSON blocks
|
|
158
249
|
if (!isStreaming) {
|
|
159
250
|
raw = raw.replace(/(?:^|\n)\s*\{[\s\S]*\}\s*(?:\n|$)/g, (match) => {
|
|
160
251
|
if (match.includes('```')) return match;
|
|
@@ -166,7 +257,6 @@ export function MessageBubble({
|
|
|
166
257
|
});
|
|
167
258
|
}
|
|
168
259
|
|
|
169
|
-
// 2b. Suppress duplicated markdown tables if a UI block is present
|
|
170
260
|
if (hasStructuredUiBlock) {
|
|
171
261
|
raw = stripStructuredUiLabels(stripMarkdownTables(raw))
|
|
172
262
|
.replace(/\n{3,}/g, '\n\n')
|
|
@@ -182,18 +272,25 @@ export function MessageBubble({
|
|
|
182
272
|
[primaryColor, accentColor, isStreaming, onAddToCart, viewportSize],
|
|
183
273
|
);
|
|
184
274
|
|
|
275
|
+
const timeLabel = formatTime(message.createdAt);
|
|
276
|
+
const isCompleted = !isStreaming && message.content;
|
|
277
|
+
|
|
185
278
|
// ── Render ─────────────────────────────────────────────────────────────────
|
|
186
279
|
return (
|
|
187
280
|
<div className={`flex ${isCompact ? 'gap-2' : 'gap-3'} ${isUser ? 'flex-row-reverse' : 'flex-row'} items-start`}>
|
|
188
281
|
{/* Avatar */}
|
|
189
282
|
<div
|
|
190
|
-
className={`flex-shrink-0 ${isCompact ? 'w-7 h-7' : 'w-8 h-8'} rounded-full flex items-center justify-center shadow-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
283
|
+
className={`flex-shrink-0 ${isCompact ? 'w-7 h-7' : 'w-8 h-8'} rounded-full flex items-center justify-center shadow-md transition-all duration-300 ${
|
|
284
|
+
isUser
|
|
285
|
+
? 'text-white'
|
|
286
|
+
: 'bg-gradient-to-br from-slate-100 to-slate-200 dark:from-white/10 dark:to-white/5 text-slate-600 dark:text-white/70 ring-1 ring-slate-200/80 dark:ring-white/10'
|
|
287
|
+
} ${isStreaming && !isUser ? 'ring-2 ring-offset-1 ring-offset-transparent animate-pulse' : ''}`}
|
|
194
288
|
style={isUser ? { background: `linear-gradient(135deg, ${primaryColor}, ${accentColor})` } : {}}
|
|
195
289
|
>
|
|
196
|
-
{isUser
|
|
290
|
+
{isUser
|
|
291
|
+
? <User className={`${isCompact ? 'w-3.5 h-3.5' : 'w-4 h-4'} text-white`} />
|
|
292
|
+
: <Bot className={`${isCompact ? 'w-3.5 h-3.5' : 'w-4 h-4'}`} />
|
|
293
|
+
}
|
|
197
294
|
</div>
|
|
198
295
|
|
|
199
296
|
<div className={`flex flex-col gap-1 min-w-0 ${isCompact ? 'max-w-[94%]' : isMedium ? 'max-w-[92%]' : 'max-w-[90%]'} ${isUser ? 'items-end' : 'items-start'}`}>
|
|
@@ -208,28 +305,30 @@ export function MessageBubble({
|
|
|
208
305
|
|
|
209
306
|
{/* Bubble */}
|
|
210
307
|
<div
|
|
211
|
-
className={`relative group ${isCompact ? 'px-3 py-2.5 text-[13px]' : 'px-4 py-3 text-sm'} rounded-2xl leading-relaxed shadow
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
308
|
+
className={`relative group ${isCompact ? 'px-3 py-2.5 text-[13px]' : 'px-4 py-3 text-sm'} rounded-2xl leading-relaxed transition-shadow duration-200 ${
|
|
309
|
+
isUser
|
|
310
|
+
? 'text-white rounded-tr-sm shadow-md hover:shadow-lg'
|
|
311
|
+
: 'bg-white dark:bg-white/5 border border-slate-200/80 dark:border-white/10 text-slate-800 dark:text-white/90 rounded-tl-sm shadow-sm hover:shadow-md hover:border-slate-300/60 dark:hover:border-white/15'
|
|
312
|
+
}`}
|
|
215
313
|
style={
|
|
216
314
|
isUser ? { background: `linear-gradient(135deg, ${primaryColor}, ${accentColor})` } : {}
|
|
217
315
|
}
|
|
218
316
|
>
|
|
219
317
|
{/* Floating Copy Button for completed assistant messages */}
|
|
220
|
-
{!isUser &&
|
|
318
|
+
{!isUser && isCompleted && (
|
|
221
319
|
<button
|
|
222
320
|
onClick={handleCopy}
|
|
223
321
|
className={`absolute top-2 right-2 p-1.5 rounded-lg border transition-all duration-200 cursor-pointer ${
|
|
224
322
|
copied
|
|
225
323
|
? 'bg-emerald-500/10 border-emerald-500/20 text-emerald-500 dark:text-emerald-400'
|
|
226
|
-
: 'bg-
|
|
324
|
+
: 'bg-white/60 dark:bg-white/5 hover:bg-white dark:hover:bg-white/10 border-slate-200/60 dark:border-white/10 text-slate-300 dark:text-white/20 hover:text-slate-600 dark:hover:text-white/60 hover:border-slate-300 dark:hover:border-white/20'
|
|
227
325
|
} opacity-0 group-hover:opacity-100 backdrop-blur-sm shadow-sm scale-95 group-hover:scale-100`}
|
|
228
|
-
title={copied ?
|
|
326
|
+
title={copied ? 'Copied!' : 'Copy response'}
|
|
229
327
|
>
|
|
230
328
|
{copied ? <Check className="w-3.5 h-3.5" /> : <Copy className="w-3.5 h-3.5" />}
|
|
231
329
|
</button>
|
|
232
330
|
)}
|
|
331
|
+
|
|
233
332
|
{isStreaming && !message.content ? (
|
|
234
333
|
<span className="flex items-center gap-1 py-1">
|
|
235
334
|
<span className="w-1.5 h-1.5 rounded-full bg-slate-400 dark:bg-white/60 animate-bounce [animation-delay:0ms]" />
|
|
@@ -255,28 +354,20 @@ export function MessageBubble({
|
|
|
255
354
|
</ReactMarkdown>
|
|
256
355
|
)}
|
|
257
356
|
|
|
258
|
-
{/* Fix: Always show streaming cursor when isStreaming is true */}
|
|
259
357
|
{isStreaming && (
|
|
260
|
-
<span
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
accentColor={accentColor}
|
|
265
|
-
glow={false} />
|
|
266
|
-
Thinking...
|
|
267
|
-
</span>
|
|
358
|
+
<span
|
|
359
|
+
className="inline-block w-2.5 h-4 ml-1.5 animate-[pulse_1.2s_infinite] align-middle rounded-sm"
|
|
360
|
+
style={{ backgroundColor: primaryColor }}
|
|
361
|
+
/>
|
|
268
362
|
)}
|
|
269
363
|
</div>
|
|
270
364
|
)}
|
|
271
365
|
</div>
|
|
272
366
|
|
|
273
|
-
{/* Auto-generated visualization
|
|
367
|
+
{/* Auto-generated visualization */}
|
|
274
368
|
{(() => {
|
|
275
369
|
if (isUser || structuredContent.payload) return null;
|
|
276
370
|
|
|
277
|
-
// During streaming: if we have sources but no uiTransformation yet,
|
|
278
|
-
// eagerly render a skeleton carousel for product queries so the user
|
|
279
|
-
// sees something immediately instead of waiting for the metadata frame.
|
|
280
371
|
if (isStreaming && !message.uiTransformation && sources && sources.length > 0) {
|
|
281
372
|
const hasProductSource = sources.some(s =>
|
|
282
373
|
s.metadata && Object.keys(s.metadata).some(k =>
|
|
@@ -301,7 +392,7 @@ export function MessageBubble({
|
|
|
301
392
|
if (!message.uiTransformation) return null;
|
|
302
393
|
const ui = message.uiTransformation as UITransformationResponse;
|
|
303
394
|
const textContent = (ui.data as { content?: string })?.content ?? '';
|
|
304
|
-
|
|
395
|
+
|
|
305
396
|
const isNegativeOrFallbackText =
|
|
306
397
|
textContent.toLowerCase().includes('cannot answer') ||
|
|
307
398
|
textContent.toLowerCase().includes('no relevant data') ||
|
|
@@ -315,7 +406,7 @@ export function MessageBubble({
|
|
|
315
406
|
!['text', 'table'].includes(ui.type) ||
|
|
316
407
|
(ui.type === 'text' && !hasRichUI && allProducts.length === 0 && textContent &&
|
|
317
408
|
!processedMarkdown.toLowerCase().includes(textContent.trim().toLowerCase())));
|
|
318
|
-
|
|
409
|
+
|
|
319
410
|
if (!shouldShow) return null;
|
|
320
411
|
return (
|
|
321
412
|
<div className="w-full mt-3">
|
|
@@ -330,7 +421,6 @@ export function MessageBubble({
|
|
|
330
421
|
);
|
|
331
422
|
})()}
|
|
332
423
|
|
|
333
|
-
|
|
334
424
|
{/* Product Carousel */}
|
|
335
425
|
{!isUser && !hasRichUI && !shouldSuppressProductCarousel && allProducts.length > 0 && (
|
|
336
426
|
<div className="w-full mt-1">
|
|
@@ -342,28 +432,50 @@ export function MessageBubble({
|
|
|
342
432
|
</div>
|
|
343
433
|
)}
|
|
344
434
|
|
|
345
|
-
{/* Footer actions: Sources
|
|
435
|
+
{/* Footer actions: Sources, Trace, Timestamp & Feedback */}
|
|
346
436
|
{!isUser && (
|
|
347
|
-
<div className=
|
|
437
|
+
<div className={`flex items-center gap-3 mt-1.5 w-full flex-wrap ${isCompact ? 'gap-2' : 'gap-3'}`}>
|
|
438
|
+
{/* Sources toggle */}
|
|
348
439
|
{sources && sources.length > 0 && (
|
|
349
440
|
<button
|
|
350
441
|
onClick={() => setShowSources(s => !s)}
|
|
351
|
-
className="text-[11px] text-indigo-400 hover:text-indigo-300 transition-colors flex items-center gap-1"
|
|
442
|
+
className="text-[11px] text-indigo-400 hover:text-indigo-300 dark:text-indigo-400/70 dark:hover:text-indigo-300 transition-colors flex items-center gap-1 font-medium"
|
|
352
443
|
>
|
|
353
444
|
{showSources ? <ChevronDown className="w-3 h-3" /> : <ChevronRight className="w-3 h-3" />}
|
|
354
|
-
{sources.length} source{sources.length !== 1 ? 's' : ''}
|
|
445
|
+
{sources.length} source{sources.length !== 1 ? 's' : ''}
|
|
355
446
|
</button>
|
|
356
447
|
)}
|
|
357
448
|
|
|
449
|
+
{/* Trace toggle */}
|
|
358
450
|
{message.trace && (
|
|
359
451
|
<button
|
|
360
452
|
onClick={() => setShowTrace(t => !t)}
|
|
361
|
-
className="text-[11px] text-emerald-500 hover:text-emerald-400 transition-colors flex items-center gap-1"
|
|
453
|
+
className="text-[11px] text-emerald-500/70 hover:text-emerald-400 dark:text-emerald-500/50 dark:hover:text-emerald-400 transition-colors flex items-center gap-1 font-medium"
|
|
362
454
|
>
|
|
363
455
|
<Activity className="w-3 h-3" />
|
|
364
|
-
{showTrace ? 'Hide
|
|
456
|
+
{showTrace ? 'Hide trace' : 'Trace'}
|
|
365
457
|
</button>
|
|
366
458
|
)}
|
|
459
|
+
|
|
460
|
+
{/* Spacer */}
|
|
461
|
+
<div className="flex-1" />
|
|
462
|
+
|
|
463
|
+
{/* Timestamp */}
|
|
464
|
+
{timeLabel && isCompleted && (
|
|
465
|
+
<span className="flex items-center gap-1 text-[10px] text-slate-300 dark:text-white/20 font-medium select-none">
|
|
466
|
+
<Clock className="w-2.5 h-2.5" />
|
|
467
|
+
{timeLabel}
|
|
468
|
+
</span>
|
|
469
|
+
)}
|
|
470
|
+
|
|
471
|
+
{/* Feedback thumbs — only for completed, non-user messages with an ID */}
|
|
472
|
+
{isCompleted && onFeedback && message.id && (
|
|
473
|
+
<FeedbackBar
|
|
474
|
+
messageId={message.id}
|
|
475
|
+
onFeedback={onFeedback}
|
|
476
|
+
primaryColor={primaryColor}
|
|
477
|
+
/>
|
|
478
|
+
)}
|
|
367
479
|
</div>
|
|
368
480
|
)}
|
|
369
481
|
|
|
@@ -17,6 +17,8 @@ import {
|
|
|
17
17
|
FileText,
|
|
18
18
|
Puzzle,
|
|
19
19
|
MessageSquare,
|
|
20
|
+
Cpu,
|
|
21
|
+
Cloud,
|
|
20
22
|
} from 'lucide-react';
|
|
21
23
|
import { ArchitectureCardProps, Snippet, PipelineStep, ProviderPill } from '../types';
|
|
22
24
|
|
|
@@ -51,6 +53,8 @@ export const AI_MODELS: ProviderPill[] = [
|
|
|
51
53
|
{ Icon: Sparkles, label: 'OpenAI' },
|
|
52
54
|
{ Icon: Bot, label: 'Anthropic' },
|
|
53
55
|
{ Icon: Brain, label: 'Gemini' },
|
|
56
|
+
{ Icon: Cpu, label: 'Groq' },
|
|
57
|
+
{ Icon: Cloud, label: 'Qwen' },
|
|
54
58
|
{ Icon: Code, label: 'Copilot' },
|
|
55
59
|
{ Icon: Terminal, label: 'LiteLLM' },
|
|
56
60
|
];
|
package/src/config/RagConfig.ts
CHANGED
|
@@ -157,6 +157,19 @@ export interface UIConfig {
|
|
|
157
157
|
// RAG Pipeline Tuning
|
|
158
158
|
// ---------------------------------------------------------------------------
|
|
159
159
|
|
|
160
|
+
export interface CAGConfig {
|
|
161
|
+
/** Enable Cold RAG (Cache Augmented Generation) */
|
|
162
|
+
enabled?: boolean;
|
|
163
|
+
/** Namespace containing the cold data (e.g., static manuals/guides) */
|
|
164
|
+
coldNamespace?: string;
|
|
165
|
+
/** Limit of cold documents to retrieve at initialization and keep in cache/context */
|
|
166
|
+
coldLimit?: number;
|
|
167
|
+
/** Specific search query to retrieve the cold documents (e.g., "manual", "documentation") */
|
|
168
|
+
coldQuery?: string;
|
|
169
|
+
/** Specific document IDs to load as cold context */
|
|
170
|
+
coldDocumentIds?: string[];
|
|
171
|
+
}
|
|
172
|
+
|
|
160
173
|
export interface RAGConfig {
|
|
161
174
|
/** Number of top-K chunks retrieved per query */
|
|
162
175
|
topK?: number;
|
|
@@ -197,6 +210,18 @@ export interface RAGConfig {
|
|
|
197
210
|
* Defaults to built-in list (find, search, tell me about, etc.).
|
|
198
211
|
*/
|
|
199
212
|
vectorKeywords?: string[];
|
|
213
|
+
/** Cold RAG (Cache Augmented Generation) configuration */
|
|
214
|
+
cag?: CAGConfig;
|
|
215
|
+
/** Chat history configuration */
|
|
216
|
+
history?: {
|
|
217
|
+
enabled?: boolean;
|
|
218
|
+
tableName?: string;
|
|
219
|
+
};
|
|
220
|
+
/** User feedback configuration */
|
|
221
|
+
feedback?: {
|
|
222
|
+
enabled?: boolean;
|
|
223
|
+
tableName?: string;
|
|
224
|
+
};
|
|
200
225
|
}
|
|
201
226
|
|
|
202
227
|
export interface RetrievalConfig {
|
|
@@ -229,11 +254,23 @@ export interface WorkflowConfig {
|
|
|
229
254
|
options?: Record<string, unknown>;
|
|
230
255
|
}
|
|
231
256
|
|
|
257
|
+
export interface MCPServerConfig {
|
|
258
|
+
name: string;
|
|
259
|
+
transport: 'stdio' | 'sse';
|
|
260
|
+
url?: string; // Required for SSE transport
|
|
261
|
+
command?: string; // Required for Stdio transport
|
|
262
|
+
args?: string[]; // Optional for Stdio transport
|
|
263
|
+
env?: Record<string, string>; // Optional env variables for Stdio child process
|
|
264
|
+
}
|
|
265
|
+
|
|
232
266
|
// ---------------------------------------------------------------------------
|
|
233
267
|
// Root Config
|
|
234
268
|
// ---------------------------------------------------------------------------
|
|
235
269
|
|
|
236
270
|
export interface RagConfig {
|
|
271
|
+
/** License key for commercial production validation */
|
|
272
|
+
licenseKey?: string;
|
|
273
|
+
|
|
237
274
|
/**
|
|
238
275
|
* Unique identifier for the consuming project.
|
|
239
276
|
* Used as the vector DB namespace to achieve multi-tenancy.
|
|
@@ -257,6 +294,15 @@ export interface RagConfig {
|
|
|
257
294
|
|
|
258
295
|
/** Optional Graph database configuration */
|
|
259
296
|
graphDb?: GraphDBConfig;
|
|
297
|
+
|
|
298
|
+
/** Optional Telemetry configuration for observability logging */
|
|
299
|
+
telemetry?: {
|
|
300
|
+
enabled?: boolean;
|
|
301
|
+
url?: string;
|
|
302
|
+
};
|
|
303
|
+
|
|
304
|
+
/** Optional Model Context Protocol (MCP) server configurations */
|
|
305
|
+
mcpServers?: MCPServerConfig[];
|
|
260
306
|
}
|
|
261
307
|
|
|
262
308
|
/**
|
package/src/config/constants.ts
CHANGED
|
@@ -26,6 +26,8 @@ export const LLM_PROVIDERS = [
|
|
|
26
26
|
'anthropic',
|
|
27
27
|
'ollama',
|
|
28
28
|
'gemini',
|
|
29
|
+
'groq',
|
|
30
|
+
'qwen',
|
|
29
31
|
'rest',
|
|
30
32
|
'universal_rest',
|
|
31
33
|
'custom',
|
|
@@ -35,6 +37,7 @@ export const EMBEDDING_PROVIDERS = [
|
|
|
35
37
|
'openai',
|
|
36
38
|
'ollama',
|
|
37
39
|
'gemini',
|
|
40
|
+
'qwen',
|
|
38
41
|
'rest',
|
|
39
42
|
'universal_rest',
|
|
40
43
|
'custom',
|
|
@@ -51,6 +54,7 @@ export const PROVIDERS_WITH_EMBEDDINGS = [
|
|
|
51
54
|
'openai',
|
|
52
55
|
'ollama',
|
|
53
56
|
'gemini',
|
|
57
|
+
'qwen',
|
|
54
58
|
'rest',
|
|
55
59
|
'universal_rest',
|
|
56
60
|
] as const;
|
|
@@ -149,6 +149,7 @@ export function getEnvConfig(env: Record<string, string | undefined> = process.e
|
|
|
149
149
|
|
|
150
150
|
return {
|
|
151
151
|
projectId,
|
|
152
|
+
licenseKey: readString(env, 'RETRIVORA_LICENSE_KEY') ?? readString(env, 'LICENSE_KEY') ?? base?.licenseKey,
|
|
152
153
|
vectorDb: {
|
|
153
154
|
provider: vectorProvider,
|
|
154
155
|
indexName:
|
|
@@ -217,6 +218,10 @@ export function getEnvConfig(env: Record<string, string | undefined> = process.e
|
|
|
217
218
|
try { return JSON.parse(raw) as Record<string, string>; } catch { return undefined; }
|
|
218
219
|
})(),
|
|
219
220
|
},
|
|
221
|
+
telemetry: {
|
|
222
|
+
enabled: readString(env, 'TELEMETRY_ENABLED') === 'true' || readString(env, 'NEXT_PUBLIC_TELEMETRY_ENABLED') === 'true' || base?.telemetry?.enabled || false,
|
|
223
|
+
url: readString(env, 'TELEMETRY_URL') ?? readString(env, 'NEXT_PUBLIC_TELEMETRY_URL') ?? base?.telemetry?.url ?? '/api/telemetry',
|
|
224
|
+
},
|
|
220
225
|
// Optional graph DB — driven by GRAPH_DB_PROVIDER env var
|
|
221
226
|
...(readString(env, 'GRAPH_DB_PROVIDER') ? {
|
|
222
227
|
graphDb: {
|
|
@@ -228,5 +233,15 @@ export function getEnvConfig(env: Record<string, string | undefined> = process.e
|
|
|
228
233
|
},
|
|
229
234
|
},
|
|
230
235
|
} : {}),
|
|
236
|
+
mcpServers: (() => {
|
|
237
|
+
const raw = readString(env, 'MCP_SERVERS') ?? readString(env, 'NEXT_PUBLIC_MCP_SERVERS');
|
|
238
|
+
if (!raw) return undefined;
|
|
239
|
+
try {
|
|
240
|
+
return JSON.parse(raw);
|
|
241
|
+
} catch (e) {
|
|
242
|
+
console.warn('[serverConfig] Failed to parse MCP_SERVERS env:', e);
|
|
243
|
+
return undefined;
|
|
244
|
+
}
|
|
245
|
+
})(),
|
|
231
246
|
};
|
|
232
247
|
}
|
|
@@ -61,6 +61,12 @@ export class ConfigResolver {
|
|
|
61
61
|
: envConfig.embedding,
|
|
62
62
|
ui: hostConfig.ui ? mergeDefined(envConfig.ui, hostConfig.ui) : envConfig.ui,
|
|
63
63
|
rag: hostConfig.rag ? { ...envConfig.rag, ...hostConfig.rag } : envConfig.rag,
|
|
64
|
+
telemetry: hostConfig.telemetry
|
|
65
|
+
? {
|
|
66
|
+
...envConfig.telemetry,
|
|
67
|
+
...hostConfig.telemetry,
|
|
68
|
+
}
|
|
69
|
+
: envConfig.telemetry,
|
|
64
70
|
};
|
|
65
71
|
}
|
|
66
72
|
|