@retrivora-ai/rag-engine 0.4.3 → 0.4.4
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-BICIjSuG.d.mts → DocumentChunker-3yElxTO3.d.mts} +9 -2
- package/dist/{DocumentChunker-BICIjSuG.d.ts → DocumentChunker-3yElxTO3.d.ts} +9 -2
- package/dist/{RagConfig-CVt24lbC.d.mts → RagConfig-BgRDL9Vy.d.mts} +37 -1
- package/dist/{RagConfig-CVt24lbC.d.ts → RagConfig-BgRDL9Vy.d.ts} +37 -1
- package/dist/SimpleGraphProvider-M6T7SE7D.mjs +62 -0
- package/dist/{chunk-UUZ3F4WK.mjs → chunk-OKY5P6RA.mjs} +179 -40
- package/dist/handlers/index.d.mts +2 -2
- package/dist/handlers/index.d.ts +2 -2
- package/dist/handlers/index.js +254 -40
- package/dist/handlers/index.mjs +1 -1
- package/dist/{index-OI2--lvT.d.mts → index-7qeLTPBL.d.mts} +1 -1
- package/dist/{index-D1hoNXMT.d.ts → index-DowY4_K0.d.ts} +1 -1
- package/dist/index.d.mts +15 -5
- package/dist/index.d.ts +15 -5
- package/dist/index.js +161 -1
- package/dist/index.mjs +158 -1
- package/dist/server.d.mts +52 -12
- package/dist/server.d.ts +52 -12
- package/dist/server.js +254 -40
- package/dist/server.mjs +1 -1
- package/package.json +1 -1
- package/src/components/ConfigProvider.tsx +1 -0
- package/src/components/DocumentUpload.tsx +192 -0
- package/src/config/RagConfig.ts +27 -0
- package/src/config/constants.ts +7 -0
- package/src/config/serverConfig.ts +1 -0
- package/src/core/Pipeline.ts +71 -10
- package/src/core/ProviderRegistry.ts +40 -8
- package/src/index.ts +1 -0
- package/src/providers/graphdb/BaseGraphProvider.ts +43 -0
- package/src/providers/graphdb/SimpleGraphProvider.ts +66 -0
- package/src/rag/DocumentChunker.ts +77 -34
- package/src/rag/EntityExtractor.ts +43 -0
- package/src/types/index.ts +19 -0
package/dist/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __create = Object.create;
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
|
+
var __defProps = Object.defineProperties;
|
|
4
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
5
7
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
8
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
7
9
|
var __getProtoOf = Object.getPrototypeOf;
|
|
@@ -19,6 +21,7 @@ var __spreadValues = (a, b) => {
|
|
|
19
21
|
}
|
|
20
22
|
return a;
|
|
21
23
|
};
|
|
24
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
22
25
|
var __export = (target, all) => {
|
|
23
26
|
for (var name in all)
|
|
24
27
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -47,6 +50,7 @@ __export(index_exports, {
|
|
|
47
50
|
ChatWidget: () => ChatWidget,
|
|
48
51
|
ChatWindow: () => ChatWindow,
|
|
49
52
|
ConfigProvider: () => ConfigProvider,
|
|
53
|
+
DocumentUpload: () => DocumentUpload,
|
|
50
54
|
MessageBubble: () => MessageBubble,
|
|
51
55
|
SourceCard: () => SourceCard,
|
|
52
56
|
useConfig: () => useConfig,
|
|
@@ -196,7 +200,8 @@ var defaultConfig = {
|
|
|
196
200
|
showWidget: true,
|
|
197
201
|
poweredBy: "RAG",
|
|
198
202
|
visualStyle: "glass",
|
|
199
|
-
borderRadius: "xl"
|
|
203
|
+
borderRadius: "xl",
|
|
204
|
+
allowUpload: true
|
|
200
205
|
}
|
|
201
206
|
};
|
|
202
207
|
var ConfigContext = (0, import_react3.createContext)(defaultConfig);
|
|
@@ -610,11 +615,166 @@ function ChatWidget({ position = "bottom-right" }) {
|
|
|
610
615
|
)
|
|
611
616
|
] });
|
|
612
617
|
}
|
|
618
|
+
|
|
619
|
+
// src/components/DocumentUpload.tsx
|
|
620
|
+
var import_react7 = require("react");
|
|
621
|
+
var import_lucide_react6 = require("lucide-react");
|
|
622
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
623
|
+
function DocumentUpload({ namespace, onUploadComplete, className = "" }) {
|
|
624
|
+
const { ui } = useConfig();
|
|
625
|
+
const [fileStates, setFileStates] = (0, import_react7.useState)([]);
|
|
626
|
+
const [isDragging, setIsDragging] = (0, import_react7.useState)(false);
|
|
627
|
+
const fileInputRef = (0, import_react7.useRef)(null);
|
|
628
|
+
const addFiles = (files) => {
|
|
629
|
+
const newStates = files.map((file) => ({ file, status: "idle" }));
|
|
630
|
+
setFileStates((prev) => [...prev, ...newStates]);
|
|
631
|
+
};
|
|
632
|
+
const removeFile = (index) => {
|
|
633
|
+
setFileStates((prev) => prev.filter((_, i) => i !== index));
|
|
634
|
+
};
|
|
635
|
+
const onDragOver = (e) => {
|
|
636
|
+
e.preventDefault();
|
|
637
|
+
setIsDragging(true);
|
|
638
|
+
};
|
|
639
|
+
const onDragLeave = () => {
|
|
640
|
+
setIsDragging(false);
|
|
641
|
+
};
|
|
642
|
+
const onDrop = (e) => {
|
|
643
|
+
e.preventDefault();
|
|
644
|
+
setIsDragging(false);
|
|
645
|
+
if (e.dataTransfer.files) {
|
|
646
|
+
addFiles(Array.from(e.dataTransfer.files));
|
|
647
|
+
}
|
|
648
|
+
};
|
|
649
|
+
const onFileSelect = (e) => {
|
|
650
|
+
if (e.target.files) {
|
|
651
|
+
addFiles(Array.from(e.target.files));
|
|
652
|
+
}
|
|
653
|
+
};
|
|
654
|
+
const uploadFiles = async () => {
|
|
655
|
+
const idleFiles = fileStates.filter((s) => s.status === "idle");
|
|
656
|
+
if (idleFiles.length === 0) return;
|
|
657
|
+
setFileStates((prev) => prev.map((s) => s.status === "idle" ? __spreadProps(__spreadValues({}, s), { status: "uploading" }) : s));
|
|
658
|
+
const formData = new FormData();
|
|
659
|
+
idleFiles.forEach((s) => formData.append("files", s.file));
|
|
660
|
+
if (namespace) formData.append("namespace", namespace);
|
|
661
|
+
try {
|
|
662
|
+
const response = await fetch("/api/upload", {
|
|
663
|
+
method: "POST",
|
|
664
|
+
body: formData
|
|
665
|
+
});
|
|
666
|
+
const result = await response.json();
|
|
667
|
+
if (!response.ok) throw new Error(result.error || "Upload failed");
|
|
668
|
+
setFileStates((prev) => prev.map((s) => s.status === "uploading" ? __spreadProps(__spreadValues({}, s), { status: "success" }) : s));
|
|
669
|
+
if (onUploadComplete) onUploadComplete(result);
|
|
670
|
+
} catch (err) {
|
|
671
|
+
const message = err instanceof Error ? err.message : "Upload failed";
|
|
672
|
+
setFileStates((prev) => prev.map((s) => s.status === "uploading" ? __spreadProps(__spreadValues({}, s), { status: "error", error: message }) : s));
|
|
673
|
+
}
|
|
674
|
+
};
|
|
675
|
+
const isUploading = fileStates.some((s) => s.status === "uploading");
|
|
676
|
+
const hasIdle = fileStates.some((s) => s.status === "idle");
|
|
677
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
678
|
+
"div",
|
|
679
|
+
{
|
|
680
|
+
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}`,
|
|
681
|
+
onDragOver,
|
|
682
|
+
onDragLeave,
|
|
683
|
+
onDrop,
|
|
684
|
+
children: [
|
|
685
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "flex flex-col items-center justify-center text-center", children: [
|
|
686
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
687
|
+
"div",
|
|
688
|
+
{
|
|
689
|
+
className: "w-12 h-12 rounded-full flex items-center justify-center mb-4 shadow-sm",
|
|
690
|
+
style: { background: `linear-gradient(135deg, ${ui.primaryColor}20, ${ui.accentColor}20)` },
|
|
691
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_lucide_react6.Upload, { className: "w-6 h-6", style: { color: ui.primaryColor } })
|
|
692
|
+
}
|
|
693
|
+
),
|
|
694
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("h3", { className: "text-slate-900 dark:text-white font-semibold mb-1", children: "Upload Documents" }),
|
|
695
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { className: "text-slate-500 dark:text-white/40 text-sm mb-6 max-w-xs", children: "Drag and drop PDF, DOCX, TXT, or JSON files to train your AI on your own data." }),
|
|
696
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
697
|
+
"button",
|
|
698
|
+
{
|
|
699
|
+
onClick: () => {
|
|
700
|
+
var _a;
|
|
701
|
+
return (_a = fileInputRef.current) == null ? void 0 : _a.click();
|
|
702
|
+
},
|
|
703
|
+
disabled: isUploading,
|
|
704
|
+
className: "px-4 py-2 rounded-lg text-sm font-medium transition-all hover:scale-105 active:scale-95 disabled:opacity-50",
|
|
705
|
+
style: {
|
|
706
|
+
backgroundColor: `${ui.primaryColor}15`,
|
|
707
|
+
color: ui.primaryColor,
|
|
708
|
+
border: `1px solid ${ui.primaryColor}30`
|
|
709
|
+
},
|
|
710
|
+
children: "Select Files"
|
|
711
|
+
}
|
|
712
|
+
),
|
|
713
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
714
|
+
"input",
|
|
715
|
+
{
|
|
716
|
+
ref: fileInputRef,
|
|
717
|
+
type: "file",
|
|
718
|
+
multiple: true,
|
|
719
|
+
onChange: onFileSelect,
|
|
720
|
+
className: "hidden",
|
|
721
|
+
accept: ".pdf,.docx,.txt,.md,.json,.csv"
|
|
722
|
+
}
|
|
723
|
+
)
|
|
724
|
+
] }),
|
|
725
|
+
fileStates.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "mt-8 space-y-3", children: [
|
|
726
|
+
fileStates.map((state, i) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
727
|
+
"div",
|
|
728
|
+
{
|
|
729
|
+
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",
|
|
730
|
+
children: [
|
|
731
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "flex items-center gap-3 overflow-hidden", children: [
|
|
732
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "w-8 h-8 rounded-lg bg-white dark:bg-white/10 flex items-center justify-center shadow-sm", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_lucide_react6.File, { className: "w-4 h-4 text-slate-400" }) }),
|
|
733
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "truncate", children: [
|
|
734
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { className: "text-xs font-medium text-slate-700 dark:text-white/80 truncate", children: state.file.name }),
|
|
735
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("p", { className: "text-[10px] text-slate-400", children: [
|
|
736
|
+
(state.file.size / 1024).toFixed(1),
|
|
737
|
+
" KB"
|
|
738
|
+
] })
|
|
739
|
+
] })
|
|
740
|
+
] }),
|
|
741
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
742
|
+
state.status === "uploading" && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_lucide_react6.Loader2, { className: "w-4 h-4 text-slate-400 animate-spin" }),
|
|
743
|
+
state.status === "success" && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_lucide_react6.CheckCircle, { className: "w-4 h-4 text-emerald-500" }),
|
|
744
|
+
state.status === "error" && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { title: state.error, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_lucide_react6.AlertCircle, { className: "w-4 h-4 text-rose-500" }) }),
|
|
745
|
+
state.status !== "uploading" && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
746
|
+
"button",
|
|
747
|
+
{
|
|
748
|
+
onClick: () => removeFile(i),
|
|
749
|
+
className: "p-1 rounded-md hover:bg-slate-200 dark:hover:bg-white/10 transition-colors",
|
|
750
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_lucide_react6.X, { className: "w-3.5 h-3.5 text-slate-400" })
|
|
751
|
+
}
|
|
752
|
+
)
|
|
753
|
+
] })
|
|
754
|
+
]
|
|
755
|
+
},
|
|
756
|
+
i
|
|
757
|
+
)),
|
|
758
|
+
hasIdle && !isUploading && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
759
|
+
"button",
|
|
760
|
+
{
|
|
761
|
+
onClick: uploadFiles,
|
|
762
|
+
className: "w-full mt-4 py-2.5 rounded-xl text-sm font-semibold text-white shadow-lg transition-all hover:scale-[1.02] active:scale-[0.98]",
|
|
763
|
+
style: { background: `linear-gradient(135deg, ${ui.primaryColor}, ${ui.accentColor})` },
|
|
764
|
+
children: "Start Upload"
|
|
765
|
+
}
|
|
766
|
+
)
|
|
767
|
+
] })
|
|
768
|
+
]
|
|
769
|
+
}
|
|
770
|
+
);
|
|
771
|
+
}
|
|
613
772
|
// Annotate the CommonJS export names for ESM import in node:
|
|
614
773
|
0 && (module.exports = {
|
|
615
774
|
ChatWidget,
|
|
616
775
|
ChatWindow,
|
|
617
776
|
ConfigProvider,
|
|
777
|
+
DocumentUpload,
|
|
618
778
|
MessageBubble,
|
|
619
779
|
SourceCard,
|
|
620
780
|
useConfig,
|
package/dist/index.mjs
CHANGED
|
@@ -2,6 +2,7 @@ import {
|
|
|
2
2
|
mergeDefined
|
|
3
3
|
} from "./chunk-EDLTMSNY.mjs";
|
|
4
4
|
import {
|
|
5
|
+
__spreadProps,
|
|
5
6
|
__spreadValues
|
|
6
7
|
} from "./chunk-FWCSY2DS.mjs";
|
|
7
8
|
|
|
@@ -138,7 +139,8 @@ var defaultConfig = {
|
|
|
138
139
|
showWidget: true,
|
|
139
140
|
poweredBy: "RAG",
|
|
140
141
|
visualStyle: "glass",
|
|
141
|
-
borderRadius: "xl"
|
|
142
|
+
borderRadius: "xl",
|
|
143
|
+
allowUpload: true
|
|
142
144
|
}
|
|
143
145
|
};
|
|
144
146
|
var ConfigContext = createContext(defaultConfig);
|
|
@@ -570,10 +572,165 @@ function ChatWidget({ position = "bottom-right" }) {
|
|
|
570
572
|
)
|
|
571
573
|
] });
|
|
572
574
|
}
|
|
575
|
+
|
|
576
|
+
// src/components/DocumentUpload.tsx
|
|
577
|
+
import { useState as useState5, useRef as useRef3 } from "react";
|
|
578
|
+
import { Upload, File, X as X3, CheckCircle, AlertCircle, Loader2 } from "lucide-react";
|
|
579
|
+
import { jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
580
|
+
function DocumentUpload({ namespace, onUploadComplete, className = "" }) {
|
|
581
|
+
const { ui } = useConfig();
|
|
582
|
+
const [fileStates, setFileStates] = useState5([]);
|
|
583
|
+
const [isDragging, setIsDragging] = useState5(false);
|
|
584
|
+
const fileInputRef = useRef3(null);
|
|
585
|
+
const addFiles = (files) => {
|
|
586
|
+
const newStates = files.map((file) => ({ file, status: "idle" }));
|
|
587
|
+
setFileStates((prev) => [...prev, ...newStates]);
|
|
588
|
+
};
|
|
589
|
+
const removeFile = (index) => {
|
|
590
|
+
setFileStates((prev) => prev.filter((_, i) => i !== index));
|
|
591
|
+
};
|
|
592
|
+
const onDragOver = (e) => {
|
|
593
|
+
e.preventDefault();
|
|
594
|
+
setIsDragging(true);
|
|
595
|
+
};
|
|
596
|
+
const onDragLeave = () => {
|
|
597
|
+
setIsDragging(false);
|
|
598
|
+
};
|
|
599
|
+
const onDrop = (e) => {
|
|
600
|
+
e.preventDefault();
|
|
601
|
+
setIsDragging(false);
|
|
602
|
+
if (e.dataTransfer.files) {
|
|
603
|
+
addFiles(Array.from(e.dataTransfer.files));
|
|
604
|
+
}
|
|
605
|
+
};
|
|
606
|
+
const onFileSelect = (e) => {
|
|
607
|
+
if (e.target.files) {
|
|
608
|
+
addFiles(Array.from(e.target.files));
|
|
609
|
+
}
|
|
610
|
+
};
|
|
611
|
+
const uploadFiles = async () => {
|
|
612
|
+
const idleFiles = fileStates.filter((s) => s.status === "idle");
|
|
613
|
+
if (idleFiles.length === 0) return;
|
|
614
|
+
setFileStates((prev) => prev.map((s) => s.status === "idle" ? __spreadProps(__spreadValues({}, s), { status: "uploading" }) : s));
|
|
615
|
+
const formData = new FormData();
|
|
616
|
+
idleFiles.forEach((s) => formData.append("files", s.file));
|
|
617
|
+
if (namespace) formData.append("namespace", namespace);
|
|
618
|
+
try {
|
|
619
|
+
const response = await fetch("/api/upload", {
|
|
620
|
+
method: "POST",
|
|
621
|
+
body: formData
|
|
622
|
+
});
|
|
623
|
+
const result = await response.json();
|
|
624
|
+
if (!response.ok) throw new Error(result.error || "Upload failed");
|
|
625
|
+
setFileStates((prev) => prev.map((s) => s.status === "uploading" ? __spreadProps(__spreadValues({}, s), { status: "success" }) : s));
|
|
626
|
+
if (onUploadComplete) onUploadComplete(result);
|
|
627
|
+
} catch (err) {
|
|
628
|
+
const message = err instanceof Error ? err.message : "Upload failed";
|
|
629
|
+
setFileStates((prev) => prev.map((s) => s.status === "uploading" ? __spreadProps(__spreadValues({}, s), { status: "error", error: message }) : s));
|
|
630
|
+
}
|
|
631
|
+
};
|
|
632
|
+
const isUploading = fileStates.some((s) => s.status === "uploading");
|
|
633
|
+
const hasIdle = fileStates.some((s) => s.status === "idle");
|
|
634
|
+
return /* @__PURE__ */ jsxs5(
|
|
635
|
+
"div",
|
|
636
|
+
{
|
|
637
|
+
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}`,
|
|
638
|
+
onDragOver,
|
|
639
|
+
onDragLeave,
|
|
640
|
+
onDrop,
|
|
641
|
+
children: [
|
|
642
|
+
/* @__PURE__ */ jsxs5("div", { className: "flex flex-col items-center justify-center text-center", children: [
|
|
643
|
+
/* @__PURE__ */ jsx7(
|
|
644
|
+
"div",
|
|
645
|
+
{
|
|
646
|
+
className: "w-12 h-12 rounded-full flex items-center justify-center mb-4 shadow-sm",
|
|
647
|
+
style: { background: `linear-gradient(135deg, ${ui.primaryColor}20, ${ui.accentColor}20)` },
|
|
648
|
+
children: /* @__PURE__ */ jsx7(Upload, { className: "w-6 h-6", style: { color: ui.primaryColor } })
|
|
649
|
+
}
|
|
650
|
+
),
|
|
651
|
+
/* @__PURE__ */ jsx7("h3", { className: "text-slate-900 dark:text-white font-semibold mb-1", children: "Upload Documents" }),
|
|
652
|
+
/* @__PURE__ */ jsx7("p", { className: "text-slate-500 dark:text-white/40 text-sm mb-6 max-w-xs", children: "Drag and drop PDF, DOCX, TXT, or JSON files to train your AI on your own data." }),
|
|
653
|
+
/* @__PURE__ */ jsx7(
|
|
654
|
+
"button",
|
|
655
|
+
{
|
|
656
|
+
onClick: () => {
|
|
657
|
+
var _a;
|
|
658
|
+
return (_a = fileInputRef.current) == null ? void 0 : _a.click();
|
|
659
|
+
},
|
|
660
|
+
disabled: isUploading,
|
|
661
|
+
className: "px-4 py-2 rounded-lg text-sm font-medium transition-all hover:scale-105 active:scale-95 disabled:opacity-50",
|
|
662
|
+
style: {
|
|
663
|
+
backgroundColor: `${ui.primaryColor}15`,
|
|
664
|
+
color: ui.primaryColor,
|
|
665
|
+
border: `1px solid ${ui.primaryColor}30`
|
|
666
|
+
},
|
|
667
|
+
children: "Select Files"
|
|
668
|
+
}
|
|
669
|
+
),
|
|
670
|
+
/* @__PURE__ */ jsx7(
|
|
671
|
+
"input",
|
|
672
|
+
{
|
|
673
|
+
ref: fileInputRef,
|
|
674
|
+
type: "file",
|
|
675
|
+
multiple: true,
|
|
676
|
+
onChange: onFileSelect,
|
|
677
|
+
className: "hidden",
|
|
678
|
+
accept: ".pdf,.docx,.txt,.md,.json,.csv"
|
|
679
|
+
}
|
|
680
|
+
)
|
|
681
|
+
] }),
|
|
682
|
+
fileStates.length > 0 && /* @__PURE__ */ jsxs5("div", { className: "mt-8 space-y-3", children: [
|
|
683
|
+
fileStates.map((state, i) => /* @__PURE__ */ jsxs5(
|
|
684
|
+
"div",
|
|
685
|
+
{
|
|
686
|
+
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",
|
|
687
|
+
children: [
|
|
688
|
+
/* @__PURE__ */ jsxs5("div", { className: "flex items-center gap-3 overflow-hidden", children: [
|
|
689
|
+
/* @__PURE__ */ jsx7("div", { className: "w-8 h-8 rounded-lg bg-white dark:bg-white/10 flex items-center justify-center shadow-sm", children: /* @__PURE__ */ jsx7(File, { className: "w-4 h-4 text-slate-400" }) }),
|
|
690
|
+
/* @__PURE__ */ jsxs5("div", { className: "truncate", children: [
|
|
691
|
+
/* @__PURE__ */ jsx7("p", { className: "text-xs font-medium text-slate-700 dark:text-white/80 truncate", children: state.file.name }),
|
|
692
|
+
/* @__PURE__ */ jsxs5("p", { className: "text-[10px] text-slate-400", children: [
|
|
693
|
+
(state.file.size / 1024).toFixed(1),
|
|
694
|
+
" KB"
|
|
695
|
+
] })
|
|
696
|
+
] })
|
|
697
|
+
] }),
|
|
698
|
+
/* @__PURE__ */ jsxs5("div", { className: "flex items-center gap-2", children: [
|
|
699
|
+
state.status === "uploading" && /* @__PURE__ */ jsx7(Loader2, { className: "w-4 h-4 text-slate-400 animate-spin" }),
|
|
700
|
+
state.status === "success" && /* @__PURE__ */ jsx7(CheckCircle, { className: "w-4 h-4 text-emerald-500" }),
|
|
701
|
+
state.status === "error" && /* @__PURE__ */ jsx7("div", { title: state.error, children: /* @__PURE__ */ jsx7(AlertCircle, { className: "w-4 h-4 text-rose-500" }) }),
|
|
702
|
+
state.status !== "uploading" && /* @__PURE__ */ jsx7(
|
|
703
|
+
"button",
|
|
704
|
+
{
|
|
705
|
+
onClick: () => removeFile(i),
|
|
706
|
+
className: "p-1 rounded-md hover:bg-slate-200 dark:hover:bg-white/10 transition-colors",
|
|
707
|
+
children: /* @__PURE__ */ jsx7(X3, { className: "w-3.5 h-3.5 text-slate-400" })
|
|
708
|
+
}
|
|
709
|
+
)
|
|
710
|
+
] })
|
|
711
|
+
]
|
|
712
|
+
},
|
|
713
|
+
i
|
|
714
|
+
)),
|
|
715
|
+
hasIdle && !isUploading && /* @__PURE__ */ jsx7(
|
|
716
|
+
"button",
|
|
717
|
+
{
|
|
718
|
+
onClick: uploadFiles,
|
|
719
|
+
className: "w-full mt-4 py-2.5 rounded-xl text-sm font-semibold text-white shadow-lg transition-all hover:scale-[1.02] active:scale-[0.98]",
|
|
720
|
+
style: { background: `linear-gradient(135deg, ${ui.primaryColor}, ${ui.accentColor})` },
|
|
721
|
+
children: "Start Upload"
|
|
722
|
+
}
|
|
723
|
+
)
|
|
724
|
+
] })
|
|
725
|
+
]
|
|
726
|
+
}
|
|
727
|
+
);
|
|
728
|
+
}
|
|
573
729
|
export {
|
|
574
730
|
ChatWidget,
|
|
575
731
|
ChatWindow,
|
|
576
732
|
ConfigProvider,
|
|
733
|
+
DocumentUpload,
|
|
577
734
|
MessageBubble,
|
|
578
735
|
SourceCard,
|
|
579
736
|
useConfig,
|
package/dist/server.d.mts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { c as RagConfig, C as ChatResponse, I as IngestDocument, e as VectorDBConfig, d as UpsertDocument, V as VectorMatch, L as LLMConfig, E as EmbeddingConfig, f as VectorDBProvider, b as LLMProvider, a as EmbeddingProvider } from './RagConfig-
|
|
2
|
-
export { R as RAGConfig, U as UIConfig } from './RagConfig-
|
|
3
|
-
import { C as ChatMessage, I as ILLMProvider, a as ChatOptions, E as EmbedOptions } from './DocumentChunker-
|
|
4
|
-
export { b as Chunk, c as ChunkOptions, D as DocumentChunker } from './DocumentChunker-
|
|
5
|
-
import { H as HealthCheckResult } from './index-
|
|
6
|
-
export { P as ProviderHealthCheck, c as createChatHandler, a as createHealthHandler, b as createIngestHandler, d as createUploadHandler } from './index-
|
|
1
|
+
import { c as RagConfig, C as ChatResponse, I as IngestDocument, e as VectorDBConfig, d as UpsertDocument, V as VectorMatch, G as GraphDBConfig, g as GraphNode, h as Edge, i as GraphSearchResult, L as LLMConfig, E as EmbeddingConfig, f as VectorDBProvider, b as LLMProvider, a as EmbeddingProvider } from './RagConfig-BgRDL9Vy.mjs';
|
|
2
|
+
export { R as RAGConfig, U as UIConfig } from './RagConfig-BgRDL9Vy.mjs';
|
|
3
|
+
import { C as ChatMessage, I as ILLMProvider, a as ChatOptions, E as EmbedOptions } from './DocumentChunker-3yElxTO3.mjs';
|
|
4
|
+
export { b as Chunk, c as ChunkOptions, D as DocumentChunker } from './DocumentChunker-3yElxTO3.mjs';
|
|
5
|
+
import { H as HealthCheckResult } from './index-7qeLTPBL.mjs';
|
|
6
|
+
export { P as ProviderHealthCheck, c as createChatHandler, a as createHealthHandler, b as createIngestHandler, d as createUploadHandler } from './index-7qeLTPBL.mjs';
|
|
7
7
|
import 'next/server';
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -233,9 +233,11 @@ declare class VectorPlugin {
|
|
|
233
233
|
*/
|
|
234
234
|
declare class Pipeline {
|
|
235
235
|
private vectorDB;
|
|
236
|
+
private graphDB?;
|
|
236
237
|
private llmProvider;
|
|
237
238
|
private embeddingProvider;
|
|
238
239
|
private chunker;
|
|
240
|
+
private entityExtractor?;
|
|
239
241
|
private config;
|
|
240
242
|
private initialised;
|
|
241
243
|
constructor(config: RagConfig);
|
|
@@ -249,6 +251,10 @@ declare class Pipeline {
|
|
|
249
251
|
chunksIngested: number;
|
|
250
252
|
}>>;
|
|
251
253
|
ask(question: string, history?: ChatMessage[], namespace?: string): Promise<ChatResponse>;
|
|
254
|
+
/**
|
|
255
|
+
* Rewrite the user query for better retrieval performance.
|
|
256
|
+
*/
|
|
257
|
+
private rewriteQuery;
|
|
252
258
|
}
|
|
253
259
|
|
|
254
260
|
/**
|
|
@@ -314,6 +320,38 @@ declare abstract class BaseVectorProvider {
|
|
|
314
320
|
protected sanitizeFilter(filter?: Record<string, unknown>): Record<string, unknown>;
|
|
315
321
|
}
|
|
316
322
|
|
|
323
|
+
/**
|
|
324
|
+
* BaseGraphProvider — Abstract base class for Graph DB providers.
|
|
325
|
+
*/
|
|
326
|
+
declare abstract class BaseGraphProvider {
|
|
327
|
+
protected config: GraphDBConfig;
|
|
328
|
+
constructor(config: GraphDBConfig);
|
|
329
|
+
/**
|
|
330
|
+
* Initialise connection to the graph database.
|
|
331
|
+
*/
|
|
332
|
+
abstract initialize(): Promise<void>;
|
|
333
|
+
/**
|
|
334
|
+
* Add nodes to the graph.
|
|
335
|
+
*/
|
|
336
|
+
abstract addNodes(nodes: GraphNode[]): Promise<void>;
|
|
337
|
+
/**
|
|
338
|
+
* Add edges (relationships) to the graph.
|
|
339
|
+
*/
|
|
340
|
+
abstract addEdges(edges: Edge[]): Promise<void>;
|
|
341
|
+
/**
|
|
342
|
+
* Query the graph for relevant nodes and edges.
|
|
343
|
+
*/
|
|
344
|
+
abstract query(queryText: string, limit?: number): Promise<GraphSearchResult>;
|
|
345
|
+
/**
|
|
346
|
+
* Check if the database is reachable.
|
|
347
|
+
*/
|
|
348
|
+
abstract ping(): Promise<boolean>;
|
|
349
|
+
/**
|
|
350
|
+
* Close connection.
|
|
351
|
+
*/
|
|
352
|
+
abstract disconnect(): Promise<void>;
|
|
353
|
+
}
|
|
354
|
+
|
|
317
355
|
/**
|
|
318
356
|
* ProviderRegistry — dynamic provider loader for Vector DBs and LLMs.
|
|
319
357
|
*
|
|
@@ -323,19 +361,21 @@ declare abstract class BaseVectorProvider {
|
|
|
323
361
|
*/
|
|
324
362
|
declare class ProviderRegistry {
|
|
325
363
|
private static vectorProviders;
|
|
364
|
+
private static graphProviders;
|
|
365
|
+
static registerVectorProvider(name: string, providerClass: new (config: VectorDBConfig) => BaseVectorProvider): void;
|
|
326
366
|
/**
|
|
327
|
-
* Register a custom
|
|
328
|
-
* The name must match the provider value used in VectorDBConfig.provider.
|
|
329
|
-
*
|
|
330
|
-
* @example
|
|
331
|
-
* ProviderRegistry.registerVectorProvider('my-db', MyCustomProvider);
|
|
367
|
+
* Register a custom graph provider class by name.
|
|
332
368
|
*/
|
|
333
|
-
static
|
|
369
|
+
static registerGraphProvider(name: string, providerClass: new (config: GraphDBConfig) => BaseGraphProvider): void;
|
|
334
370
|
/**
|
|
335
371
|
* Creates a vector database provider based on the configuration.
|
|
336
372
|
* Built-in providers are dynamically imported to avoid bundling all SDKs.
|
|
337
373
|
*/
|
|
338
374
|
static createVectorProvider(config: VectorDBConfig): Promise<BaseVectorProvider>;
|
|
375
|
+
/**
|
|
376
|
+
* Creates a graph database provider based on the configuration.
|
|
377
|
+
*/
|
|
378
|
+
static createGraphProvider(config: GraphDBConfig): Promise<BaseGraphProvider>;
|
|
339
379
|
/**
|
|
340
380
|
* Creates an LLM provider based on the configuration.
|
|
341
381
|
*/
|
package/dist/server.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { c as RagConfig, C as ChatResponse, I as IngestDocument, e as VectorDBConfig, d as UpsertDocument, V as VectorMatch, L as LLMConfig, E as EmbeddingConfig, f as VectorDBProvider, b as LLMProvider, a as EmbeddingProvider } from './RagConfig-
|
|
2
|
-
export { R as RAGConfig, U as UIConfig } from './RagConfig-
|
|
3
|
-
import { C as ChatMessage, I as ILLMProvider, a as ChatOptions, E as EmbedOptions } from './DocumentChunker-
|
|
4
|
-
export { b as Chunk, c as ChunkOptions, D as DocumentChunker } from './DocumentChunker-
|
|
5
|
-
import { H as HealthCheckResult } from './index-
|
|
6
|
-
export { P as ProviderHealthCheck, c as createChatHandler, a as createHealthHandler, b as createIngestHandler, d as createUploadHandler } from './index-
|
|
1
|
+
import { c as RagConfig, C as ChatResponse, I as IngestDocument, e as VectorDBConfig, d as UpsertDocument, V as VectorMatch, G as GraphDBConfig, g as GraphNode, h as Edge, i as GraphSearchResult, L as LLMConfig, E as EmbeddingConfig, f as VectorDBProvider, b as LLMProvider, a as EmbeddingProvider } from './RagConfig-BgRDL9Vy.js';
|
|
2
|
+
export { R as RAGConfig, U as UIConfig } from './RagConfig-BgRDL9Vy.js';
|
|
3
|
+
import { C as ChatMessage, I as ILLMProvider, a as ChatOptions, E as EmbedOptions } from './DocumentChunker-3yElxTO3.js';
|
|
4
|
+
export { b as Chunk, c as ChunkOptions, D as DocumentChunker } from './DocumentChunker-3yElxTO3.js';
|
|
5
|
+
import { H as HealthCheckResult } from './index-DowY4_K0.js';
|
|
6
|
+
export { P as ProviderHealthCheck, c as createChatHandler, a as createHealthHandler, b as createIngestHandler, d as createUploadHandler } from './index-DowY4_K0.js';
|
|
7
7
|
import 'next/server';
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -233,9 +233,11 @@ declare class VectorPlugin {
|
|
|
233
233
|
*/
|
|
234
234
|
declare class Pipeline {
|
|
235
235
|
private vectorDB;
|
|
236
|
+
private graphDB?;
|
|
236
237
|
private llmProvider;
|
|
237
238
|
private embeddingProvider;
|
|
238
239
|
private chunker;
|
|
240
|
+
private entityExtractor?;
|
|
239
241
|
private config;
|
|
240
242
|
private initialised;
|
|
241
243
|
constructor(config: RagConfig);
|
|
@@ -249,6 +251,10 @@ declare class Pipeline {
|
|
|
249
251
|
chunksIngested: number;
|
|
250
252
|
}>>;
|
|
251
253
|
ask(question: string, history?: ChatMessage[], namespace?: string): Promise<ChatResponse>;
|
|
254
|
+
/**
|
|
255
|
+
* Rewrite the user query for better retrieval performance.
|
|
256
|
+
*/
|
|
257
|
+
private rewriteQuery;
|
|
252
258
|
}
|
|
253
259
|
|
|
254
260
|
/**
|
|
@@ -314,6 +320,38 @@ declare abstract class BaseVectorProvider {
|
|
|
314
320
|
protected sanitizeFilter(filter?: Record<string, unknown>): Record<string, unknown>;
|
|
315
321
|
}
|
|
316
322
|
|
|
323
|
+
/**
|
|
324
|
+
* BaseGraphProvider — Abstract base class for Graph DB providers.
|
|
325
|
+
*/
|
|
326
|
+
declare abstract class BaseGraphProvider {
|
|
327
|
+
protected config: GraphDBConfig;
|
|
328
|
+
constructor(config: GraphDBConfig);
|
|
329
|
+
/**
|
|
330
|
+
* Initialise connection to the graph database.
|
|
331
|
+
*/
|
|
332
|
+
abstract initialize(): Promise<void>;
|
|
333
|
+
/**
|
|
334
|
+
* Add nodes to the graph.
|
|
335
|
+
*/
|
|
336
|
+
abstract addNodes(nodes: GraphNode[]): Promise<void>;
|
|
337
|
+
/**
|
|
338
|
+
* Add edges (relationships) to the graph.
|
|
339
|
+
*/
|
|
340
|
+
abstract addEdges(edges: Edge[]): Promise<void>;
|
|
341
|
+
/**
|
|
342
|
+
* Query the graph for relevant nodes and edges.
|
|
343
|
+
*/
|
|
344
|
+
abstract query(queryText: string, limit?: number): Promise<GraphSearchResult>;
|
|
345
|
+
/**
|
|
346
|
+
* Check if the database is reachable.
|
|
347
|
+
*/
|
|
348
|
+
abstract ping(): Promise<boolean>;
|
|
349
|
+
/**
|
|
350
|
+
* Close connection.
|
|
351
|
+
*/
|
|
352
|
+
abstract disconnect(): Promise<void>;
|
|
353
|
+
}
|
|
354
|
+
|
|
317
355
|
/**
|
|
318
356
|
* ProviderRegistry — dynamic provider loader for Vector DBs and LLMs.
|
|
319
357
|
*
|
|
@@ -323,19 +361,21 @@ declare abstract class BaseVectorProvider {
|
|
|
323
361
|
*/
|
|
324
362
|
declare class ProviderRegistry {
|
|
325
363
|
private static vectorProviders;
|
|
364
|
+
private static graphProviders;
|
|
365
|
+
static registerVectorProvider(name: string, providerClass: new (config: VectorDBConfig) => BaseVectorProvider): void;
|
|
326
366
|
/**
|
|
327
|
-
* Register a custom
|
|
328
|
-
* The name must match the provider value used in VectorDBConfig.provider.
|
|
329
|
-
*
|
|
330
|
-
* @example
|
|
331
|
-
* ProviderRegistry.registerVectorProvider('my-db', MyCustomProvider);
|
|
367
|
+
* Register a custom graph provider class by name.
|
|
332
368
|
*/
|
|
333
|
-
static
|
|
369
|
+
static registerGraphProvider(name: string, providerClass: new (config: GraphDBConfig) => BaseGraphProvider): void;
|
|
334
370
|
/**
|
|
335
371
|
* Creates a vector database provider based on the configuration.
|
|
336
372
|
* Built-in providers are dynamically imported to avoid bundling all SDKs.
|
|
337
373
|
*/
|
|
338
374
|
static createVectorProvider(config: VectorDBConfig): Promise<BaseVectorProvider>;
|
|
375
|
+
/**
|
|
376
|
+
* Creates a graph database provider based on the configuration.
|
|
377
|
+
*/
|
|
378
|
+
static createGraphProvider(config: GraphDBConfig): Promise<BaseGraphProvider>;
|
|
339
379
|
/**
|
|
340
380
|
* Creates an LLM provider based on the configuration.
|
|
341
381
|
*/
|