@retrivora-ai/rag-engine 1.4.9 → 1.5.1

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,18 +2263,14 @@ var Pipeline = class {
2263
2263
  const chartInstruction = `
2264
2264
 
2265
2265
  ${CHART_MARKER}
2266
- ### MASTER DATA VISUALIZATION PROTOCOL:
2267
- You are an expert data analyst. When asked to visualize or compare data retrieved from the context:
2268
- 1. DECIDE the best chart type: 'pie' (for parts-of-a-whole), 'bar' (for category comparisons), or 'line' (for trends).
2269
- 2. TRANSFORM arbitrary metadata from the context into a FLAT list of objects. Extract relevant keys dynamically.
2270
- 3. OUTPUT a \`\`\`chart\`\`\` code block using this JSON format:
2271
- {
2272
- "type": "bar" | "line" | "pie",
2273
- "xAxisKey": "key_for_labels",
2274
- "dataKeys": ["key_for_values"],
2275
- "data": [ { "key_for_labels": "Category A", "key_for_values": 100 }, ... ]
2276
- }
2277
- 4. RULES: Valid JSON only. No math. No text-based charts. No markdown tables for graphs. If showing a chart, DO NOT output a "products" JSON carousel.`;
2266
+ ### DATA REPRESENTATION TOOLBOX:
2267
+ You have two specialized formats for structured data. Choose the one (or both) that provides the most value to the user:
2268
+ 1. \`\`\`chart\`\`\` block: Best for statistics, distributions, and comparisons.
2269
+ Format: { "type": "bar" | "line" | "pie", "data": [ { "label": "X", "value": 10 } ] }
2270
+ 2. \`\`\`json\`\`\` (products) block: Best for listing or browsing specific items.
2271
+ Format: { "type": "products", "data": [...] }
2272
+
2273
+ RULES: Output MUST be valid JSON. Data objects MUST be FLAT. Never draw charts with text or markdown tables.`;
2278
2274
  if (!((_a = this.config.llm.systemPrompt) == null ? void 0 : _a.includes(CHART_MARKER))) {
2279
2275
  this.config.llm.systemPrompt = (this.config.llm.systemPrompt || "") + chartInstruction;
2280
2276
  }
@@ -3826,18 +3826,14 @@ var Pipeline = class {
3826
3826
  const chartInstruction = `
3827
3827
 
3828
3828
  ${CHART_MARKER}
3829
- ### MASTER DATA VISUALIZATION PROTOCOL:
3830
- You are an expert data analyst. When asked to visualize or compare data retrieved from the context:
3831
- 1. DECIDE the best chart type: 'pie' (for parts-of-a-whole), 'bar' (for category comparisons), or 'line' (for trends).
3832
- 2. TRANSFORM arbitrary metadata from the context into a FLAT list of objects. Extract relevant keys dynamically.
3833
- 3. OUTPUT a \`\`\`chart\`\`\` code block using this JSON format:
3834
- {
3835
- "type": "bar" | "line" | "pie",
3836
- "xAxisKey": "key_for_labels",
3837
- "dataKeys": ["key_for_values"],
3838
- "data": [ { "key_for_labels": "Category A", "key_for_values": 100 }, ... ]
3839
- }
3840
- 4. RULES: Valid JSON only. No math. No text-based charts. No markdown tables for graphs. If showing a chart, DO NOT output a "products" JSON carousel.`;
3829
+ ### DATA REPRESENTATION TOOLBOX:
3830
+ You have two specialized formats for structured data. Choose the one (or both) that provides the most value to the user:
3831
+ 1. \`\`\`chart\`\`\` block: Best for statistics, distributions, and comparisons.
3832
+ Format: { "type": "bar" | "line" | "pie", "data": [ { "label": "X", "value": 10 } ] }
3833
+ 2. \`\`\`json\`\`\` (products) block: Best for listing or browsing specific items.
3834
+ Format: { "type": "products", "data": [...] }
3835
+
3836
+ RULES: Output MUST be valid JSON. Data objects MUST be FLAT. Never draw charts with text or markdown tables.`;
3841
3837
  if (!((_a = this.config.llm.systemPrompt) == null ? void 0 : _a.includes(CHART_MARKER))) {
3842
3838
  this.config.llm.systemPrompt = (this.config.llm.systemPrompt || "") + chartInstruction;
3843
3839
  }
@@ -9,7 +9,7 @@ import {
9
9
  sseFrame,
10
10
  sseMetaFrame,
11
11
  sseTextFrame
12
- } from "../chunk-FHNGNXXS.mjs";
12
+ } from "../chunk-NXEX6XM6.mjs";
13
13
  import "../chunk-YLTMFW4M.mjs";
14
14
  import "../chunk-X4TOT24V.mjs";
15
15
  export {
package/dist/index.js CHANGED
@@ -504,9 +504,7 @@ function MessageBubble({
504
504
  });
505
505
  }, [sources, isUser]);
506
506
  const { productsFromContent, cleanContent } = import_react5.default.useMemo(() => {
507
- if (isUser) return { productsFromContent: [], cleanContent: message.content };
508
- const isVisualization = message.content.includes("```chart") || message.content.toLowerCase().includes("pie chart") || message.content.toLowerCase().includes("bar chart") || message.content.toLowerCase().includes("distribution");
509
- if (isVisualization) {
507
+ if (isUser) {
510
508
  return { productsFromContent: [], cleanContent: message.content };
511
509
  }
512
510
  const jsonRegex = /```json\s*([\s\S]*?)\s*```/g;
package/dist/index.mjs CHANGED
@@ -467,9 +467,7 @@ function MessageBubble({
467
467
  });
468
468
  }, [sources, isUser]);
469
469
  const { productsFromContent, cleanContent } = React5.useMemo(() => {
470
- if (isUser) return { productsFromContent: [], cleanContent: message.content };
471
- const isVisualization = message.content.includes("```chart") || message.content.toLowerCase().includes("pie chart") || message.content.toLowerCase().includes("bar chart") || message.content.toLowerCase().includes("distribution");
472
- if (isVisualization) {
470
+ if (isUser) {
473
471
  return { productsFromContent: [], cleanContent: message.content };
474
472
  }
475
473
  const jsonRegex = /```json\s*([\s\S]*?)\s*```/g;
package/dist/server.js CHANGED
@@ -3917,18 +3917,14 @@ var Pipeline = class {
3917
3917
  const chartInstruction = `
3918
3918
 
3919
3919
  ${CHART_MARKER}
3920
- ### MASTER DATA VISUALIZATION PROTOCOL:
3921
- You are an expert data analyst. When asked to visualize or compare data retrieved from the context:
3922
- 1. DECIDE the best chart type: 'pie' (for parts-of-a-whole), 'bar' (for category comparisons), or 'line' (for trends).
3923
- 2. TRANSFORM arbitrary metadata from the context into a FLAT list of objects. Extract relevant keys dynamically.
3924
- 3. OUTPUT a \`\`\`chart\`\`\` code block using this JSON format:
3925
- {
3926
- "type": "bar" | "line" | "pie",
3927
- "xAxisKey": "key_for_labels",
3928
- "dataKeys": ["key_for_values"],
3929
- "data": [ { "key_for_labels": "Category A", "key_for_values": 100 }, ... ]
3930
- }
3931
- 4. RULES: Valid JSON only. No math. No text-based charts. No markdown tables for graphs. If showing a chart, DO NOT output a "products" JSON carousel.`;
3920
+ ### DATA REPRESENTATION TOOLBOX:
3921
+ You have two specialized formats for structured data. Choose the one (or both) that provides the most value to the user:
3922
+ 1. \`\`\`chart\`\`\` block: Best for statistics, distributions, and comparisons.
3923
+ Format: { "type": "bar" | "line" | "pie", "data": [ { "label": "X", "value": 10 } ] }
3924
+ 2. \`\`\`json\`\`\` (products) block: Best for listing or browsing specific items.
3925
+ Format: { "type": "products", "data": [...] }
3926
+
3927
+ RULES: Output MUST be valid JSON. Data objects MUST be FLAT. Never draw charts with text or markdown tables.`;
3932
3928
  if (!((_a = this.config.llm.systemPrompt) == null ? void 0 : _a.includes(CHART_MARKER))) {
3933
3929
  this.config.llm.systemPrompt = (this.config.llm.systemPrompt || "") + chartInstruction;
3934
3930
  }
package/dist/server.mjs CHANGED
@@ -39,7 +39,7 @@ import {
39
39
  sseFrame,
40
40
  sseMetaFrame,
41
41
  sseTextFrame
42
- } from "./chunk-FHNGNXXS.mjs";
42
+ } from "./chunk-NXEX6XM6.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.4.9",
3
+ "version": "1.5.1",
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",
@@ -311,16 +311,7 @@ export function MessageBubble({
311
311
 
312
312
  // ── Products + cleaned content from structured JSON blocks in the message ──
313
313
  const { productsFromContent, cleanContent } = React.useMemo(() => {
314
- if (isUser) return { productsFromContent: [] as Product[], cleanContent: message.content };
315
-
316
- // If the message contains a chart or refers to visualization, suppress the product carousel
317
- const isVisualization =
318
- message.content.includes('```chart') ||
319
- message.content.toLowerCase().includes('pie chart') ||
320
- message.content.toLowerCase().includes('bar chart') ||
321
- message.content.toLowerCase().includes('distribution');
322
-
323
- if (isVisualization) {
314
+ if (isUser) {
324
315
  return { productsFromContent: [] as Product[], cleanContent: message.content };
325
316
  }
326
317
 
@@ -103,18 +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 = '<!-- VIZ_PROTOCOL_V1 -->';
105
105
  const chartInstruction = `\n\n${CHART_MARKER}
106
- ### MASTER DATA VISUALIZATION PROTOCOL:
107
- You are an expert data analyst. When asked to visualize or compare data retrieved from the context:
108
- 1. DECIDE the best chart type: 'pie' (for parts-of-a-whole), 'bar' (for category comparisons), or 'line' (for trends).
109
- 2. TRANSFORM arbitrary metadata from the context into a FLAT list of objects. Extract relevant keys dynamically.
110
- 3. OUTPUT a \`\`\`chart\`\`\` code block using this JSON format:
111
- {
112
- "type": "bar" | "line" | "pie",
113
- "xAxisKey": "key_for_labels",
114
- "dataKeys": ["key_for_values"],
115
- "data": [ { "key_for_labels": "Category A", "key_for_values": 100 }, ... ]
116
- }
117
- 4. RULES: Valid JSON only. No math. No text-based charts. No markdown tables for graphs. If showing a chart, DO NOT output a "products" JSON carousel.`;
106
+ ### DATA REPRESENTATION TOOLBOX:
107
+ You have two specialized formats for structured data. Choose the one (or both) that provides the most value to the user:
108
+ 1. \`\`\`chart\`\`\` block: Best for statistics, distributions, and comparisons.
109
+ Format: { "type": "bar" | "line" | "pie", "data": [ { "label": "X", "value": 10 } ] }
110
+ 2. \`\`\`json\`\`\` (products) block: Best for listing or browsing specific items.
111
+ Format: { "type": "products", "data": [...] }
112
+
113
+ RULES: Output MUST be valid JSON. Data objects MUST be FLAT. Never draw charts with text or markdown tables.`;
118
114
 
119
115
  if (!this.config.llm.systemPrompt?.includes(CHART_MARKER)) {
120
116
  this.config.llm.systemPrompt = (this.config.llm.systemPrompt || '') + chartInstruction;