@retrivora-ai/rag-engine 0.1.8 → 0.1.10
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/{ChromaDBProvider-2JZSBOQX.mjs → ChromaDBProvider-T7TK3ONZ.mjs} +2 -2
- package/dist/{MilvusProvider-CJDBCBVI.mjs → MilvusProvider-Y5FV5EAE.mjs} +2 -2
- package/dist/{MongoDBProvider-WWVJG3WT.mjs → MongoDBProvider-QHMGD2LZ.mjs} +2 -2
- package/dist/{PineconeProvider-E6L5Z2FO.mjs → PineconeProvider-A47MRRYJ.mjs} +2 -2
- package/dist/{PostgreSQLProvider-ZNXA67IM.mjs → PostgreSQLProvider-PJ5ER5Z4.mjs} +1 -1
- package/dist/{QdrantProvider-JITRNJQN.mjs → QdrantProvider-OLPJK7CY.mjs} +2 -2
- package/dist/{RedisProvider-3VKFQXXD.mjs → RedisProvider-ANEJ3BHR.mjs} +2 -2
- package/dist/{UniversalVectorProvider-E6L4U4OX.mjs → UniversalVectorProvider-QJIV2AJJ.mjs} +3 -3
- package/dist/{WeaviateProvider-MXIPP44J.mjs → WeaviateProvider-WIK2QN23.mjs} +2 -2
- package/dist/{chunk-YIYDJQJM.mjs → chunk-2VR5ZMXV.mjs} +11 -11
- package/dist/{chunk-QEYVWVT5.mjs → chunk-5HXNKSCR.mjs} +1 -1
- package/dist/{chunk-MFWJZVF3.mjs → chunk-BMHJTWSU.mjs} +1 -1
- package/dist/{chunk-UKDXCXW7.mjs → chunk-EDLTMSNY.mjs} +1 -1
- package/dist/{chunk-I4E63NIC.mjs → chunk-FWCSY2DS.mjs} +14 -1
- package/dist/{chunk-7BQI4A5J.mjs → chunk-HOMXEE3M.mjs} +1 -1
- package/dist/{chunk-TSX6DQXX.mjs → chunk-RUKZC3ON.mjs} +1 -1
- package/dist/{chunk-YST6KYBJ.mjs → chunk-VEJNRS4B.mjs} +1 -1
- package/dist/{chunk-XZPVJS2B.mjs → chunk-VKE5ZW7Y.mjs} +1 -1
- package/dist/{chunk-Y6HQZDCJ.mjs → chunk-VV2ML6TM.mjs} +2 -2
- package/dist/{chunk-26EMHLIN.mjs → chunk-W2PQR3UK.mjs} +1 -1
- package/dist/handlers/index.mjs +3 -3
- package/dist/index.js +67 -58
- package/dist/index.mjs +74 -47
- package/dist/server.d.mts +36 -1
- package/dist/server.d.ts +36 -1
- package/dist/server.js +127 -0
- package/dist/server.mjs +124 -11
- package/package.json +1 -1
- package/src/app/constants.tsx +220 -0
- package/src/app/page.tsx +193 -363
- package/src/app/types.ts +30 -0
- package/src/components/ChatWindow.tsx +3 -11
- package/src/providers/vectordb/MultiTablePostgresProvider.ts +164 -0
- package/src/server.ts +1 -0
package/dist/index.mjs
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import {
|
|
2
2
|
mergeDefined
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-EDLTMSNY.mjs";
|
|
4
4
|
import {
|
|
5
5
|
__spreadValues
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-FWCSY2DS.mjs";
|
|
7
7
|
|
|
8
8
|
// src/components/ChatWidget.tsx
|
|
9
9
|
import { useState as useState4 } from "react";
|
|
10
|
-
import { MessageSquare, X as X2 } from "lucide-react";
|
|
10
|
+
import { MessageSquare as MessageSquare2, X as X2 } from "lucide-react";
|
|
11
11
|
|
|
12
12
|
// src/components/ChatWindow.tsx
|
|
13
13
|
import { useState as useState3, useRef as useRef2, useEffect as useEffect3, useCallback as useCallback2 } from "react";
|
|
14
14
|
import {
|
|
15
|
-
Bot as
|
|
15
|
+
Bot as Bot3,
|
|
16
16
|
Trash2,
|
|
17
17
|
X,
|
|
18
|
-
Sparkles,
|
|
18
|
+
Sparkles as Sparkles2,
|
|
19
19
|
ArrowUp,
|
|
20
20
|
TriangleAlert
|
|
21
21
|
} from "lucide-react";
|
|
@@ -277,8 +277,43 @@ function useRagChat(projectId, options = {}) {
|
|
|
277
277
|
};
|
|
278
278
|
}
|
|
279
279
|
|
|
280
|
+
// src/app/constants.tsx
|
|
281
|
+
import {
|
|
282
|
+
Zap,
|
|
283
|
+
Database,
|
|
284
|
+
Layers,
|
|
285
|
+
Search,
|
|
286
|
+
Box,
|
|
287
|
+
Package,
|
|
288
|
+
Activity,
|
|
289
|
+
Hexagon,
|
|
290
|
+
Sparkles,
|
|
291
|
+
Bot as Bot2,
|
|
292
|
+
Brain,
|
|
293
|
+
Rabbit,
|
|
294
|
+
Code,
|
|
295
|
+
Terminal,
|
|
296
|
+
FileText,
|
|
297
|
+
Puzzle,
|
|
298
|
+
MessageSquare
|
|
299
|
+
} from "lucide-react";
|
|
300
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
301
|
+
var CHAT_SUGGESTIONS = [
|
|
302
|
+
"What can you help me with?",
|
|
303
|
+
"Summarise the key topics",
|
|
304
|
+
"Show me an example"
|
|
305
|
+
];
|
|
306
|
+
var BORDER_RADIUS_MAP = {
|
|
307
|
+
none: "rounded-none",
|
|
308
|
+
sm: "rounded-sm",
|
|
309
|
+
md: "rounded-md",
|
|
310
|
+
lg: "rounded-lg",
|
|
311
|
+
xl: "rounded-xl",
|
|
312
|
+
full: "rounded-3xl"
|
|
313
|
+
};
|
|
314
|
+
|
|
280
315
|
// src/components/ChatWindow.tsx
|
|
281
|
-
import { jsx as
|
|
316
|
+
import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
282
317
|
function ChatWindow({ className = "", style, onClose, showClose = false }) {
|
|
283
318
|
const { ui, projectId } = useConfig();
|
|
284
319
|
const [input, setInput] = useState3("");
|
|
@@ -317,15 +352,7 @@ function ChatWindow({ className = "", style, onClose, showClose = false }) {
|
|
|
317
352
|
clear();
|
|
318
353
|
};
|
|
319
354
|
const isEmpty = messages.length === 0;
|
|
320
|
-
const
|
|
321
|
-
none: "rounded-none",
|
|
322
|
-
sm: "rounded-sm",
|
|
323
|
-
md: "rounded-md",
|
|
324
|
-
lg: "rounded-lg",
|
|
325
|
-
xl: "rounded-xl",
|
|
326
|
-
full: "rounded-3xl"
|
|
327
|
-
};
|
|
328
|
-
const currentRadius = borderRadiusMap[ui.borderRadius || "xl"];
|
|
355
|
+
const currentRadius = BORDER_RADIUS_MAP[ui.borderRadius || "xl"];
|
|
329
356
|
const isGlass = ui.visualStyle !== "solid";
|
|
330
357
|
return /* @__PURE__ */ jsxs3(
|
|
331
358
|
"div",
|
|
@@ -342,41 +369,41 @@ function ChatWindow({ className = "", style, onClose, showClose = false }) {
|
|
|
342
369
|
/* @__PURE__ */ jsxs3("div", { className: "flex items-center gap-3", children: [
|
|
343
370
|
ui.logoUrl ? (
|
|
344
371
|
// eslint-disable-next-line @next/next/no-img-element
|
|
345
|
-
/* @__PURE__ */
|
|
346
|
-
) : /* @__PURE__ */
|
|
372
|
+
/* @__PURE__ */ jsx5("img", { src: ui.logoUrl, alt: "logo", className: "w-8 h-8 rounded-lg object-cover" })
|
|
373
|
+
) : /* @__PURE__ */ jsx5(
|
|
347
374
|
"div",
|
|
348
375
|
{
|
|
349
376
|
className: `w-9 h-9 flex items-center justify-center shadow-md ${ui.borderRadius === "full" ? "rounded-full" : "rounded-xl"}`,
|
|
350
377
|
style: { background: `linear-gradient(135deg, ${ui.primaryColor}, ${ui.accentColor})` },
|
|
351
|
-
children: /* @__PURE__ */
|
|
378
|
+
children: /* @__PURE__ */ jsx5(Bot3, { className: "w-5 h-5 text-white" })
|
|
352
379
|
}
|
|
353
380
|
),
|
|
354
381
|
/* @__PURE__ */ jsxs3("div", { children: [
|
|
355
|
-
/* @__PURE__ */
|
|
356
|
-
ui.poweredBy && /* @__PURE__ */
|
|
382
|
+
/* @__PURE__ */ jsx5("h2", { className: "text-slate-900 dark:text-white font-semibold text-sm leading-tight", children: ui.title }),
|
|
383
|
+
ui.poweredBy && /* @__PURE__ */ jsx5("p", { className: "text-slate-500 dark:text-white/40 text-[11px] leading-tight", children: `Powered by ${ui.poweredBy}` })
|
|
357
384
|
] })
|
|
358
385
|
] }),
|
|
359
386
|
/* @__PURE__ */ jsxs3("div", { className: "flex items-center gap-2", children: [
|
|
360
387
|
/* @__PURE__ */ jsxs3("span", { className: "flex items-center gap-1 text-[10px] text-emerald-500 dark:text-emerald-400", children: [
|
|
361
|
-
/* @__PURE__ */
|
|
388
|
+
/* @__PURE__ */ jsx5("span", { className: "w-1.5 h-1.5 rounded-full bg-emerald-500 dark:bg-emerald-400 animate-pulse" }),
|
|
362
389
|
"Online"
|
|
363
390
|
] }),
|
|
364
|
-
mounted && messages.length > 0 && /* @__PURE__ */
|
|
391
|
+
mounted && messages.length > 0 && /* @__PURE__ */ jsx5(
|
|
365
392
|
"button",
|
|
366
393
|
{
|
|
367
394
|
onClick: clearHistory,
|
|
368
395
|
title: "Clear conversation",
|
|
369
396
|
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",
|
|
370
|
-
children: /* @__PURE__ */
|
|
397
|
+
children: /* @__PURE__ */ jsx5(Trash2, { className: "w-3.5 h-3.5" })
|
|
371
398
|
}
|
|
372
399
|
),
|
|
373
|
-
showClose && onClose && /* @__PURE__ */
|
|
400
|
+
showClose && onClose && /* @__PURE__ */ jsx5(
|
|
374
401
|
"button",
|
|
375
402
|
{
|
|
376
403
|
onClick: onClose,
|
|
377
404
|
title: "Close chat",
|
|
378
405
|
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",
|
|
379
|
-
children: /* @__PURE__ */
|
|
406
|
+
children: /* @__PURE__ */ jsx5(X, { className: "w-4 h-4" })
|
|
380
407
|
}
|
|
381
408
|
)
|
|
382
409
|
] })
|
|
@@ -387,20 +414,20 @@ function ChatWindow({ className = "", style, onClose, showClose = false }) {
|
|
|
387
414
|
!mounted || isEmpty ? (
|
|
388
415
|
/* Welcome state */
|
|
389
416
|
/* @__PURE__ */ jsxs3("div", { className: "h-full flex flex-col items-center justify-center text-center gap-4 px-6 py-12", children: [
|
|
390
|
-
/* @__PURE__ */
|
|
417
|
+
/* @__PURE__ */ jsx5(
|
|
391
418
|
"div",
|
|
392
419
|
{
|
|
393
420
|
className: `w-16 h-16 flex items-center justify-center shadow-lg ${ui.borderRadius === "full" ? "rounded-full" : "rounded-2xl"}`,
|
|
394
421
|
style: { background: `linear-gradient(135deg, ${ui.primaryColor}, ${ui.accentColor})` },
|
|
395
|
-
children: /* @__PURE__ */
|
|
422
|
+
children: /* @__PURE__ */ jsx5(Sparkles2, { className: "w-8 h-8 text-white" })
|
|
396
423
|
}
|
|
397
424
|
),
|
|
398
425
|
/* @__PURE__ */ jsxs3("div", { children: [
|
|
399
|
-
/* @__PURE__ */
|
|
400
|
-
/* @__PURE__ */
|
|
426
|
+
/* @__PURE__ */ jsx5("p", { className: "text-slate-800 dark:text-white/80 font-medium leading-relaxed", children: ui.welcomeMessage }),
|
|
427
|
+
/* @__PURE__ */ jsx5("p", { className: "text-slate-500 dark:text-white/30 text-sm mt-2", children: "Ask a question to get started" })
|
|
401
428
|
] }),
|
|
402
|
-
/* @__PURE__ */
|
|
403
|
-
(suggestion) => /* @__PURE__ */
|
|
429
|
+
/* @__PURE__ */ jsx5("div", { className: "flex flex-wrap gap-2 justify-center mt-2", children: CHAT_SUGGESTIONS.map(
|
|
430
|
+
(suggestion) => /* @__PURE__ */ jsx5(
|
|
404
431
|
"button",
|
|
405
432
|
{
|
|
406
433
|
onClick: () => {
|
|
@@ -415,7 +442,7 @@ function ChatWindow({ className = "", style, onClose, showClose = false }) {
|
|
|
415
442
|
)
|
|
416
443
|
) })
|
|
417
444
|
] })
|
|
418
|
-
) : messages.map((msg) => /* @__PURE__ */
|
|
445
|
+
) : messages.map((msg) => /* @__PURE__ */ jsx5(
|
|
419
446
|
MessageBubble,
|
|
420
447
|
{
|
|
421
448
|
message: msg,
|
|
@@ -425,7 +452,7 @@ function ChatWindow({ className = "", style, onClose, showClose = false }) {
|
|
|
425
452
|
},
|
|
426
453
|
msg.id
|
|
427
454
|
)),
|
|
428
|
-
isLoading && /* @__PURE__ */
|
|
455
|
+
isLoading && /* @__PURE__ */ jsx5(
|
|
429
456
|
MessageBubble,
|
|
430
457
|
{
|
|
431
458
|
message: { role: "assistant", content: "" },
|
|
@@ -435,14 +462,14 @@ function ChatWindow({ className = "", style, onClose, showClose = false }) {
|
|
|
435
462
|
}
|
|
436
463
|
),
|
|
437
464
|
error && /* @__PURE__ */ jsxs3("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", children: [
|
|
438
|
-
/* @__PURE__ */
|
|
439
|
-
/* @__PURE__ */
|
|
465
|
+
/* @__PURE__ */ jsx5(TriangleAlert, { className: "w-4 h-4 flex-shrink-0" }),
|
|
466
|
+
/* @__PURE__ */ jsx5("span", { children: error })
|
|
440
467
|
] }),
|
|
441
|
-
/* @__PURE__ */
|
|
468
|
+
/* @__PURE__ */ jsx5("div", { ref: bottomRef })
|
|
442
469
|
] }),
|
|
443
470
|
/* @__PURE__ */ jsxs3("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]"}`, children: [
|
|
444
471
|
/* @__PURE__ */ jsxs3("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"}`, children: [
|
|
445
|
-
/* @__PURE__ */
|
|
472
|
+
/* @__PURE__ */ jsx5(
|
|
446
473
|
"textarea",
|
|
447
474
|
{
|
|
448
475
|
ref: inputRef,
|
|
@@ -456,7 +483,7 @@ function ChatWindow({ className = "", style, onClose, showClose = false }) {
|
|
|
456
483
|
style: { scrollbarWidth: "none" }
|
|
457
484
|
}
|
|
458
485
|
),
|
|
459
|
-
/* @__PURE__ */
|
|
486
|
+
/* @__PURE__ */ jsx5(
|
|
460
487
|
"button",
|
|
461
488
|
{
|
|
462
489
|
onClick: sendMessage,
|
|
@@ -466,11 +493,11 @@ function ChatWindow({ className = "", style, onClose, showClose = false }) {
|
|
|
466
493
|
background: input.trim() && !isLoading ? `linear-gradient(135deg, ${ui.primaryColor}, ${ui.accentColor})` : "rgba(148, 163, 184, 0.2)"
|
|
467
494
|
// slate-400/20 for light mode disabled
|
|
468
495
|
},
|
|
469
|
-
children: /* @__PURE__ */
|
|
496
|
+
children: /* @__PURE__ */ jsx5(ArrowUp, { className: "w-4 h-4 text-white" })
|
|
470
497
|
}
|
|
471
498
|
)
|
|
472
499
|
] }),
|
|
473
|
-
/* @__PURE__ */
|
|
500
|
+
/* @__PURE__ */ jsx5("p", { className: "text-center text-[10px] text-slate-400 dark:text-white/20 mt-2", children: "Press Enter to send \xB7 Shift+Enter for new line" })
|
|
474
501
|
] })
|
|
475
502
|
]
|
|
476
503
|
}
|
|
@@ -478,7 +505,7 @@ function ChatWindow({ className = "", style, onClose, showClose = false }) {
|
|
|
478
505
|
}
|
|
479
506
|
|
|
480
507
|
// src/components/ChatWidget.tsx
|
|
481
|
-
import { Fragment as Fragment2, jsx as
|
|
508
|
+
import { Fragment as Fragment2, jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
482
509
|
function ChatWidget({ position = "bottom-right" }) {
|
|
483
510
|
const { ui } = useConfig();
|
|
484
511
|
const [isOpen, setIsOpen] = useState4(false);
|
|
@@ -498,7 +525,7 @@ function ChatWidget({ position = "bottom-right" }) {
|
|
|
498
525
|
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"}`,
|
|
499
526
|
style: { height: "600px", maxHeight: "calc(100vh - 6rem)" },
|
|
500
527
|
children: [
|
|
501
|
-
/* @__PURE__ */
|
|
528
|
+
/* @__PURE__ */ jsx6(
|
|
502
529
|
ChatWindow,
|
|
503
530
|
{
|
|
504
531
|
className: "h-full relative z-10",
|
|
@@ -506,7 +533,7 @@ function ChatWidget({ position = "bottom-right" }) {
|
|
|
506
533
|
onClose: () => setIsOpen(false)
|
|
507
534
|
}
|
|
508
535
|
),
|
|
509
|
-
/* @__PURE__ */
|
|
536
|
+
/* @__PURE__ */ jsx6(
|
|
510
537
|
"div",
|
|
511
538
|
{
|
|
512
539
|
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"}`
|
|
@@ -523,21 +550,21 @@ function ChatWidget({ position = "bottom-right" }) {
|
|
|
523
550
|
style: { background: `linear-gradient(135deg, ${ui.primaryColor}, ${ui.accentColor})` },
|
|
524
551
|
"aria-label": "Open chat",
|
|
525
552
|
children: [
|
|
526
|
-
/* @__PURE__ */
|
|
553
|
+
/* @__PURE__ */ jsx6(
|
|
527
554
|
"span",
|
|
528
555
|
{
|
|
529
556
|
className: "absolute inset-0 rounded-full animate-ping opacity-20",
|
|
530
557
|
style: { background: ui.primaryColor }
|
|
531
558
|
}
|
|
532
559
|
),
|
|
533
|
-
/* @__PURE__ */
|
|
560
|
+
/* @__PURE__ */ jsx6(
|
|
534
561
|
"span",
|
|
535
562
|
{
|
|
536
563
|
className: `transition-transform duration-300 ${isOpen ? "rotate-90 scale-90" : "rotate-0 scale-100"}`,
|
|
537
|
-
children: isOpen ? /* @__PURE__ */
|
|
564
|
+
children: isOpen ? /* @__PURE__ */ jsx6(X2, { className: "w-6 h-6 text-white" }) : /* @__PURE__ */ jsx6(MessageSquare2, { className: "w-6 h-6 text-white" })
|
|
538
565
|
}
|
|
539
566
|
),
|
|
540
|
-
hasUnread && !isOpen && /* @__PURE__ */
|
|
567
|
+
hasUnread && !isOpen && /* @__PURE__ */ jsx6("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", children: "1" })
|
|
541
568
|
]
|
|
542
569
|
}
|
|
543
570
|
)
|
package/dist/server.d.mts
CHANGED
|
@@ -693,6 +693,41 @@ declare class PostgreSQLProvider extends BaseVectorProvider {
|
|
|
693
693
|
disconnect(): Promise<void>;
|
|
694
694
|
}
|
|
695
695
|
|
|
696
|
+
/**
|
|
697
|
+
* MultiTablePostgresProvider — PostgreSQL implementation that searches across
|
|
698
|
+
* multiple existing tables with pre-existing embeddings.
|
|
699
|
+
*
|
|
700
|
+
* Extends BaseVectorProvider so it can be registered with ProviderRegistry.
|
|
701
|
+
* Upsert operations are not supported — data is assumed to be managed externally
|
|
702
|
+
* or via custom ingestion scripts that write directly to each table.
|
|
703
|
+
*/
|
|
704
|
+
declare class MultiTablePostgresProvider extends BaseVectorProvider {
|
|
705
|
+
private pool;
|
|
706
|
+
private readonly dimensions;
|
|
707
|
+
private readonly connectionString;
|
|
708
|
+
private readonly tables;
|
|
709
|
+
constructor(config: VectorDBConfig);
|
|
710
|
+
initialize(): Promise<void>;
|
|
711
|
+
/**
|
|
712
|
+
* Upsert is not supported for MultiTablePostgresProvider as it's designed for
|
|
713
|
+
* searching across pre-existing tables with varying schemas.
|
|
714
|
+
*/
|
|
715
|
+
upsert(_doc: UpsertDocument, _namespace?: string): Promise<void>;
|
|
716
|
+
/**
|
|
717
|
+
* Batch upsert is not supported for MultiTablePostgresProvider.
|
|
718
|
+
*/
|
|
719
|
+
batchUpsert(_docs: UpsertDocument[], _namespace?: string): Promise<void>;
|
|
720
|
+
/**
|
|
721
|
+
* Query all configured tables and merge results, sorted by cosine similarity score.
|
|
722
|
+
*/
|
|
723
|
+
query(vector: number[], topK: number, _namespace?: string, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
724
|
+
_filter?: Record<string, unknown>): Promise<VectorMatch[]>;
|
|
725
|
+
delete(_id: string | number, _namespace?: string): Promise<void>;
|
|
726
|
+
deleteNamespace(_namespace: string): Promise<void>;
|
|
727
|
+
ping(): Promise<boolean>;
|
|
728
|
+
disconnect(): Promise<void>;
|
|
729
|
+
}
|
|
730
|
+
|
|
696
731
|
/**
|
|
697
732
|
* MongoDBProvider — MongoDB Atlas Vector Search implementation.
|
|
698
733
|
*/
|
|
@@ -980,4 +1015,4 @@ declare class UniversalLLMAdapter implements ILLMProvider {
|
|
|
980
1015
|
ping(): Promise<boolean>;
|
|
981
1016
|
}
|
|
982
1017
|
|
|
983
|
-
export { AnthropicProvider, BaseVectorProvider, type BatchOptions, BatchProcessor, type BatchResult, ChatMessage, ChatOptions, ChatResponse, ChromaDBProvider, ConfigBuilder, ConfigResolver, ConfigValidator, DocumentParser, EmbedOptions, EmbeddingConfig, EmbeddingProvider, EmbeddingStrategy, EmbeddingStrategyResolver, HealthCheckResult, ILLMProvider, IngestDocument, LLMConfig, LLMFactory, LLMProvider, LLM_PROFILES, MilvusProvider, MongoDBProvider, OllamaProvider, OpenAIProvider, PRESETS, PineconeProvider, Pipeline, PostgreSQLProvider, ProviderRegistry, QdrantProvider, RagConfig, RedisProvider, UniversalLLMAdapter, UniversalVectorProvider, UpsertDocument, VECTOR_PROFILES, type ValidationError, VectorDBConfig, VectorDBProvider, VectorMatch, VectorPlugin, WeaviateProvider, createFromPreset, getRagConfig };
|
|
1018
|
+
export { AnthropicProvider, BaseVectorProvider, type BatchOptions, BatchProcessor, type BatchResult, ChatMessage, ChatOptions, ChatResponse, ChromaDBProvider, ConfigBuilder, ConfigResolver, ConfigValidator, DocumentParser, EmbedOptions, EmbeddingConfig, EmbeddingProvider, EmbeddingStrategy, EmbeddingStrategyResolver, HealthCheckResult, ILLMProvider, IngestDocument, LLMConfig, LLMFactory, LLMProvider, LLM_PROFILES, MilvusProvider, MongoDBProvider, MultiTablePostgresProvider, OllamaProvider, OpenAIProvider, PRESETS, PineconeProvider, Pipeline, PostgreSQLProvider, ProviderRegistry, QdrantProvider, RagConfig, RedisProvider, UniversalLLMAdapter, UniversalVectorProvider, UpsertDocument, VECTOR_PROFILES, type ValidationError, VectorDBConfig, VectorDBProvider, VectorMatch, VectorPlugin, WeaviateProvider, createFromPreset, getRagConfig };
|
package/dist/server.d.ts
CHANGED
|
@@ -693,6 +693,41 @@ declare class PostgreSQLProvider extends BaseVectorProvider {
|
|
|
693
693
|
disconnect(): Promise<void>;
|
|
694
694
|
}
|
|
695
695
|
|
|
696
|
+
/**
|
|
697
|
+
* MultiTablePostgresProvider — PostgreSQL implementation that searches across
|
|
698
|
+
* multiple existing tables with pre-existing embeddings.
|
|
699
|
+
*
|
|
700
|
+
* Extends BaseVectorProvider so it can be registered with ProviderRegistry.
|
|
701
|
+
* Upsert operations are not supported — data is assumed to be managed externally
|
|
702
|
+
* or via custom ingestion scripts that write directly to each table.
|
|
703
|
+
*/
|
|
704
|
+
declare class MultiTablePostgresProvider extends BaseVectorProvider {
|
|
705
|
+
private pool;
|
|
706
|
+
private readonly dimensions;
|
|
707
|
+
private readonly connectionString;
|
|
708
|
+
private readonly tables;
|
|
709
|
+
constructor(config: VectorDBConfig);
|
|
710
|
+
initialize(): Promise<void>;
|
|
711
|
+
/**
|
|
712
|
+
* Upsert is not supported for MultiTablePostgresProvider as it's designed for
|
|
713
|
+
* searching across pre-existing tables with varying schemas.
|
|
714
|
+
*/
|
|
715
|
+
upsert(_doc: UpsertDocument, _namespace?: string): Promise<void>;
|
|
716
|
+
/**
|
|
717
|
+
* Batch upsert is not supported for MultiTablePostgresProvider.
|
|
718
|
+
*/
|
|
719
|
+
batchUpsert(_docs: UpsertDocument[], _namespace?: string): Promise<void>;
|
|
720
|
+
/**
|
|
721
|
+
* Query all configured tables and merge results, sorted by cosine similarity score.
|
|
722
|
+
*/
|
|
723
|
+
query(vector: number[], topK: number, _namespace?: string, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
724
|
+
_filter?: Record<string, unknown>): Promise<VectorMatch[]>;
|
|
725
|
+
delete(_id: string | number, _namespace?: string): Promise<void>;
|
|
726
|
+
deleteNamespace(_namespace: string): Promise<void>;
|
|
727
|
+
ping(): Promise<boolean>;
|
|
728
|
+
disconnect(): Promise<void>;
|
|
729
|
+
}
|
|
730
|
+
|
|
696
731
|
/**
|
|
697
732
|
* MongoDBProvider — MongoDB Atlas Vector Search implementation.
|
|
698
733
|
*/
|
|
@@ -980,4 +1015,4 @@ declare class UniversalLLMAdapter implements ILLMProvider {
|
|
|
980
1015
|
ping(): Promise<boolean>;
|
|
981
1016
|
}
|
|
982
1017
|
|
|
983
|
-
export { AnthropicProvider, BaseVectorProvider, type BatchOptions, BatchProcessor, type BatchResult, ChatMessage, ChatOptions, ChatResponse, ChromaDBProvider, ConfigBuilder, ConfigResolver, ConfigValidator, DocumentParser, EmbedOptions, EmbeddingConfig, EmbeddingProvider, EmbeddingStrategy, EmbeddingStrategyResolver, HealthCheckResult, ILLMProvider, IngestDocument, LLMConfig, LLMFactory, LLMProvider, LLM_PROFILES, MilvusProvider, MongoDBProvider, OllamaProvider, OpenAIProvider, PRESETS, PineconeProvider, Pipeline, PostgreSQLProvider, ProviderRegistry, QdrantProvider, RagConfig, RedisProvider, UniversalLLMAdapter, UniversalVectorProvider, UpsertDocument, VECTOR_PROFILES, type ValidationError, VectorDBConfig, VectorDBProvider, VectorMatch, VectorPlugin, WeaviateProvider, createFromPreset, getRagConfig };
|
|
1018
|
+
export { AnthropicProvider, BaseVectorProvider, type BatchOptions, BatchProcessor, type BatchResult, ChatMessage, ChatOptions, ChatResponse, ChromaDBProvider, ConfigBuilder, ConfigResolver, ConfigValidator, DocumentParser, EmbedOptions, EmbeddingConfig, EmbeddingProvider, EmbeddingStrategy, EmbeddingStrategyResolver, HealthCheckResult, ILLMProvider, IngestDocument, LLMConfig, LLMFactory, LLMProvider, LLM_PROFILES, MilvusProvider, MongoDBProvider, MultiTablePostgresProvider, OllamaProvider, OpenAIProvider, PRESETS, PineconeProvider, Pipeline, PostgreSQLProvider, ProviderRegistry, QdrantProvider, RagConfig, RedisProvider, UniversalLLMAdapter, UniversalVectorProvider, UpsertDocument, VECTOR_PROFILES, type ValidationError, VectorDBConfig, VectorDBProvider, VectorMatch, VectorPlugin, WeaviateProvider, createFromPreset, getRagConfig };
|
package/dist/server.js
CHANGED
|
@@ -22,6 +22,18 @@ var __spreadValues = (a, b) => {
|
|
|
22
22
|
return a;
|
|
23
23
|
};
|
|
24
24
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
25
|
+
var __objRest = (source, exclude) => {
|
|
26
|
+
var target = {};
|
|
27
|
+
for (var prop in source)
|
|
28
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
29
|
+
target[prop] = source[prop];
|
|
30
|
+
if (source != null && __getOwnPropSymbols)
|
|
31
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
32
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
33
|
+
target[prop] = source[prop];
|
|
34
|
+
}
|
|
35
|
+
return target;
|
|
36
|
+
};
|
|
25
37
|
var __esm = (fn, res) => function __init() {
|
|
26
38
|
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
27
39
|
};
|
|
@@ -1169,6 +1181,7 @@ __export(server_exports, {
|
|
|
1169
1181
|
LLM_PROFILES: () => LLM_PROFILES,
|
|
1170
1182
|
MilvusProvider: () => MilvusProvider,
|
|
1171
1183
|
MongoDBProvider: () => MongoDBProvider,
|
|
1184
|
+
MultiTablePostgresProvider: () => MultiTablePostgresProvider,
|
|
1172
1185
|
OllamaProvider: () => OllamaProvider,
|
|
1173
1186
|
OpenAIProvider: () => OpenAIProvider,
|
|
1174
1187
|
PRESETS: () => PRESETS,
|
|
@@ -3661,6 +3674,119 @@ var DocumentParser = class {
|
|
|
3661
3674
|
init_BaseVectorProvider();
|
|
3662
3675
|
init_PineconeProvider();
|
|
3663
3676
|
init_PostgreSQLProvider();
|
|
3677
|
+
|
|
3678
|
+
// src/providers/vectordb/MultiTablePostgresProvider.ts
|
|
3679
|
+
var import_pg2 = require("pg");
|
|
3680
|
+
init_BaseVectorProvider();
|
|
3681
|
+
var MultiTablePostgresProvider = class extends BaseVectorProvider {
|
|
3682
|
+
constructor(config) {
|
|
3683
|
+
var _a, _b, _c;
|
|
3684
|
+
super(config);
|
|
3685
|
+
const opts = config.options || {};
|
|
3686
|
+
if (!opts.connectionString) {
|
|
3687
|
+
throw new Error("[MultiTablePostgresProvider] options.connectionString is required");
|
|
3688
|
+
}
|
|
3689
|
+
this.connectionString = opts.connectionString;
|
|
3690
|
+
this.dimensions = (_a = opts.dimensions) != null ? _a : 768;
|
|
3691
|
+
const rawTables = (_c = (_b = opts.tables) != null ? _b : process.env.VECTOR_DB_TABLES) != null ? _c : "";
|
|
3692
|
+
this.tables = typeof rawTables === "string" ? rawTables.split(",").map((t) => t.trim()).filter(Boolean) : rawTables;
|
|
3693
|
+
if (this.tables.length === 0) {
|
|
3694
|
+
console.warn(
|
|
3695
|
+
"[MultiTablePostgresProvider] No tables configured. Set VECTOR_DB_TABLES as a comma-separated list of table names or pass options.tables."
|
|
3696
|
+
);
|
|
3697
|
+
}
|
|
3698
|
+
}
|
|
3699
|
+
async initialize() {
|
|
3700
|
+
this.pool = new import_pg2.Pool({ connectionString: this.connectionString });
|
|
3701
|
+
const client = await this.pool.connect();
|
|
3702
|
+
client.release();
|
|
3703
|
+
console.log(
|
|
3704
|
+
`[MultiTablePostgresProvider] Connected. Searching across ${this.tables.length} table(s): ${this.tables.join(", ")}`
|
|
3705
|
+
);
|
|
3706
|
+
}
|
|
3707
|
+
/**
|
|
3708
|
+
* Upsert is not supported for MultiTablePostgresProvider as it's designed for
|
|
3709
|
+
* searching across pre-existing tables with varying schemas.
|
|
3710
|
+
*/
|
|
3711
|
+
async upsert(_doc, _namespace) {
|
|
3712
|
+
throw new Error(
|
|
3713
|
+
"[MultiTablePostgresProvider] upsert() is not supported in multi-table mode. Please use the standard PostgreSQLProvider for single-table managed indices."
|
|
3714
|
+
);
|
|
3715
|
+
}
|
|
3716
|
+
/**
|
|
3717
|
+
* Batch upsert is not supported for MultiTablePostgresProvider.
|
|
3718
|
+
*/
|
|
3719
|
+
async batchUpsert(_docs, _namespace) {
|
|
3720
|
+
throw new Error(
|
|
3721
|
+
"[MultiTablePostgresProvider] batchUpsert() is not supported in multi-table mode."
|
|
3722
|
+
);
|
|
3723
|
+
}
|
|
3724
|
+
/**
|
|
3725
|
+
* Query all configured tables and merge results, sorted by cosine similarity score.
|
|
3726
|
+
*/
|
|
3727
|
+
async query(vector, topK, _namespace, _filter) {
|
|
3728
|
+
var _b, _c;
|
|
3729
|
+
if (!this.pool) {
|
|
3730
|
+
throw new Error("[MultiTablePostgresProvider] Provider not initialized. Call initialize() first.");
|
|
3731
|
+
}
|
|
3732
|
+
console.log(`[MultiTablePostgresProvider] Querying ${this.tables.length} table(s) with vector dim=${vector.length}`);
|
|
3733
|
+
const vectorLiteral = `[${vector.join(",")}]`;
|
|
3734
|
+
const allResults = [];
|
|
3735
|
+
for (const table of this.tables) {
|
|
3736
|
+
try {
|
|
3737
|
+
const result = await this.pool.query(
|
|
3738
|
+
`SELECT *, 1 - (embedding <=> $1::vector) AS score
|
|
3739
|
+
FROM "${table}"
|
|
3740
|
+
ORDER BY embedding <=> $1::vector
|
|
3741
|
+
LIMIT $2`,
|
|
3742
|
+
[vectorLiteral, topK]
|
|
3743
|
+
);
|
|
3744
|
+
for (const row of result.rows) {
|
|
3745
|
+
const _a = row, { score, id } = _a, rest = __objRest(_a, ["score", "id"]);
|
|
3746
|
+
delete rest.embedding;
|
|
3747
|
+
const content = Object.entries(rest).filter(([k, v]) => v !== null && typeof v !== "object" && k !== "id").map(([k, v]) => `${k}: ${v}`).join("\n");
|
|
3748
|
+
allResults.push({
|
|
3749
|
+
id: `${table}-${id}`,
|
|
3750
|
+
score: parseFloat(String(score)),
|
|
3751
|
+
content,
|
|
3752
|
+
metadata: __spreadProps(__spreadValues({}, rest), { source_table: table })
|
|
3753
|
+
});
|
|
3754
|
+
}
|
|
3755
|
+
} catch (err) {
|
|
3756
|
+
console.error(
|
|
3757
|
+
`[MultiTablePostgresProvider] Error querying table "${table}":`,
|
|
3758
|
+
err.message
|
|
3759
|
+
);
|
|
3760
|
+
}
|
|
3761
|
+
}
|
|
3762
|
+
const sortedResults = allResults.sort((a, b) => b.score - a.score);
|
|
3763
|
+
if (sortedResults.length > 0) {
|
|
3764
|
+
console.log(`[MultiTablePostgresProvider] Top match from "${(_c = (_b = sortedResults[0].metadata) == null ? void 0 : _b.source_table) != null ? _c : "unknown"}" with score ${sortedResults[0].score.toFixed(4)}`);
|
|
3765
|
+
}
|
|
3766
|
+
return sortedResults.slice(0, Math.max(topK, 15));
|
|
3767
|
+
}
|
|
3768
|
+
async delete(_id, _namespace) {
|
|
3769
|
+
console.warn("[MultiTablePostgresProvider] delete() is a no-op for multi-table mode.");
|
|
3770
|
+
}
|
|
3771
|
+
async deleteNamespace(_namespace) {
|
|
3772
|
+
console.warn("[MultiTablePostgresProvider] deleteNamespace() is a no-op for multi-table mode.");
|
|
3773
|
+
}
|
|
3774
|
+
async ping() {
|
|
3775
|
+
try {
|
|
3776
|
+
await this.pool.query("SELECT 1");
|
|
3777
|
+
return true;
|
|
3778
|
+
} catch (e) {
|
|
3779
|
+
return false;
|
|
3780
|
+
}
|
|
3781
|
+
}
|
|
3782
|
+
async disconnect() {
|
|
3783
|
+
if (this.pool) {
|
|
3784
|
+
await this.pool.end();
|
|
3785
|
+
}
|
|
3786
|
+
}
|
|
3787
|
+
};
|
|
3788
|
+
|
|
3789
|
+
// src/server.ts
|
|
3664
3790
|
init_MongoDBProvider();
|
|
3665
3791
|
init_MilvusProvider();
|
|
3666
3792
|
init_QdrantProvider();
|
|
@@ -3772,6 +3898,7 @@ function createUploadHandler(config) {
|
|
|
3772
3898
|
LLM_PROFILES,
|
|
3773
3899
|
MilvusProvider,
|
|
3774
3900
|
MongoDBProvider,
|
|
3901
|
+
MultiTablePostgresProvider,
|
|
3775
3902
|
OllamaProvider,
|
|
3776
3903
|
OpenAIProvider,
|
|
3777
3904
|
PRESETS,
|