@retrivora-ai/rag-engine 1.6.3 → 1.6.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.
@@ -2263,15 +2263,14 @@ var Pipeline = class {
2263
2263
  const chartInstruction = `
2264
2264
 
2265
2265
  ${CHART_MARKER}
2266
- ### UNIVERSAL UI PROTOCOL
2267
- When the user asks for a visual representation, comparison, distribution, breakdown, table, list, catalog, products, carousel, stock view, or category summary, you MUST include exactly one \`\`\`ui\`\`\` block.
2268
-
2269
- 1. VIEW SELECTION
2270
- - Use "chart" for distributions, percentages, counts, comparisons, trends, or "show me in a chart".
2271
- - Use "carousel" for browseable product recommendations or when the user asks to see products/items/cards.
2272
- - Use "table" for tabular/raw detail, explicit table/list requests, or when there are many attributes to compare.
2273
-
2274
- 2. REQUIRED JSON SHAPE
2266
+ ### UNIVERSAL UI PROTOCOL (EXPERT MODE):
2267
+ You have high-performance graphical capabilities. For any analytical query or product list, you MUST use the \`\`\`ui\`\`\` block.
2268
+ 1. WRAPPING: You MUST wrap the JSON in \`\`\`ui and \`\`\` code markers. NEVER output naked JSON.
2269
+ 2. VIEW SELECTION:
2270
+ - "chart": ALWAYS use this for distributions, percentages, or statistics. You MUST aggregate/count the data yourself.
2271
+ - "carousel": Use for browsing product items.
2272
+ - "table": Use ONLY for raw data details if explicitly asked for a "table" or "list".
2273
+ 3. SCHEMA:
2275
2274
  {
2276
2275
  "view": "chart" | "carousel" | "table",
2277
2276
  "title": "Short heading",
@@ -3826,15 +3826,14 @@ var Pipeline = class {
3826
3826
  const chartInstruction = `
3827
3827
 
3828
3828
  ${CHART_MARKER}
3829
- ### UNIVERSAL UI PROTOCOL
3830
- When the user asks for a visual representation, comparison, distribution, breakdown, table, list, catalog, products, carousel, stock view, or category summary, you MUST include exactly one \`\`\`ui\`\`\` block.
3831
-
3832
- 1. VIEW SELECTION
3833
- - Use "chart" for distributions, percentages, counts, comparisons, trends, or "show me in a chart".
3834
- - Use "carousel" for browseable product recommendations or when the user asks to see products/items/cards.
3835
- - Use "table" for tabular/raw detail, explicit table/list requests, or when there are many attributes to compare.
3836
-
3837
- 2. REQUIRED JSON SHAPE
3829
+ ### UNIVERSAL UI PROTOCOL (EXPERT MODE):
3830
+ You have high-performance graphical capabilities. For any analytical query or product list, you MUST use the \`\`\`ui\`\`\` block.
3831
+ 1. WRAPPING: You MUST wrap the JSON in \`\`\`ui and \`\`\` code markers. NEVER output naked JSON.
3832
+ 2. VIEW SELECTION:
3833
+ - "chart": ALWAYS use this for distributions, percentages, or statistics. You MUST aggregate/count the data yourself.
3834
+ - "carousel": Use for browsing product items.
3835
+ - "table": Use ONLY for raw data details if explicitly asked for a "table" or "list".
3836
+ 3. SCHEMA:
3838
3837
  {
3839
3838
  "view": "chart" | "carousel" | "table",
3840
3839
  "title": "Short heading",
@@ -9,7 +9,7 @@ import {
9
9
  sseFrame,
10
10
  sseMetaFrame,
11
11
  sseTextFrame
12
- } from "../chunk-5K7EU4KW.mjs";
12
+ } from "../chunk-EE2Z4HNW.mjs";
13
13
  import "../chunk-YLTMFW4M.mjs";
14
14
  import "../chunk-X4TOT24V.mjs";
15
15
  export {
package/dist/index.js CHANGED
@@ -838,10 +838,13 @@ function MessageBubble({
838
838
  const hasStructuredUiBlock = Boolean(structuredContent.payload) || /```(?:ui|json|chart)\s*[\s\S]*?"(?:view|chartType|type|data|items|rows|products|results)"\s*:/i.test(raw);
839
839
  raw = raw.replace(/([^\n])\n\|/g, "$1\n\n|").replace(/(\|[^\n]*\|)\n\n+(?=\|)/g, "$1\n");
840
840
  if (!isStreaming) {
841
- raw = raw.replace(/(?:^|\n)\s*\{[\s\S]*\}\s*(?:\n|$)/g, (match) => {
842
- if (match.includes("```")) return match;
841
+ raw = raw.replace(/(\{[\s\S]+?\})(?!\s*```)/g, (match) => {
843
842
  if (!looksLikeStructuredPayload(match)) return match;
844
- const type = match.includes('"view"') || match.includes('"chartType"') || match.includes('"type": "pie"') || match.includes('"type":"pie"') || match.includes('"type": "bar"') || match.includes('"type":"bar"') || match.includes('"type": "line"') || match.includes('"type":"line"') ? "ui" : "json";
843
+ const index = raw.indexOf(match);
844
+ const prefix = raw.substring(0, index);
845
+ const openBlocks = (prefix.match(/```/g) || []).length;
846
+ if (openBlocks % 2 !== 0) return match;
847
+ const type = match.includes('"view"') || match.includes('"chartType"') ? "ui" : "json";
845
848
  return `
846
849
 
847
850
  \`\`\`${type}
package/dist/index.mjs CHANGED
@@ -801,10 +801,13 @@ function MessageBubble({
801
801
  const hasStructuredUiBlock = Boolean(structuredContent.payload) || /```(?:ui|json|chart)\s*[\s\S]*?"(?:view|chartType|type|data|items|rows|products|results)"\s*:/i.test(raw);
802
802
  raw = raw.replace(/([^\n])\n\|/g, "$1\n\n|").replace(/(\|[^\n]*\|)\n\n+(?=\|)/g, "$1\n");
803
803
  if (!isStreaming) {
804
- raw = raw.replace(/(?:^|\n)\s*\{[\s\S]*\}\s*(?:\n|$)/g, (match) => {
805
- if (match.includes("```")) return match;
804
+ raw = raw.replace(/(\{[\s\S]+?\})(?!\s*```)/g, (match) => {
806
805
  if (!looksLikeStructuredPayload(match)) return match;
807
- const type = match.includes('"view"') || match.includes('"chartType"') || match.includes('"type": "pie"') || match.includes('"type":"pie"') || match.includes('"type": "bar"') || match.includes('"type":"bar"') || match.includes('"type": "line"') || match.includes('"type":"line"') ? "ui" : "json";
806
+ const index = raw.indexOf(match);
807
+ const prefix = raw.substring(0, index);
808
+ const openBlocks = (prefix.match(/```/g) || []).length;
809
+ if (openBlocks % 2 !== 0) return match;
810
+ const type = match.includes('"view"') || match.includes('"chartType"') ? "ui" : "json";
808
811
  return `
809
812
 
810
813
  \`\`\`${type}
package/dist/server.js CHANGED
@@ -3917,15 +3917,14 @@ var Pipeline = class {
3917
3917
  const chartInstruction = `
3918
3918
 
3919
3919
  ${CHART_MARKER}
3920
- ### UNIVERSAL UI PROTOCOL
3921
- When the user asks for a visual representation, comparison, distribution, breakdown, table, list, catalog, products, carousel, stock view, or category summary, you MUST include exactly one \`\`\`ui\`\`\` block.
3922
-
3923
- 1. VIEW SELECTION
3924
- - Use "chart" for distributions, percentages, counts, comparisons, trends, or "show me in a chart".
3925
- - Use "carousel" for browseable product recommendations or when the user asks to see products/items/cards.
3926
- - Use "table" for tabular/raw detail, explicit table/list requests, or when there are many attributes to compare.
3927
-
3928
- 2. REQUIRED JSON SHAPE
3920
+ ### UNIVERSAL UI PROTOCOL (EXPERT MODE):
3921
+ You have high-performance graphical capabilities. For any analytical query or product list, you MUST use the \`\`\`ui\`\`\` block.
3922
+ 1. WRAPPING: You MUST wrap the JSON in \`\`\`ui and \`\`\` code markers. NEVER output naked JSON.
3923
+ 2. VIEW SELECTION:
3924
+ - "chart": ALWAYS use this for distributions, percentages, or statistics. You MUST aggregate/count the data yourself.
3925
+ - "carousel": Use for browsing product items.
3926
+ - "table": Use ONLY for raw data details if explicitly asked for a "table" or "list".
3927
+ 3. SCHEMA:
3929
3928
  {
3930
3929
  "view": "chart" | "carousel" | "table",
3931
3930
  "title": "Short heading",
package/dist/server.mjs CHANGED
@@ -39,7 +39,7 @@ import {
39
39
  sseFrame,
40
40
  sseMetaFrame,
41
41
  sseTextFrame
42
- } from "./chunk-5K7EU4KW.mjs";
42
+ } from "./chunk-EE2Z4HNW.mjs";
43
43
  import "./chunk-YLTMFW4M.mjs";
44
44
  import {
45
45
  PineconeProvider
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@retrivora-ai/rag-engine",
3
- "version": "1.6.3",
3
+ "version": "1.6.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",
@@ -698,16 +698,19 @@ export function MessageBubble({
698
698
  .replace(/(\|[^\n]*\|)\n\n+(?=\|)/g, '$1\n'); // Remove blank lines between rows
699
699
 
700
700
  // 2. HEALING: Detect naked JSON charts/products and wrap them if markers are missing
701
- // This handles models (like Llama 3.2) that often omit the ```chart markers.
701
+ // This handles models (like Llama 3.2) that often omit the ```ui markers.
702
702
  if (!isStreaming) {
703
- // Look for objects that look like chart or product data
704
- raw = raw.replace(/(?:^|\n)\s*\{[\s\S]*\}\s*(?:\n|$)/g, (match) => {
705
- // Only wrap if not already in a code block
706
- if (match.includes('```')) return match;
703
+ // Find potential JSON objects that are not already wrapped in code blocks
704
+ raw = raw.replace(/(\{[\s\S]+?\})(?!\s*```)/g, (match) => {
707
705
  if (!looksLikeStructuredPayload(match)) return match;
708
- const type = match.includes('"view"') || match.includes('"chartType"') || match.includes('"type": "pie"') || match.includes('"type":"pie"') || match.includes('"type": "bar"') || match.includes('"type":"bar"') || match.includes('"type": "line"') || match.includes('"type":"line"')
709
- ? 'ui'
710
- : 'json';
706
+
707
+ // Final check: is it already inside a code block? (heuristic check)
708
+ const index = raw.indexOf(match);
709
+ const prefix = raw.substring(0, index);
710
+ const openBlocks = (prefix.match(/```/g) || []).length;
711
+ if (openBlocks % 2 !== 0) return match;
712
+
713
+ const type = match.includes('"view"') || match.includes('"chartType"') ? 'ui' : 'json';
711
714
  return `\n\n\`\`\`${type}\n${match.trim()}\n\`\`\`\n\n`;
712
715
  });
713
716
  }
@@ -103,15 +103,14 @@ export class Pipeline {
103
103
  // We use a unique marker to ensure this is only injected once but is ALWAYS present.
104
104
  const CHART_MARKER = '<!-- UI_PROTOCOL_V5 -->';
105
105
  const chartInstruction = `\n\n${CHART_MARKER}
106
- ### UNIVERSAL UI PROTOCOL
107
- When the user asks for a visual representation, comparison, distribution, breakdown, table, list, catalog, products, carousel, stock view, or category summary, you MUST include exactly one \`\`\`ui\`\`\` block.
108
-
109
- 1. VIEW SELECTION
110
- - Use "chart" for distributions, percentages, counts, comparisons, trends, or "show me in a chart".
111
- - Use "carousel" for browseable product recommendations or when the user asks to see products/items/cards.
112
- - Use "table" for tabular/raw detail, explicit table/list requests, or when there are many attributes to compare.
113
-
114
- 2. REQUIRED JSON SHAPE
106
+ ### UNIVERSAL UI PROTOCOL (EXPERT MODE):
107
+ You have high-performance graphical capabilities. For any analytical query or product list, you MUST use the \`\`\`ui\`\`\` block.
108
+ 1. WRAPPING: You MUST wrap the JSON in \`\`\`ui and \`\`\` code markers. NEVER output naked JSON.
109
+ 2. VIEW SELECTION:
110
+ - "chart": ALWAYS use this for distributions, percentages, or statistics. You MUST aggregate/count the data yourself.
111
+ - "carousel": Use for browsing product items.
112
+ - "table": Use ONLY for raw data details if explicitly asked for a "table" or "list".
113
+ 3. SCHEMA:
115
114
  {
116
115
  "view": "chart" | "carousel" | "table",
117
116
  "title": "Short heading",