@retrivora-ai/rag-engine 1.4.2 → 1.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/index.js +21 -3
- package/dist/index.mjs +21 -3
- package/package.json +1 -1
- package/src/components/MessageBubble.tsx +48 -14
package/dist/index.js
CHANGED
|
@@ -538,15 +538,30 @@ function MessageBubble({
|
|
|
538
538
|
});
|
|
539
539
|
}, [productsFromSources, productsFromContent, message.content]);
|
|
540
540
|
const processedMarkdown = import_react5.default.useMemo(() => {
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
541
|
+
let raw = cleanContent || message.content;
|
|
542
|
+
raw = raw.replace(/([^\n])\n\|/g, "$1\n\n|").replace(/(\|[^\n]*\|)\n\n+(?=\|)/g, "$1\n");
|
|
543
|
+
if (isStreaming) {
|
|
544
|
+
raw = raw.replace(/((?:^|\n)\|.*)+/g, (match) => {
|
|
545
|
+
return `
|
|
546
|
+
|
|
547
|
+
\`\`\`table-loading
|
|
548
|
+
${match.trim()}
|
|
549
|
+
\`\`\`
|
|
550
|
+
|
|
551
|
+
`;
|
|
552
|
+
});
|
|
553
|
+
}
|
|
554
|
+
return raw;
|
|
555
|
+
}, [cleanContent, message.content, isStreaming]);
|
|
544
556
|
const markdownComponents = import_react5.default.useMemo(
|
|
545
557
|
() => ({
|
|
546
558
|
// Wrap in not-prose so Tailwind Typography resets don't clobber our styles.
|
|
547
559
|
// prose applies display:block and padding:0 to table/th/td — not-prose opts out.
|
|
548
560
|
table: (_a) => {
|
|
549
561
|
var props = __objRest(_a, []);
|
|
562
|
+
if (isStreaming) {
|
|
563
|
+
return /* @__PURE__ */ import_react5.default.createElement("div", { className: "my-5 p-6 bg-slate-50 dark:bg-white/5 rounded-xl border border-dashed border-slate-300 dark:border-white/10 flex items-center justify-center gap-3 select-none" }, /* @__PURE__ */ import_react5.default.createElement("div", { className: "w-4 h-4 border-2 border-indigo-500 border-t-transparent rounded-full animate-spin" }), /* @__PURE__ */ import_react5.default.createElement("p", { className: "text-xs text-slate-500 font-medium italic animate-pulse" }, "Generating data table..."));
|
|
564
|
+
}
|
|
550
565
|
return /* @__PURE__ */ import_react5.default.createElement("div", { className: "not-prose overflow-hidden my-5 rounded-xl border border-slate-200 dark:border-white/10 shadow-sm bg-white dark:bg-slate-900/50" }, /* @__PURE__ */ import_react5.default.createElement("div", { className: "overflow-x-auto" }, /* @__PURE__ */ import_react5.default.createElement(
|
|
551
566
|
"table",
|
|
552
567
|
__spreadValues({
|
|
@@ -619,6 +634,9 @@ function MessageBubble({
|
|
|
619
634
|
}
|
|
620
635
|
);
|
|
621
636
|
}
|
|
637
|
+
if (!inline && lang === "table-loading") {
|
|
638
|
+
return /* @__PURE__ */ import_react5.default.createElement("div", { className: "my-5 p-6 bg-slate-50 dark:bg-white/5 rounded-xl border border-dashed border-slate-300 dark:border-white/10 flex items-center justify-center gap-3 select-none" }, /* @__PURE__ */ import_react5.default.createElement("div", { className: "w-4 h-4 border-2 border-indigo-500 border-t-transparent rounded-full animate-spin" }), /* @__PURE__ */ import_react5.default.createElement("p", { className: "text-xs text-slate-500 font-medium italic animate-pulse" }, "Generating data table..."));
|
|
639
|
+
}
|
|
622
640
|
return /* @__PURE__ */ import_react5.default.createElement("code", __spreadValues({ className }, props), typeof children === "string" || typeof children === "number" ? children : JSON.stringify(children));
|
|
623
641
|
}
|
|
624
642
|
}),
|
package/dist/index.mjs
CHANGED
|
@@ -501,15 +501,30 @@ function MessageBubble({
|
|
|
501
501
|
});
|
|
502
502
|
}, [productsFromSources, productsFromContent, message.content]);
|
|
503
503
|
const processedMarkdown = React5.useMemo(() => {
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
504
|
+
let raw = cleanContent || message.content;
|
|
505
|
+
raw = raw.replace(/([^\n])\n\|/g, "$1\n\n|").replace(/(\|[^\n]*\|)\n\n+(?=\|)/g, "$1\n");
|
|
506
|
+
if (isStreaming) {
|
|
507
|
+
raw = raw.replace(/((?:^|\n)\|.*)+/g, (match) => {
|
|
508
|
+
return `
|
|
509
|
+
|
|
510
|
+
\`\`\`table-loading
|
|
511
|
+
${match.trim()}
|
|
512
|
+
\`\`\`
|
|
513
|
+
|
|
514
|
+
`;
|
|
515
|
+
});
|
|
516
|
+
}
|
|
517
|
+
return raw;
|
|
518
|
+
}, [cleanContent, message.content, isStreaming]);
|
|
507
519
|
const markdownComponents = React5.useMemo(
|
|
508
520
|
() => ({
|
|
509
521
|
// Wrap in not-prose so Tailwind Typography resets don't clobber our styles.
|
|
510
522
|
// prose applies display:block and padding:0 to table/th/td — not-prose opts out.
|
|
511
523
|
table: (_a) => {
|
|
512
524
|
var props = __objRest(_a, []);
|
|
525
|
+
if (isStreaming) {
|
|
526
|
+
return /* @__PURE__ */ React5.createElement("div", { className: "my-5 p-6 bg-slate-50 dark:bg-white/5 rounded-xl border border-dashed border-slate-300 dark:border-white/10 flex items-center justify-center gap-3 select-none" }, /* @__PURE__ */ React5.createElement("div", { className: "w-4 h-4 border-2 border-indigo-500 border-t-transparent rounded-full animate-spin" }), /* @__PURE__ */ React5.createElement("p", { className: "text-xs text-slate-500 font-medium italic animate-pulse" }, "Generating data table..."));
|
|
527
|
+
}
|
|
513
528
|
return /* @__PURE__ */ React5.createElement("div", { className: "not-prose overflow-hidden my-5 rounded-xl border border-slate-200 dark:border-white/10 shadow-sm bg-white dark:bg-slate-900/50" }, /* @__PURE__ */ React5.createElement("div", { className: "overflow-x-auto" }, /* @__PURE__ */ React5.createElement(
|
|
514
529
|
"table",
|
|
515
530
|
__spreadValues({
|
|
@@ -582,6 +597,9 @@ function MessageBubble({
|
|
|
582
597
|
}
|
|
583
598
|
);
|
|
584
599
|
}
|
|
600
|
+
if (!inline && lang === "table-loading") {
|
|
601
|
+
return /* @__PURE__ */ React5.createElement("div", { className: "my-5 p-6 bg-slate-50 dark:bg-white/5 rounded-xl border border-dashed border-slate-300 dark:border-white/10 flex items-center justify-center gap-3 select-none" }, /* @__PURE__ */ React5.createElement("div", { className: "w-4 h-4 border-2 border-indigo-500 border-t-transparent rounded-full animate-spin" }), /* @__PURE__ */ React5.createElement("p", { className: "text-xs text-slate-500 font-medium italic animate-pulse" }, "Generating data table..."));
|
|
602
|
+
}
|
|
585
603
|
return /* @__PURE__ */ React5.createElement("code", __spreadValues({ className }, props), typeof children === "string" || typeof children === "number" ? children : JSON.stringify(children));
|
|
586
604
|
}
|
|
587
605
|
}),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@retrivora-ai/rag-engine",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.4",
|
|
4
4
|
"description": "Retrivora AI is a plug-and-play AI engine for RAG chat experiences — generic vector DB + LLM provider, embeddable or standalone.",
|
|
5
5
|
"author": "Abhinav Alkuchi",
|
|
6
6
|
"license": "MIT",
|
|
@@ -357,28 +357,51 @@ export function MessageBubble({
|
|
|
357
357
|
});
|
|
358
358
|
}, [productsFromSources, productsFromContent, message.content]);
|
|
359
359
|
|
|
360
|
-
// ── Markdown source fixer ──────────────────────────────────────────────────
|
|
361
|
-
// GFM tables require a blank line before the | row when preceded by text.
|
|
362
360
|
const processedMarkdown = React.useMemo(() => {
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
361
|
+
let raw = cleanContent || message.content;
|
|
362
|
+
|
|
363
|
+
// 1. Structural fixes
|
|
364
|
+
raw = raw.replace(/([^\n])\n\|/g, '$1\n\n|') // Ensure blank line before table
|
|
365
|
+
.replace(/(\|[^\n]*\|)\n\n+(?=\|)/g, '$1\n'); // Remove blank lines between rows
|
|
366
|
+
|
|
367
|
+
// 2. HIJACKING: If streaming, hide table-like content to prevent raw markdown flashing.
|
|
368
|
+
if (isStreaming) {
|
|
369
|
+
raw = raw.replace(/((?:^|\n)\|.*)+/g, (match) => {
|
|
370
|
+
return `\n\n\`\`\`table-loading\n${match.trim()}\n\`\`\`\n\n`;
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
return raw;
|
|
375
|
+
}, [cleanContent, message.content, isStreaming]);
|
|
366
376
|
|
|
367
377
|
// ── Markdown component overrides ───────────────────────────────────────────
|
|
368
378
|
const markdownComponents = React.useMemo(
|
|
369
379
|
() => ({
|
|
370
380
|
// Wrap in not-prose so Tailwind Typography resets don't clobber our styles.
|
|
371
381
|
// prose applies display:block and padding:0 to table/th/td — not-prose opts out.
|
|
372
|
-
table: ({ ...props }: React.HTMLAttributes<HTMLTableElement>) =>
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
<
|
|
376
|
-
className="
|
|
377
|
-
|
|
378
|
-
|
|
382
|
+
table: ({ ...props }: React.HTMLAttributes<HTMLTableElement>) => {
|
|
383
|
+
if (isStreaming) {
|
|
384
|
+
return (
|
|
385
|
+
<div className="my-5 p-6 bg-slate-50 dark:bg-white/5 rounded-xl border border-dashed border-slate-300 dark:border-white/10 flex items-center justify-center gap-3 select-none">
|
|
386
|
+
<div className="w-4 h-4 border-2 border-indigo-500 border-t-transparent rounded-full animate-spin" />
|
|
387
|
+
<p className="text-xs text-slate-500 font-medium italic animate-pulse">
|
|
388
|
+
Generating data table...
|
|
389
|
+
</p>
|
|
390
|
+
</div>
|
|
391
|
+
);
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
return (
|
|
395
|
+
<div className="not-prose overflow-hidden my-5 rounded-xl border border-slate-200 dark:border-white/10 shadow-sm bg-white dark:bg-slate-900/50">
|
|
396
|
+
<div className="overflow-x-auto">
|
|
397
|
+
<table
|
|
398
|
+
className="!table w-full text-left border-collapse min-w-[400px] text-sm"
|
|
399
|
+
{...props}
|
|
400
|
+
/>
|
|
401
|
+
</div>
|
|
379
402
|
</div>
|
|
380
|
-
|
|
381
|
-
|
|
403
|
+
);
|
|
404
|
+
},
|
|
382
405
|
thead: ({ ...props }: React.HTMLAttributes<HTMLTableSectionElement>) => (
|
|
383
406
|
<thead
|
|
384
407
|
className="!table-header-group bg-slate-50 dark:bg-white/5 border-b border-slate-200 dark:border-white/10"
|
|
@@ -429,6 +452,17 @@ export function MessageBubble({
|
|
|
429
452
|
);
|
|
430
453
|
}
|
|
431
454
|
|
|
455
|
+
if (!inline && lang === 'table-loading') {
|
|
456
|
+
return (
|
|
457
|
+
<div className="my-5 p-6 bg-slate-50 dark:bg-white/5 rounded-xl border border-dashed border-slate-300 dark:border-white/10 flex items-center justify-center gap-3 select-none">
|
|
458
|
+
<div className="w-4 h-4 border-2 border-indigo-500 border-t-transparent rounded-full animate-spin" />
|
|
459
|
+
<p className="text-xs text-slate-500 font-medium italic animate-pulse">
|
|
460
|
+
Generating data table...
|
|
461
|
+
</p>
|
|
462
|
+
</div>
|
|
463
|
+
);
|
|
464
|
+
}
|
|
465
|
+
|
|
432
466
|
return (
|
|
433
467
|
<code className={className} {...props}>
|
|
434
468
|
{typeof children === 'string' || typeof children === 'number'
|