@retrivora-ai/rag-engine 1.6.2 → 1.6.3

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 CHANGED
@@ -530,6 +530,10 @@ function extractStructuredPayload(raw) {
530
530
  text: stripStructuredUiLabels(raw).replace(/\n{3,}/g, "\n\n").trim()
531
531
  };
532
532
  }
533
+ function isLikelyUiOnlyMessage(text) {
534
+ const trimmed = text.trim();
535
+ return trimmed.length === 0 || /^(chart data|table data|visualization|visual representation)\s*:?\s*$/i.test(trimmed);
536
+ }
533
537
  function resolveImage(data) {
534
538
  for (const key of ["image", "img", "thumbnail"]) {
535
539
  const v = data[key];
@@ -746,6 +750,7 @@ function MessageBubble({
746
750
  () => isUser ? { payload: null, text: message.content } : extractStructuredPayload(message.content),
747
751
  [isUser, message.content]
748
752
  );
753
+ const shouldRenderStructuredOnly = !isUser && Boolean(structuredContent.payload) && isLikelyUiOnlyMessage(structuredContent.text);
749
754
  const productsFromSources = import_react5.default.useMemo(() => {
750
755
  if (isUser || !sources) return [];
751
756
  return sources.filter((s) => {
@@ -1008,7 +1013,7 @@ ${match.trim()}
1008
1013
  onAddToCart,
1009
1014
  viewportSize
1010
1015
  }
1011
- ), /* @__PURE__ */ import_react5.default.createElement(import_react_markdown.default, { remarkPlugins: [import_remark_gfm.default], components: markdownComponents }, processedMarkdown), isStreaming && message.content && /* @__PURE__ */ import_react5.default.createElement("span", { className: "inline-block w-1.5 h-3.5 ml-1 bg-emerald-500 animate-pulse align-middle" }))
1016
+ ), !shouldRenderStructuredOnly && /* @__PURE__ */ import_react5.default.createElement(import_react_markdown.default, { remarkPlugins: [import_remark_gfm.default], components: markdownComponents }, processedMarkdown), isStreaming && message.content && /* @__PURE__ */ import_react5.default.createElement("span", { className: "inline-block w-1.5 h-3.5 ml-1 bg-emerald-500 animate-pulse align-middle" }))
1012
1017
  ), !isUser && !hasStructuredProductBlock && allProducts.length > 0 && /* @__PURE__ */ import_react5.default.createElement("div", { className: "w-full mt-1" }, /* @__PURE__ */ import_react5.default.createElement(
1013
1018
  ProductCarousel,
1014
1019
  {
package/dist/index.mjs CHANGED
@@ -493,6 +493,10 @@ function extractStructuredPayload(raw) {
493
493
  text: stripStructuredUiLabels(raw).replace(/\n{3,}/g, "\n\n").trim()
494
494
  };
495
495
  }
496
+ function isLikelyUiOnlyMessage(text) {
497
+ const trimmed = text.trim();
498
+ return trimmed.length === 0 || /^(chart data|table data|visualization|visual representation)\s*:?\s*$/i.test(trimmed);
499
+ }
496
500
  function resolveImage(data) {
497
501
  for (const key of ["image", "img", "thumbnail"]) {
498
502
  const v = data[key];
@@ -709,6 +713,7 @@ function MessageBubble({
709
713
  () => isUser ? { payload: null, text: message.content } : extractStructuredPayload(message.content),
710
714
  [isUser, message.content]
711
715
  );
716
+ const shouldRenderStructuredOnly = !isUser && Boolean(structuredContent.payload) && isLikelyUiOnlyMessage(structuredContent.text);
712
717
  const productsFromSources = React5.useMemo(() => {
713
718
  if (isUser || !sources) return [];
714
719
  return sources.filter((s) => {
@@ -971,7 +976,7 @@ ${match.trim()}
971
976
  onAddToCart,
972
977
  viewportSize
973
978
  }
974
- ), /* @__PURE__ */ React5.createElement(ReactMarkdown, { remarkPlugins: [remarkGfm], components: markdownComponents }, processedMarkdown), isStreaming && message.content && /* @__PURE__ */ React5.createElement("span", { className: "inline-block w-1.5 h-3.5 ml-1 bg-emerald-500 animate-pulse align-middle" }))
979
+ ), !shouldRenderStructuredOnly && /* @__PURE__ */ React5.createElement(ReactMarkdown, { remarkPlugins: [remarkGfm], components: markdownComponents }, processedMarkdown), isStreaming && message.content && /* @__PURE__ */ React5.createElement("span", { className: "inline-block w-1.5 h-3.5 ml-1 bg-emerald-500 animate-pulse align-middle" }))
975
980
  ), !isUser && !hasStructuredProductBlock && allProducts.length > 0 && /* @__PURE__ */ React5.createElement("div", { className: "w-full mt-1" }, /* @__PURE__ */ React5.createElement(
976
981
  ProductCarousel,
977
982
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@retrivora-ai/rag-engine",
3
- "version": "1.6.2",
3
+ "version": "1.6.3",
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",
@@ -193,6 +193,11 @@ function extractStructuredPayload(raw: string): { payload: string | null; text:
193
193
  };
194
194
  }
195
195
 
196
+ function isLikelyUiOnlyMessage(text: string): boolean {
197
+ const trimmed = text.trim();
198
+ return trimmed.length === 0 || /^(chart data|table data|visualization|visual representation)\s*:?\s*$/i.test(trimmed);
199
+ }
200
+
196
201
  // ─── Tiny helpers ─────────────────────────────────────────────────────────────
197
202
 
198
203
  function resolveImage(data: Record<string, unknown>): string | undefined {
@@ -584,6 +589,7 @@ export function MessageBubble({
584
589
  () => isUser ? { payload: null, text: message.content } : extractStructuredPayload(message.content),
585
590
  [isUser, message.content],
586
591
  );
592
+ const shouldRenderStructuredOnly = !isUser && Boolean(structuredContent.payload) && isLikelyUiOnlyMessage(structuredContent.text);
587
593
 
588
594
  // ── Products from sources ──────────────────────────────────────────────────
589
595
  const productsFromSources = React.useMemo<Product[]>(() => {
@@ -903,9 +909,11 @@ export function MessageBubble({
903
909
  />
904
910
  )}
905
911
 
906
- <ReactMarkdown remarkPlugins={[remarkGfm]} components={markdownComponents}>
907
- {processedMarkdown}
908
- </ReactMarkdown>
912
+ {!shouldRenderStructuredOnly && (
913
+ <ReactMarkdown remarkPlugins={[remarkGfm]} components={markdownComponents}>
914
+ {processedMarkdown}
915
+ </ReactMarkdown>
916
+ )}
909
917
 
910
918
  {isStreaming && message.content && (
911
919
  <span className="inline-block w-1.5 h-3.5 ml-1 bg-emerald-500 animate-pulse align-middle" />