@retrivora-ai/rag-engine 1.0.4 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/DocumentChunker-Dh9TvmGG.d.mts +45 -0
- package/dist/DocumentChunker-Dh9TvmGG.d.ts +45 -0
- package/dist/{RagConfig-DRJO4hGU.d.mts → RagConfig-BjC6zSTV.d.mts} +62 -1
- package/dist/{RagConfig-DRJO4hGU.d.ts → RagConfig-BjC6zSTV.d.ts} +62 -1
- package/dist/{chunk-6MLZHQZT.mjs → chunk-ZCDJSGUW.mjs} +237 -104
- package/dist/handlers/index.d.mts +2 -2
- package/dist/handlers/index.d.ts +2 -2
- package/dist/handlers/index.js +239 -106
- package/dist/handlers/index.mjs +11 -3
- package/dist/index-C3bLmWcR.d.ts +206 -0
- package/dist/index-CU_fQq__.d.mts +206 -0
- package/dist/index.d.mts +3 -4
- package/dist/index.d.ts +3 -4
- package/dist/index.js +103 -89
- package/dist/index.mjs +91 -95
- package/dist/server.d.mts +45 -97
- package/dist/server.d.ts +45 -97
- package/dist/server.js +319 -221
- package/dist/server.mjs +78 -167
- package/package.json +12 -10
- package/src/components/ChatWindow.tsx +2 -2
- package/src/components/ConfigProvider.tsx +2 -2
- package/src/components/MessageBubble.tsx +2 -2
- package/src/components/SourceCard.tsx +1 -1
- package/src/components/ThemeToggle.tsx +1 -1
- package/src/config/ConfigBuilder.ts +86 -211
- package/src/config/RagConfig.ts +4 -0
- package/src/config/uiConstants.ts +23 -0
- package/src/core/ConfigResolver.ts +57 -29
- package/src/core/LangChainAgent.ts +73 -40
- package/src/core/Pipeline.ts +64 -8
- package/src/core/ProviderRegistry.ts +2 -2
- package/src/core/QueryProcessor.ts +45 -12
- package/src/handlers/index.ts +138 -49
- package/src/hooks/useRagChat.ts +71 -32
- package/src/server.ts +12 -2
- package/dist/DocumentChunker-C-sCZPhi.d.mts +0 -102
- package/dist/DocumentChunker-C-sCZPhi.d.ts +0 -102
- package/dist/index-B2mutkgp.d.ts +0 -116
- package/dist/index-Bjy0es5a.d.mts +0 -116
package/dist/index.mjs
CHANGED
|
@@ -7,16 +7,16 @@ import {
|
|
|
7
7
|
} from "./chunk-X4TOT24V.mjs";
|
|
8
8
|
|
|
9
9
|
// src/components/ChatWidget.tsx
|
|
10
|
-
import
|
|
11
|
-
import { MessageSquare
|
|
10
|
+
import React6, { useState as useState4 } from "react";
|
|
11
|
+
import { MessageSquare, X as X2 } from "lucide-react";
|
|
12
12
|
|
|
13
13
|
// src/components/ChatWindow.tsx
|
|
14
|
-
import
|
|
14
|
+
import React5, { useState as useState3, useRef as useRef2, useEffect as useEffect3, useCallback as useCallback2 } from "react";
|
|
15
15
|
import {
|
|
16
|
-
Bot as
|
|
16
|
+
Bot as Bot2,
|
|
17
17
|
Trash2,
|
|
18
18
|
X,
|
|
19
|
-
Sparkles
|
|
19
|
+
Sparkles,
|
|
20
20
|
ArrowUp,
|
|
21
21
|
TriangleAlert
|
|
22
22
|
} from "lucide-react";
|
|
@@ -159,6 +159,22 @@ function useStoredMessages(storageKey, persist) {
|
|
|
159
159
|
}
|
|
160
160
|
|
|
161
161
|
// src/hooks/useRagChat.ts
|
|
162
|
+
function parseSseChunk(raw) {
|
|
163
|
+
const frames = [];
|
|
164
|
+
for (const block of raw.split("\n\n")) {
|
|
165
|
+
for (const line of block.split("\n")) {
|
|
166
|
+
if (!line.startsWith("data: ")) continue;
|
|
167
|
+
try {
|
|
168
|
+
const frame = JSON.parse(line.slice(6));
|
|
169
|
+
if (frame && typeof frame === "object" && "type" in frame) {
|
|
170
|
+
frames.push(frame);
|
|
171
|
+
}
|
|
172
|
+
} catch (e) {
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
return frames;
|
|
177
|
+
}
|
|
162
178
|
function useRagChat(projectId, options = {}) {
|
|
163
179
|
const {
|
|
164
180
|
apiUrl = "/api/chat",
|
|
@@ -177,11 +193,12 @@ function useRagChat(projectId, options = {}) {
|
|
|
177
193
|
messagesRef.current = messages;
|
|
178
194
|
}, [messages]);
|
|
179
195
|
const sendMessage = useCallback(
|
|
180
|
-
async (text,
|
|
196
|
+
async (text, opts) => {
|
|
197
|
+
var _a, _b;
|
|
181
198
|
const trimmed = text.trim();
|
|
182
199
|
if (!trimmed || isLoading) return;
|
|
183
200
|
lastInputRef.current = trimmed;
|
|
184
|
-
if (!(
|
|
201
|
+
if (!(opts == null ? void 0 : opts.skipUserMessage)) {
|
|
185
202
|
const userMessage = {
|
|
186
203
|
id: `user_${Date.now()}`,
|
|
187
204
|
role: "user",
|
|
@@ -214,6 +231,7 @@ function useRagChat(projectId, options = {}) {
|
|
|
214
231
|
const decoder = new TextDecoder();
|
|
215
232
|
let assistantContent = "";
|
|
216
233
|
let sources = [];
|
|
234
|
+
let buffer = "";
|
|
217
235
|
const assistantMessageId = `assistant_${Date.now()}`;
|
|
218
236
|
setMessages((prev) => [
|
|
219
237
|
...prev,
|
|
@@ -227,27 +245,19 @@ function useRagChat(projectId, options = {}) {
|
|
|
227
245
|
while (true) {
|
|
228
246
|
const { done, value } = await reader.read();
|
|
229
247
|
if (done) break;
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
248
|
+
buffer += decoder.decode(value, { stream: true });
|
|
249
|
+
const lastBoundary = buffer.lastIndexOf("\n\n");
|
|
250
|
+
if (lastBoundary === -1) continue;
|
|
251
|
+
const complete = buffer.slice(0, lastBoundary + 2);
|
|
252
|
+
buffer = buffer.slice(lastBoundary + 2);
|
|
253
|
+
for (const frame of parseSseChunk(complete)) {
|
|
254
|
+
if (frame.type === "text") {
|
|
255
|
+
assistantContent += frame.text;
|
|
256
|
+
} else if (frame.type === "metadata") {
|
|
257
|
+
sources = (_a = frame.sources) != null ? _a : [];
|
|
258
|
+
} else if (frame.type === "error") {
|
|
259
|
+
setError(frame.error || "Stream error");
|
|
239
260
|
}
|
|
240
|
-
} else if (chunk.includes("__ERROR__")) {
|
|
241
|
-
const [text2, errorStr] = chunk.split("__ERROR__");
|
|
242
|
-
if (text2) assistantContent += text2;
|
|
243
|
-
try {
|
|
244
|
-
const err = JSON.parse(errorStr);
|
|
245
|
-
setError(err.error || "Stream error");
|
|
246
|
-
} catch (e) {
|
|
247
|
-
setError("An error occurred during streaming");
|
|
248
|
-
}
|
|
249
|
-
} else {
|
|
250
|
-
assistantContent += chunk;
|
|
251
261
|
}
|
|
252
262
|
setMessages(
|
|
253
263
|
(prev) => prev.map(
|
|
@@ -255,6 +265,12 @@ function useRagChat(projectId, options = {}) {
|
|
|
255
265
|
)
|
|
256
266
|
);
|
|
257
267
|
}
|
|
268
|
+
if (buffer.trim()) {
|
|
269
|
+
for (const frame of parseSseChunk(buffer)) {
|
|
270
|
+
if (frame.type === "text") assistantContent += frame.text;
|
|
271
|
+
else if (frame.type === "metadata") sources = (_b = frame.sources) != null ? _b : [];
|
|
272
|
+
}
|
|
273
|
+
}
|
|
258
274
|
const finalAssistantMessage = {
|
|
259
275
|
id: assistantMessageId,
|
|
260
276
|
role: "assistant",
|
|
@@ -297,32 +313,7 @@ function useRagChat(projectId, options = {}) {
|
|
|
297
313
|
};
|
|
298
314
|
}
|
|
299
315
|
|
|
300
|
-
// src/
|
|
301
|
-
import React5 from "react";
|
|
302
|
-
import {
|
|
303
|
-
Zap,
|
|
304
|
-
Database,
|
|
305
|
-
Layers,
|
|
306
|
-
Search,
|
|
307
|
-
Box,
|
|
308
|
-
Package,
|
|
309
|
-
Activity,
|
|
310
|
-
Hexagon,
|
|
311
|
-
Sparkles,
|
|
312
|
-
Bot as Bot2,
|
|
313
|
-
Brain,
|
|
314
|
-
Rabbit,
|
|
315
|
-
Code,
|
|
316
|
-
Terminal,
|
|
317
|
-
FileText,
|
|
318
|
-
Puzzle,
|
|
319
|
-
MessageSquare
|
|
320
|
-
} from "lucide-react";
|
|
321
|
-
var CHAT_SUGGESTIONS = [
|
|
322
|
-
"What can you help me with?",
|
|
323
|
-
"Summarise the key topics",
|
|
324
|
-
"Show me an example"
|
|
325
|
-
];
|
|
316
|
+
// src/config/uiConstants.ts
|
|
326
317
|
var BORDER_RADIUS_MAP = {
|
|
327
318
|
none: "rounded-none",
|
|
328
319
|
sm: "rounded-sm",
|
|
@@ -331,6 +322,11 @@ var BORDER_RADIUS_MAP = {
|
|
|
331
322
|
xl: "rounded-xl",
|
|
332
323
|
full: "rounded-3xl"
|
|
333
324
|
};
|
|
325
|
+
var CHAT_SUGGESTIONS = [
|
|
326
|
+
"What can you help me with?",
|
|
327
|
+
"Summarise the key topics",
|
|
328
|
+
"Show me an example"
|
|
329
|
+
];
|
|
334
330
|
|
|
335
331
|
// src/components/ChatWindow.tsx
|
|
336
332
|
function ChatWindow({ className = "", style, onClose, showClose = false }) {
|
|
@@ -374,58 +370,58 @@ function ChatWindow({ className = "", style, onClose, showClose = false }) {
|
|
|
374
370
|
const isEmpty = messages.length === 0;
|
|
375
371
|
const currentRadius = BORDER_RADIUS_MAP[ui.borderRadius || "xl"];
|
|
376
372
|
const isGlass = ui.visualStyle !== "solid";
|
|
377
|
-
return /* @__PURE__ */
|
|
373
|
+
return /* @__PURE__ */ React5.createElement(
|
|
378
374
|
"div",
|
|
379
375
|
{
|
|
380
376
|
className: `flex flex-col border border-slate-200 dark:border-white/10 shadow-2xl transition-all duration-300 ${currentRadius} ${isGlass ? "bg-white/90 dark:bg-[#0f0f1a]/90 backdrop-blur-xl" : "bg-white dark:bg-[#0f0f1a]"} ${className}`,
|
|
381
377
|
style: __spreadValues({ "--primary": ui.primaryColor, "--accent": ui.accentColor }, style)
|
|
382
378
|
},
|
|
383
|
-
/* @__PURE__ */
|
|
379
|
+
/* @__PURE__ */ React5.createElement(
|
|
384
380
|
"div",
|
|
385
381
|
{
|
|
386
382
|
className: "flex items-center justify-between px-5 py-4 border-b border-slate-200 dark:border-white/10",
|
|
387
383
|
style: { background: `linear-gradient(135deg, ${ui.primaryColor}15, ${ui.accentColor}10)` }
|
|
388
384
|
},
|
|
389
|
-
/* @__PURE__ */
|
|
385
|
+
/* @__PURE__ */ React5.createElement("div", { className: "flex items-center gap-3" }, ui.logoUrl ? (
|
|
390
386
|
// eslint-disable-next-line @next/next/no-img-element
|
|
391
|
-
/* @__PURE__ */
|
|
392
|
-
) : /* @__PURE__ */
|
|
387
|
+
/* @__PURE__ */ React5.createElement("img", { src: ui.logoUrl, alt: "logo", className: "w-8 h-8 rounded-lg object-cover" })
|
|
388
|
+
) : /* @__PURE__ */ React5.createElement(
|
|
393
389
|
"div",
|
|
394
390
|
{
|
|
395
391
|
className: `w-9 h-9 flex items-center justify-center shadow-md ${ui.borderRadius === "full" ? "rounded-full" : "rounded-xl"}`,
|
|
396
392
|
style: { background: `linear-gradient(135deg, ${ui.primaryColor}, ${ui.accentColor})` }
|
|
397
393
|
},
|
|
398
|
-
/* @__PURE__ */
|
|
399
|
-
), /* @__PURE__ */
|
|
400
|
-
/* @__PURE__ */
|
|
394
|
+
/* @__PURE__ */ React5.createElement(Bot2, { className: "w-5 h-5 text-white" })
|
|
395
|
+
), /* @__PURE__ */ React5.createElement("div", null, /* @__PURE__ */ React5.createElement("h2", { className: "text-slate-900 dark:text-white font-semibold text-sm leading-tight" }, ui.title), ui.poweredBy && /* @__PURE__ */ React5.createElement("p", { className: "text-slate-500 dark:text-white/40 text-[11px] leading-tight" }, `Powered by ${ui.poweredBy}`))),
|
|
396
|
+
/* @__PURE__ */ React5.createElement("div", { className: "flex items-center gap-2" }, /* @__PURE__ */ React5.createElement("span", { className: "flex items-center gap-1 text-[10px] text-emerald-500 dark:text-emerald-400" }, /* @__PURE__ */ React5.createElement("span", { className: "w-1.5 h-1.5 rounded-full bg-emerald-500 dark:bg-emerald-400 animate-pulse" }), "Online"), mounted && messages.length > 0 && /* @__PURE__ */ React5.createElement(
|
|
401
397
|
"button",
|
|
402
398
|
{
|
|
403
399
|
onClick: clearHistory,
|
|
404
400
|
title: "Clear conversation",
|
|
405
401
|
className: "w-7 h-7 rounded-lg flex items-center justify-center text-slate-400 hover:text-slate-600 dark:text-white/40 dark:hover:text-white/70 hover:bg-slate-100 dark:hover:bg-white/10 transition-all cursor-pointer"
|
|
406
402
|
},
|
|
407
|
-
/* @__PURE__ */
|
|
408
|
-
), showClose && onClose && /* @__PURE__ */
|
|
403
|
+
/* @__PURE__ */ React5.createElement(Trash2, { className: "w-3.5 h-3.5" })
|
|
404
|
+
), showClose && onClose && /* @__PURE__ */ React5.createElement(
|
|
409
405
|
"button",
|
|
410
406
|
{
|
|
411
407
|
onClick: onClose,
|
|
412
408
|
title: "Close chat",
|
|
413
409
|
className: "w-7 h-7 rounded-lg flex items-center justify-center text-slate-400 hover:text-slate-600 dark:text-white/40 dark:hover:text-white/70 hover:bg-slate-100 dark:hover:bg-white/10 transition-all cursor-pointer"
|
|
414
410
|
},
|
|
415
|
-
/* @__PURE__ */
|
|
411
|
+
/* @__PURE__ */ React5.createElement(X, { className: "w-4 h-4" })
|
|
416
412
|
))
|
|
417
413
|
),
|
|
418
|
-
/* @__PURE__ */
|
|
414
|
+
/* @__PURE__ */ React5.createElement("div", { className: "flex-1 overflow-y-auto px-4 py-4 space-y-5 scrollbar-thin scrollbar-thumb-slate-200 dark:scrollbar-thumb-white/10 scrollbar-track-transparent min-h-0 bg-slate-50 dark:bg-transparent" }, !mounted || isEmpty ? (
|
|
419
415
|
/* Welcome state */
|
|
420
|
-
/* @__PURE__ */
|
|
416
|
+
/* @__PURE__ */ React5.createElement("div", { className: "h-full flex flex-col items-center justify-center text-center gap-4 px-6 py-12" }, /* @__PURE__ */ React5.createElement(
|
|
421
417
|
"div",
|
|
422
418
|
{
|
|
423
419
|
className: `w-16 h-16 flex items-center justify-center shadow-lg ${ui.borderRadius === "full" ? "rounded-full" : "rounded-2xl"}`,
|
|
424
420
|
style: { background: `linear-gradient(135deg, ${ui.primaryColor}, ${ui.accentColor})` }
|
|
425
421
|
},
|
|
426
|
-
/* @__PURE__ */
|
|
427
|
-
), /* @__PURE__ */
|
|
428
|
-
(suggestion) => /* @__PURE__ */
|
|
422
|
+
/* @__PURE__ */ React5.createElement(Sparkles, { className: "w-8 h-8 text-white" })
|
|
423
|
+
), /* @__PURE__ */ React5.createElement("div", null, /* @__PURE__ */ React5.createElement("p", { className: "text-slate-800 dark:text-white/80 font-medium leading-relaxed" }, ui.welcomeMessage), /* @__PURE__ */ React5.createElement("p", { className: "text-slate-500 dark:text-white/30 text-sm mt-2" }, "Ask a question to get started")), /* @__PURE__ */ React5.createElement("div", { className: "flex flex-wrap gap-2 justify-center mt-2" }, CHAT_SUGGESTIONS.map(
|
|
424
|
+
(suggestion) => /* @__PURE__ */ React5.createElement(
|
|
429
425
|
"button",
|
|
430
426
|
{
|
|
431
427
|
key: suggestion,
|
|
@@ -439,7 +435,7 @@ function ChatWindow({ className = "", style, onClose, showClose = false }) {
|
|
|
439
435
|
suggestion
|
|
440
436
|
)
|
|
441
437
|
)))
|
|
442
|
-
) : messages.map((msg, index) => /* @__PURE__ */
|
|
438
|
+
) : messages.map((msg, index) => /* @__PURE__ */ React5.createElement(
|
|
443
439
|
MessageBubble,
|
|
444
440
|
{
|
|
445
441
|
key: msg.id,
|
|
@@ -449,7 +445,7 @@ function ChatWindow({ className = "", style, onClose, showClose = false }) {
|
|
|
449
445
|
primaryColor: ui.primaryColor,
|
|
450
446
|
accentColor: ui.accentColor
|
|
451
447
|
}
|
|
452
|
-
)), isLoading && ((_a = messages[messages.length - 1]) == null ? void 0 : _a.role) !== "assistant" && /* @__PURE__ */
|
|
448
|
+
)), isLoading && ((_a = messages[messages.length - 1]) == null ? void 0 : _a.role) !== "assistant" && /* @__PURE__ */ React5.createElement(
|
|
453
449
|
MessageBubble,
|
|
454
450
|
{
|
|
455
451
|
message: { role: "assistant", content: "" },
|
|
@@ -457,8 +453,8 @@ function ChatWindow({ className = "", style, onClose, showClose = false }) {
|
|
|
457
453
|
primaryColor: ui.primaryColor,
|
|
458
454
|
accentColor: ui.accentColor
|
|
459
455
|
}
|
|
460
|
-
), error && /* @__PURE__ */
|
|
461
|
-
/* @__PURE__ */
|
|
456
|
+
), error && /* @__PURE__ */ React5.createElement("div", { className: "flex items-center gap-2 text-rose-500 dark:text-rose-400 text-sm bg-rose-50 dark:bg-rose-400/10 border border-rose-200 dark:border-rose-400/20 rounded-xl px-4 py-3" }, /* @__PURE__ */ React5.createElement(TriangleAlert, { className: "w-4 h-4 flex-shrink-0" }), /* @__PURE__ */ React5.createElement("span", null, error)), /* @__PURE__ */ React5.createElement("div", { ref: bottomRef })),
|
|
457
|
+
/* @__PURE__ */ React5.createElement("div", { className: `px-4 pb-4 pt-2 border-t border-slate-200 dark:border-white/10 ${isGlass ? "bg-transparent" : "bg-white dark:bg-[#0f0f1a]"}` }, /* @__PURE__ */ React5.createElement("div", { className: `flex items-end gap-2 bg-slate-50 dark:bg-white/5 border border-slate-200 dark:border-white/10 p-2 focus-within:border-slate-300 dark:focus-within:border-white/20 transition-all ${ui.borderRadius === "full" ? "rounded-3xl" : "rounded-2xl"}` }, /* @__PURE__ */ React5.createElement(
|
|
462
458
|
"textarea",
|
|
463
459
|
{
|
|
464
460
|
ref: inputRef,
|
|
@@ -471,7 +467,7 @@ function ChatWindow({ className = "", style, onClose, showClose = false }) {
|
|
|
471
467
|
className: "flex-1 bg-transparent text-slate-900 dark:text-white/90 placeholder-slate-400 dark:placeholder-white/30 text-sm resize-none outline-none py-1.5 px-2 max-h-32 leading-relaxed disabled:opacity-50",
|
|
472
468
|
style: { scrollbarWidth: "none" }
|
|
473
469
|
}
|
|
474
|
-
), /* @__PURE__ */
|
|
470
|
+
), /* @__PURE__ */ React5.createElement(
|
|
475
471
|
"button",
|
|
476
472
|
{
|
|
477
473
|
onClick: sendMessage,
|
|
@@ -482,8 +478,8 @@ function ChatWindow({ className = "", style, onClose, showClose = false }) {
|
|
|
482
478
|
// slate-400/20 for light mode disabled
|
|
483
479
|
}
|
|
484
480
|
},
|
|
485
|
-
/* @__PURE__ */
|
|
486
|
-
)), /* @__PURE__ */
|
|
481
|
+
/* @__PURE__ */ React5.createElement(ArrowUp, { className: "w-4 h-4 text-white" })
|
|
482
|
+
)), /* @__PURE__ */ React5.createElement("p", { className: "text-center text-[10px] text-slate-400 dark:text-white/20 mt-2" }, "Press Enter to send \xB7 Shift+Enter for new line"))
|
|
487
483
|
);
|
|
488
484
|
}
|
|
489
485
|
|
|
@@ -500,13 +496,13 @@ function ChatWidget({ position = "bottom-right" }) {
|
|
|
500
496
|
setIsOpen(true);
|
|
501
497
|
setHasUnread(false);
|
|
502
498
|
};
|
|
503
|
-
return /* @__PURE__ */
|
|
499
|
+
return /* @__PURE__ */ React6.createElement(React6.Fragment, null, /* @__PURE__ */ React6.createElement(
|
|
504
500
|
"div",
|
|
505
501
|
{
|
|
506
502
|
className: `fixed z-[9998] w-[380px] max-w-[calc(100vw-3rem)] transition-all duration-300 ease-in-out ${windowPositionClass} ${isOpen ? "opacity-100 translate-y-0 pointer-events-auto" : "opacity-0 translate-y-4 pointer-events-none"}`,
|
|
507
503
|
style: { height: "600px", maxHeight: "calc(100vh - 6rem)" }
|
|
508
504
|
},
|
|
509
|
-
/* @__PURE__ */
|
|
505
|
+
/* @__PURE__ */ React6.createElement(
|
|
510
506
|
ChatWindow,
|
|
511
507
|
{
|
|
512
508
|
className: "h-full relative z-10",
|
|
@@ -514,13 +510,13 @@ function ChatWidget({ position = "bottom-right" }) {
|
|
|
514
510
|
onClose: () => setIsOpen(false)
|
|
515
511
|
}
|
|
516
512
|
),
|
|
517
|
-
/* @__PURE__ */
|
|
513
|
+
/* @__PURE__ */ React6.createElement(
|
|
518
514
|
"div",
|
|
519
515
|
{
|
|
520
516
|
className: `absolute -bottom-1.5 w-4 h-4 rotate-45 border-r border-b border-slate-200 dark:border-white/10 z-0 ${ui.visualStyle === "solid" ? "bg-white dark:bg-[#0f0f1a]" : "bg-white/90 dark:bg-[#0f0f1a]/90 backdrop-blur-xl"} ${position === "bottom-left" ? "left-5" : "right-5"}`
|
|
521
517
|
}
|
|
522
518
|
)
|
|
523
|
-
), /* @__PURE__ */
|
|
519
|
+
), /* @__PURE__ */ React6.createElement(
|
|
524
520
|
"button",
|
|
525
521
|
{
|
|
526
522
|
onClick: isOpen ? () => setIsOpen(false) : handleOpen,
|
|
@@ -528,26 +524,26 @@ function ChatWidget({ position = "bottom-right" }) {
|
|
|
528
524
|
style: { background: `linear-gradient(135deg, ${ui.primaryColor}, ${ui.accentColor})` },
|
|
529
525
|
"aria-label": "Open chat"
|
|
530
526
|
},
|
|
531
|
-
/* @__PURE__ */
|
|
527
|
+
/* @__PURE__ */ React6.createElement(
|
|
532
528
|
"span",
|
|
533
529
|
{
|
|
534
530
|
className: "absolute inset-0 rounded-full animate-ping opacity-20",
|
|
535
531
|
style: { background: ui.primaryColor }
|
|
536
532
|
}
|
|
537
533
|
),
|
|
538
|
-
/* @__PURE__ */
|
|
534
|
+
/* @__PURE__ */ React6.createElement(
|
|
539
535
|
"span",
|
|
540
536
|
{
|
|
541
537
|
className: `transition-transform duration-300 ${isOpen ? "rotate-90 scale-90" : "rotate-0 scale-100"}`
|
|
542
538
|
},
|
|
543
|
-
isOpen ? /* @__PURE__ */
|
|
539
|
+
isOpen ? /* @__PURE__ */ React6.createElement(X2, { className: "w-6 h-6 text-white" }) : /* @__PURE__ */ React6.createElement(MessageSquare, { className: "w-6 h-6 text-white" })
|
|
544
540
|
),
|
|
545
|
-
hasUnread && !isOpen && /* @__PURE__ */
|
|
541
|
+
hasUnread && !isOpen && /* @__PURE__ */ React6.createElement("span", { className: "absolute top-0 right-0 w-4 h-4 bg-rose-500 rounded-full border-2 border-white flex items-center justify-center text-[9px] font-bold text-white" }, "1")
|
|
546
542
|
));
|
|
547
543
|
}
|
|
548
544
|
|
|
549
545
|
// src/components/DocumentUpload.tsx
|
|
550
|
-
import
|
|
546
|
+
import React7, { useState as useState5, useRef as useRef3 } from "react";
|
|
551
547
|
import { Upload, File, X as X3, CheckCircle, AlertCircle, Loader2 } from "lucide-react";
|
|
552
548
|
function DocumentUpload({ namespace, onUploadComplete, className = "" }) {
|
|
553
549
|
const { ui } = useConfig();
|
|
@@ -603,7 +599,7 @@ function DocumentUpload({ namespace, onUploadComplete, className = "" }) {
|
|
|
603
599
|
};
|
|
604
600
|
const isUploading = fileStates.some((s) => s.status === "uploading");
|
|
605
601
|
const hasIdle = fileStates.some((s) => s.status === "idle");
|
|
606
|
-
return /* @__PURE__ */
|
|
602
|
+
return /* @__PURE__ */ React7.createElement(
|
|
607
603
|
"div",
|
|
608
604
|
{
|
|
609
605
|
className: `p-6 border-2 border-dashed transition-all duration-300 rounded-2xl ${isDragging ? "border-emerald-500 bg-emerald-50/50 dark:bg-emerald-500/5" : "border-slate-200 dark:border-white/10 bg-white dark:bg-white/5"} ${className}`,
|
|
@@ -611,14 +607,14 @@ function DocumentUpload({ namespace, onUploadComplete, className = "" }) {
|
|
|
611
607
|
onDragLeave,
|
|
612
608
|
onDrop
|
|
613
609
|
},
|
|
614
|
-
/* @__PURE__ */
|
|
610
|
+
/* @__PURE__ */ React7.createElement("div", { className: "flex flex-col items-center justify-center text-center" }, /* @__PURE__ */ React7.createElement(
|
|
615
611
|
"div",
|
|
616
612
|
{
|
|
617
613
|
className: "w-12 h-12 rounded-full flex items-center justify-center mb-4 shadow-sm",
|
|
618
614
|
style: { background: `linear-gradient(135deg, ${ui.primaryColor}20, ${ui.accentColor}20)` }
|
|
619
615
|
},
|
|
620
|
-
/* @__PURE__ */
|
|
621
|
-
), /* @__PURE__ */
|
|
616
|
+
/* @__PURE__ */ React7.createElement(Upload, { className: "w-6 h-6", style: { color: ui.primaryColor } })
|
|
617
|
+
), /* @__PURE__ */ React7.createElement("h3", { className: "text-slate-900 dark:text-white font-semibold mb-1" }, "Upload Documents"), /* @__PURE__ */ React7.createElement("p", { className: "text-slate-500 dark:text-white/40 text-sm mb-6 max-w-xs" }, "Drag and drop PDF, DOCX, TXT, or JSON files to train your AI on your own data."), /* @__PURE__ */ React7.createElement(
|
|
622
618
|
"button",
|
|
623
619
|
{
|
|
624
620
|
onClick: () => {
|
|
@@ -634,7 +630,7 @@ function DocumentUpload({ namespace, onUploadComplete, className = "" }) {
|
|
|
634
630
|
}
|
|
635
631
|
},
|
|
636
632
|
"Select Files"
|
|
637
|
-
), /* @__PURE__ */
|
|
633
|
+
), /* @__PURE__ */ React7.createElement(
|
|
638
634
|
"input",
|
|
639
635
|
{
|
|
640
636
|
ref: fileInputRef,
|
|
@@ -645,22 +641,22 @@ function DocumentUpload({ namespace, onUploadComplete, className = "" }) {
|
|
|
645
641
|
accept: ".pdf,.docx,.txt,.md,.json,.csv"
|
|
646
642
|
}
|
|
647
643
|
)),
|
|
648
|
-
fileStates.length > 0 && /* @__PURE__ */
|
|
644
|
+
fileStates.length > 0 && /* @__PURE__ */ React7.createElement("div", { className: "mt-8 space-y-3" }, fileStates.map((state, i) => /* @__PURE__ */ React7.createElement(
|
|
649
645
|
"div",
|
|
650
646
|
{
|
|
651
647
|
key: i,
|
|
652
648
|
className: "flex items-center justify-between p-3 rounded-xl bg-slate-50 dark:bg-white/5 border border-slate-100 dark:border-white/10"
|
|
653
649
|
},
|
|
654
|
-
/* @__PURE__ */
|
|
655
|
-
/* @__PURE__ */
|
|
650
|
+
/* @__PURE__ */ React7.createElement("div", { className: "flex items-center gap-3 overflow-hidden" }, /* @__PURE__ */ React7.createElement("div", { className: "w-8 h-8 rounded-lg bg-white dark:bg-white/10 flex items-center justify-center shadow-sm" }, /* @__PURE__ */ React7.createElement(File, { className: "w-4 h-4 text-slate-400" })), /* @__PURE__ */ React7.createElement("div", { className: "truncate" }, /* @__PURE__ */ React7.createElement("p", { className: "text-xs font-medium text-slate-700 dark:text-white/80 truncate" }, state.file.name), /* @__PURE__ */ React7.createElement("p", { className: "text-[10px] text-slate-400" }, (state.file.size / 1024).toFixed(1), " KB"))),
|
|
651
|
+
/* @__PURE__ */ React7.createElement("div", { className: "flex items-center gap-2" }, state.status === "uploading" && /* @__PURE__ */ React7.createElement(Loader2, { className: "w-4 h-4 text-slate-400 animate-spin" }), state.status === "success" && /* @__PURE__ */ React7.createElement(CheckCircle, { className: "w-4 h-4 text-emerald-500" }), state.status === "error" && /* @__PURE__ */ React7.createElement("div", { title: state.error }, /* @__PURE__ */ React7.createElement(AlertCircle, { className: "w-4 h-4 text-rose-500" })), state.status !== "uploading" && /* @__PURE__ */ React7.createElement(
|
|
656
652
|
"button",
|
|
657
653
|
{
|
|
658
654
|
onClick: () => removeFile(i),
|
|
659
655
|
className: "p-1 rounded-md hover:bg-slate-200 dark:hover:bg-white/10 transition-colors"
|
|
660
656
|
},
|
|
661
|
-
/* @__PURE__ */
|
|
657
|
+
/* @__PURE__ */ React7.createElement(X3, { className: "w-3.5 h-3.5 text-slate-400" })
|
|
662
658
|
))
|
|
663
|
-
)), hasIdle && !isUploading && /* @__PURE__ */
|
|
659
|
+
)), hasIdle && !isUploading && /* @__PURE__ */ React7.createElement(
|
|
664
660
|
"button",
|
|
665
661
|
{
|
|
666
662
|
onClick: uploadFiles,
|