@retrivora-ai/rag-engine 1.2.4 → 1.2.6

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.
@@ -1699,7 +1699,10 @@ Sources Used: ${JSON.stringify(
1699
1699
  When presenting structured data, statistics, or comparisons, decide if it is best presented as a table or a chart.
1700
1700
  - For tables: use standard Markdown tables.
1701
1701
  - For charts (bar, line, pie): Output a JSON code block with language 'chart'.
1702
- - CRITICAL: Use ONLY valid JSON (double quotes, no trailing commas).
1702
+ - CRITICAL RULES:
1703
+ 1. Use ONLY valid JSON (double quotes, no trailing commas).
1704
+ 2. NO math expressions (e.g., use 100, NOT 50+50).
1705
+ 3. dataKeys MUST exactly match the property names in the data objects.
1703
1706
  \`\`\`chart
1704
1707
  {
1705
1708
  "type": "bar" | "line" | "pie",
@@ -2257,7 +2260,10 @@ var Pipeline = class {
2257
2260
  When presenting structured data, statistics, or comparisons, decide if it is best presented as a table or a chart.
2258
2261
  - For tables: use standard Markdown tables.
2259
2262
  - For charts (bar, line, pie): Output a JSON code block with language 'chart'.
2260
- - CRITICAL: Use ONLY valid JSON (double quotes, no trailing commas).
2263
+ - CRITICAL RULES:
2264
+ 1. Use ONLY valid JSON (double quotes, no trailing commas).
2265
+ 2. NO math expressions (e.g., use 100, NOT 50+50).
2266
+ 3. dataKeys MUST exactly match the property names in the data objects.
2261
2267
  \`\`\`chart
2262
2268
  {
2263
2269
  "type": "bar" | "line" | "pie",
@@ -3268,7 +3268,10 @@ Sources Used: ${JSON.stringify(
3268
3268
  When presenting structured data, statistics, or comparisons, decide if it is best presented as a table or a chart.
3269
3269
  - For tables: use standard Markdown tables.
3270
3270
  - For charts (bar, line, pie): Output a JSON code block with language 'chart'.
3271
- - CRITICAL: Use ONLY valid JSON (double quotes, no trailing commas).
3271
+ - CRITICAL RULES:
3272
+ 1. Use ONLY valid JSON (double quotes, no trailing commas).
3273
+ 2. NO math expressions (e.g., use 100, NOT 50+50).
3274
+ 3. dataKeys MUST exactly match the property names in the data objects.
3272
3275
  \`\`\`chart
3273
3276
  {
3274
3277
  "type": "bar" | "line" | "pie",
@@ -3820,7 +3823,10 @@ var Pipeline = class {
3820
3823
  When presenting structured data, statistics, or comparisons, decide if it is best presented as a table or a chart.
3821
3824
  - For tables: use standard Markdown tables.
3822
3825
  - For charts (bar, line, pie): Output a JSON code block with language 'chart'.
3823
- - CRITICAL: Use ONLY valid JSON (double quotes, no trailing commas).
3826
+ - CRITICAL RULES:
3827
+ 1. Use ONLY valid JSON (double quotes, no trailing commas).
3828
+ 2. NO math expressions (e.g., use 100, NOT 50+50).
3829
+ 3. dataKeys MUST exactly match the property names in the data objects.
3824
3830
  \`\`\`chart
3825
3831
  {
3826
3832
  "type": "bar" | "line" | "pie",
@@ -9,7 +9,7 @@ import {
9
9
  sseFrame,
10
10
  sseMetaFrame,
11
11
  sseTextFrame
12
- } from "../chunk-X4TMJV23.mjs";
12
+ } from "../chunk-6WBJNJ5M.mjs";
13
13
  import "../chunk-YLTMFW4M.mjs";
14
14
  import "../chunk-X4TOT24V.mjs";
15
15
  export {
package/dist/index.js CHANGED
@@ -228,7 +228,7 @@ function DynamicChart({ config, primaryColor = "#6366f1", accentColor = "#8b5cf6
228
228
  }
229
229
  if (type === "pie") {
230
230
  const pieDataKey = dataKeys[0] || Object.keys(data[0]).find((k) => k !== xAxisKey) || "value";
231
- return /* @__PURE__ */ import_react4.default.createElement("div", { className: "w-full h-64 mt-4 mb-2 select-none" }, /* @__PURE__ */ import_react4.default.createElement(import_recharts.ResponsiveContainer, { width: "100%", height: "100%" }, /* @__PURE__ */ import_react4.default.createElement(import_recharts.PieChart, null, /* @__PURE__ */ import_react4.default.createElement(
231
+ return /* @__PURE__ */ import_react4.default.createElement("div", { className: "w-full h-72 min-h-[280px] mt-4 mb-2 select-none overflow-hidden" }, /* @__PURE__ */ import_react4.default.createElement(import_recharts.ResponsiveContainer, { width: "99%", height: "100%" }, /* @__PURE__ */ import_react4.default.createElement(import_recharts.PieChart, null, /* @__PURE__ */ import_react4.default.createElement(
232
232
  import_recharts.Pie,
233
233
  {
234
234
  data,
@@ -247,7 +247,7 @@ function DynamicChart({ config, primaryColor = "#6366f1", accentColor = "#8b5cf6
247
247
  }
248
248
  ), /* @__PURE__ */ import_react4.default.createElement(import_recharts.Legend, null))));
249
249
  }
250
- return /* @__PURE__ */ import_react4.default.createElement("div", { className: "w-full h-64 mt-4 mb-2 select-none" }, /* @__PURE__ */ import_react4.default.createElement(import_recharts.ResponsiveContainer, { width: "100%", height: "100%" }, type === "bar" ? /* @__PURE__ */ import_react4.default.createElement(import_recharts.BarChart, { data, margin: { top: 10, right: 10, left: -20, bottom: 0 } }, /* @__PURE__ */ import_react4.default.createElement(import_recharts.CartesianGrid, { strokeDasharray: "3 3", vertical: false, stroke: "#e2e8f0" }), /* @__PURE__ */ import_react4.default.createElement(import_recharts.XAxis, { dataKey: xAxisKey, tick: { fontSize: 12, fill: "#64748b" }, tickLine: false, axisLine: { stroke: "#cbd5e1" } }), /* @__PURE__ */ import_react4.default.createElement(import_recharts.YAxis, { tick: { fontSize: 12, fill: "#64748b" }, tickLine: false, axisLine: false }), /* @__PURE__ */ import_react4.default.createElement(
250
+ return /* @__PURE__ */ import_react4.default.createElement("div", { className: "w-full h-72 min-h-[280px] mt-4 mb-2 select-none overflow-hidden" }, /* @__PURE__ */ import_react4.default.createElement(import_recharts.ResponsiveContainer, { width: "99%", height: "100%" }, type === "bar" ? /* @__PURE__ */ import_react4.default.createElement(import_recharts.BarChart, { data, margin: { top: 10, right: 10, left: -20, bottom: 0 } }, /* @__PURE__ */ import_react4.default.createElement(import_recharts.CartesianGrid, { strokeDasharray: "3 3", vertical: false, stroke: "#e2e8f0" }), /* @__PURE__ */ import_react4.default.createElement(import_recharts.XAxis, { dataKey: xAxisKey, tick: { fontSize: 12, fill: "#64748b" }, tickLine: false, axisLine: { stroke: "#cbd5e1" } }), /* @__PURE__ */ import_react4.default.createElement(import_recharts.YAxis, { tick: { fontSize: 12, fill: "#64748b" }, tickLine: false, axisLine: false }), /* @__PURE__ */ import_react4.default.createElement(
251
251
  import_recharts.Tooltip,
252
252
  {
253
253
  contentStyle: { borderRadius: "8px", border: "none", boxShadow: "0 4px 6px -1px rgb(0 0 0 / 0.1)" },
@@ -402,9 +402,13 @@ function MessageBubble({
402
402
  const match = /language-(\w+)/.exec(className || "");
403
403
  const isChart = match && match[1] === "chart";
404
404
  if (!inline && isChart) {
405
- const rawContent = String(children).trim();
405
+ let rawContent = String(children).trim();
406
+ const sanitizeJson = (json) => {
407
+ return json.replace(/:\s*(\d+)\s*\+\s*(\d+)/g, (_, a, b) => `: ${Number(a) + Number(b)}`).replace(/,\s*""\s*,/g, ",").replace(/\{\s*""\s*,/g, "{").replace(/,\s*""\s*\}/g, "}");
408
+ };
406
409
  try {
407
- const config = JSON.parse(rawContent);
410
+ const sanitized = sanitizeJson(rawContent);
411
+ const config = JSON.parse(sanitized);
408
412
  return /* @__PURE__ */ import_react5.default.createElement("div", { className: "my-4 p-4 bg-white dark:bg-slate-900 rounded-xl border border-slate-200 dark:border-white/10 shadow-sm" }, /* @__PURE__ */ import_react5.default.createElement(
409
413
  DynamicChart,
410
414
  {
@@ -414,7 +418,7 @@ function MessageBubble({
414
418
  }
415
419
  ));
416
420
  } catch (err) {
417
- console.error("[MessageBubble] Chart parsing failed:", err, "\nRaw content:", rawContent);
421
+ console.error("[MessageBubble] Chart parsing failed:", err, "\nSanitized content:", sanitizeJson(rawContent));
418
422
  return /* @__PURE__ */ import_react5.default.createElement("div", { className: "p-4 bg-red-50 dark:bg-red-900/20 text-red-600 dark:text-red-400 rounded-lg text-sm border border-red-100 dark:border-red-900/30" }, /* @__PURE__ */ import_react5.default.createElement("p", { className: "font-medium mb-1" }, "Failed to render chart"), /* @__PURE__ */ import_react5.default.createElement("p", { className: "opacity-70 text-xs" }, "The generated configuration is invalid. Check console for details."));
419
423
  }
420
424
  }
package/dist/index.mjs CHANGED
@@ -191,7 +191,7 @@ function DynamicChart({ config, primaryColor = "#6366f1", accentColor = "#8b5cf6
191
191
  }
192
192
  if (type === "pie") {
193
193
  const pieDataKey = dataKeys[0] || Object.keys(data[0]).find((k) => k !== xAxisKey) || "value";
194
- return /* @__PURE__ */ React4.createElement("div", { className: "w-full h-64 mt-4 mb-2 select-none" }, /* @__PURE__ */ React4.createElement(ResponsiveContainer, { width: "100%", height: "100%" }, /* @__PURE__ */ React4.createElement(PieChart, null, /* @__PURE__ */ React4.createElement(
194
+ return /* @__PURE__ */ React4.createElement("div", { className: "w-full h-72 min-h-[280px] mt-4 mb-2 select-none overflow-hidden" }, /* @__PURE__ */ React4.createElement(ResponsiveContainer, { width: "99%", height: "100%" }, /* @__PURE__ */ React4.createElement(PieChart, null, /* @__PURE__ */ React4.createElement(
195
195
  Pie,
196
196
  {
197
197
  data,
@@ -210,7 +210,7 @@ function DynamicChart({ config, primaryColor = "#6366f1", accentColor = "#8b5cf6
210
210
  }
211
211
  ), /* @__PURE__ */ React4.createElement(Legend, null))));
212
212
  }
213
- return /* @__PURE__ */ React4.createElement("div", { className: "w-full h-64 mt-4 mb-2 select-none" }, /* @__PURE__ */ React4.createElement(ResponsiveContainer, { width: "100%", height: "100%" }, type === "bar" ? /* @__PURE__ */ React4.createElement(BarChart, { data, margin: { top: 10, right: 10, left: -20, bottom: 0 } }, /* @__PURE__ */ React4.createElement(CartesianGrid, { strokeDasharray: "3 3", vertical: false, stroke: "#e2e8f0" }), /* @__PURE__ */ React4.createElement(XAxis, { dataKey: xAxisKey, tick: { fontSize: 12, fill: "#64748b" }, tickLine: false, axisLine: { stroke: "#cbd5e1" } }), /* @__PURE__ */ React4.createElement(YAxis, { tick: { fontSize: 12, fill: "#64748b" }, tickLine: false, axisLine: false }), /* @__PURE__ */ React4.createElement(
213
+ return /* @__PURE__ */ React4.createElement("div", { className: "w-full h-72 min-h-[280px] mt-4 mb-2 select-none overflow-hidden" }, /* @__PURE__ */ React4.createElement(ResponsiveContainer, { width: "99%", height: "100%" }, type === "bar" ? /* @__PURE__ */ React4.createElement(BarChart, { data, margin: { top: 10, right: 10, left: -20, bottom: 0 } }, /* @__PURE__ */ React4.createElement(CartesianGrid, { strokeDasharray: "3 3", vertical: false, stroke: "#e2e8f0" }), /* @__PURE__ */ React4.createElement(XAxis, { dataKey: xAxisKey, tick: { fontSize: 12, fill: "#64748b" }, tickLine: false, axisLine: { stroke: "#cbd5e1" } }), /* @__PURE__ */ React4.createElement(YAxis, { tick: { fontSize: 12, fill: "#64748b" }, tickLine: false, axisLine: false }), /* @__PURE__ */ React4.createElement(
214
214
  Tooltip,
215
215
  {
216
216
  contentStyle: { borderRadius: "8px", border: "none", boxShadow: "0 4px 6px -1px rgb(0 0 0 / 0.1)" },
@@ -365,9 +365,13 @@ function MessageBubble({
365
365
  const match = /language-(\w+)/.exec(className || "");
366
366
  const isChart = match && match[1] === "chart";
367
367
  if (!inline && isChart) {
368
- const rawContent = String(children).trim();
368
+ let rawContent = String(children).trim();
369
+ const sanitizeJson = (json) => {
370
+ return json.replace(/:\s*(\d+)\s*\+\s*(\d+)/g, (_, a, b) => `: ${Number(a) + Number(b)}`).replace(/,\s*""\s*,/g, ",").replace(/\{\s*""\s*,/g, "{").replace(/,\s*""\s*\}/g, "}");
371
+ };
369
372
  try {
370
- const config = JSON.parse(rawContent);
373
+ const sanitized = sanitizeJson(rawContent);
374
+ const config = JSON.parse(sanitized);
371
375
  return /* @__PURE__ */ React5.createElement("div", { className: "my-4 p-4 bg-white dark:bg-slate-900 rounded-xl border border-slate-200 dark:border-white/10 shadow-sm" }, /* @__PURE__ */ React5.createElement(
372
376
  DynamicChart,
373
377
  {
@@ -377,7 +381,7 @@ function MessageBubble({
377
381
  }
378
382
  ));
379
383
  } catch (err) {
380
- console.error("[MessageBubble] Chart parsing failed:", err, "\nRaw content:", rawContent);
384
+ console.error("[MessageBubble] Chart parsing failed:", err, "\nSanitized content:", sanitizeJson(rawContent));
381
385
  return /* @__PURE__ */ React5.createElement("div", { className: "p-4 bg-red-50 dark:bg-red-900/20 text-red-600 dark:text-red-400 rounded-lg text-sm border border-red-100 dark:border-red-900/30" }, /* @__PURE__ */ React5.createElement("p", { className: "font-medium mb-1" }, "Failed to render chart"), /* @__PURE__ */ React5.createElement("p", { className: "opacity-70 text-xs" }, "The generated configuration is invalid. Check console for details."));
382
386
  }
383
387
  }
package/dist/server.js CHANGED
@@ -3353,7 +3353,10 @@ Sources Used: ${JSON.stringify(
3353
3353
  When presenting structured data, statistics, or comparisons, decide if it is best presented as a table or a chart.
3354
3354
  - For tables: use standard Markdown tables.
3355
3355
  - For charts (bar, line, pie): Output a JSON code block with language 'chart'.
3356
- - CRITICAL: Use ONLY valid JSON (double quotes, no trailing commas).
3356
+ - CRITICAL RULES:
3357
+ 1. Use ONLY valid JSON (double quotes, no trailing commas).
3358
+ 2. NO math expressions (e.g., use 100, NOT 50+50).
3359
+ 3. dataKeys MUST exactly match the property names in the data objects.
3357
3360
  \`\`\`chart
3358
3361
  {
3359
3362
  "type": "bar" | "line" | "pie",
@@ -3911,7 +3914,10 @@ var Pipeline = class {
3911
3914
  When presenting structured data, statistics, or comparisons, decide if it is best presented as a table or a chart.
3912
3915
  - For tables: use standard Markdown tables.
3913
3916
  - For charts (bar, line, pie): Output a JSON code block with language 'chart'.
3914
- - CRITICAL: Use ONLY valid JSON (double quotes, no trailing commas).
3917
+ - CRITICAL RULES:
3918
+ 1. Use ONLY valid JSON (double quotes, no trailing commas).
3919
+ 2. NO math expressions (e.g., use 100, NOT 50+50).
3920
+ 3. dataKeys MUST exactly match the property names in the data objects.
3915
3921
  \`\`\`chart
3916
3922
  {
3917
3923
  "type": "bar" | "line" | "pie",
package/dist/server.mjs CHANGED
@@ -39,7 +39,7 @@ import {
39
39
  sseFrame,
40
40
  sseMetaFrame,
41
41
  sseTextFrame
42
- } from "./chunk-X4TMJV23.mjs";
42
+ } from "./chunk-6WBJNJ5M.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.2.4",
3
+ "version": "1.2.6",
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",
@@ -35,8 +35,8 @@ export function DynamicChart({ config, primaryColor = '#6366f1', accentColor = '
35
35
  const pieDataKey = dataKeys[0] || Object.keys(data[0]).find(k => k !== xAxisKey) || 'value';
36
36
 
37
37
  return (
38
- <div className="w-full h-64 mt-4 mb-2 select-none">
39
- <ResponsiveContainer width="100%" height="100%">
38
+ <div className="w-full h-72 min-h-[280px] mt-4 mb-2 select-none overflow-hidden">
39
+ <ResponsiveContainer width="99%" height="100%">
40
40
  <PieChart>
41
41
  <Pie
42
42
  data={data}
@@ -63,8 +63,8 @@ export function DynamicChart({ config, primaryColor = '#6366f1', accentColor = '
63
63
 
64
64
  // Bar and Line charts
65
65
  return (
66
- <div className="w-full h-64 mt-4 mb-2 select-none">
67
- <ResponsiveContainer width="100%" height="100%">
66
+ <div className="w-full h-72 min-h-[280px] mt-4 mb-2 select-none overflow-hidden">
67
+ <ResponsiveContainer width="99%" height="100%">
68
68
  {type === 'bar' ? (
69
69
  <BarChart data={data} margin={{ top: 10, right: 10, left: -20, bottom: 0 }}>
70
70
  <CartesianGrid strokeDasharray="3 3" vertical={false} stroke="#e2e8f0" />
@@ -178,10 +178,22 @@ export function MessageBubble({
178
178
  const isChart = match && match[1] === 'chart';
179
179
 
180
180
  if (!inline && isChart) {
181
- const rawContent = String(children).trim();
181
+ let rawContent = String(children).trim();
182
+
183
+ // Sanitization helper to handle LLM quirks
184
+ const sanitizeJson = (json: string) => {
185
+ return json
186
+ // 1. Resolve simple math: "value": 10 + 20 => "value": 30
187
+ .replace(/:\s*(\d+)\s*\+\s*(\d+)/g, (_, a, b) => `: ${Number(a) + Number(b)}`)
188
+ // 2. Remove dangling empty strings: "key": "val", "", "other": "val" => "key": "val", "other": "val"
189
+ .replace(/,\s*""\s*,/g, ',')
190
+ .replace(/\{\s*""\s*,/g, '{')
191
+ .replace(/,\s*""\s*\}/g, '}');
192
+ };
193
+
182
194
  try {
183
- // Attempt to parse the JSON
184
- const config = JSON.parse(rawContent) as ChartConfig;
195
+ const sanitized = sanitizeJson(rawContent);
196
+ const config = JSON.parse(sanitized) as ChartConfig;
185
197
  return (
186
198
  <div className="my-4 p-4 bg-white dark:bg-slate-900 rounded-xl border border-slate-200 dark:border-white/10 shadow-sm">
187
199
  <DynamicChart
@@ -192,7 +204,7 @@ export function MessageBubble({
192
204
  </div>
193
205
  );
194
206
  } catch (err) {
195
- console.error('[MessageBubble] Chart parsing failed:', err, '\nRaw content:', rawContent);
207
+ console.error('[MessageBubble] Chart parsing failed:', err, '\nSanitized content:', sanitizeJson(rawContent));
196
208
  return (
197
209
  <div className="p-4 bg-red-50 dark:bg-red-900/20 text-red-600 dark:text-red-400 rounded-lg text-sm border border-red-100 dark:border-red-900/30">
198
210
  <p className="font-medium mb-1">Failed to render chart</p>
@@ -53,7 +53,10 @@ export class LangChainAgent {
53
53
  const chartInstruction = `\n\nWhen presenting structured data, statistics, or comparisons, decide if it is best presented as a table or a chart.
54
54
  - For tables: use standard Markdown tables.
55
55
  - For charts (bar, line, pie): Output a JSON code block with language 'chart'.
56
- - CRITICAL: Use ONLY valid JSON (double quotes, no trailing commas).
56
+ - CRITICAL RULES:
57
+ 1. Use ONLY valid JSON (double quotes, no trailing commas).
58
+ 2. NO math expressions (e.g., use 100, NOT 50+50).
59
+ 3. dataKeys MUST exactly match the property names in the data objects.
57
60
  \`\`\`chart
58
61
  {
59
62
  "type": "bar" | "line" | "pie",
@@ -103,7 +103,10 @@ export class Pipeline {
103
103
  const chartInstruction = `\n\nWhen presenting structured data, statistics, or comparisons, decide if it is best presented as a table or a chart.
104
104
  - For tables: use standard Markdown tables.
105
105
  - For charts (bar, line, pie): Output a JSON code block with language 'chart'.
106
- - CRITICAL: Use ONLY valid JSON (double quotes, no trailing commas).
106
+ - CRITICAL RULES:
107
+ 1. Use ONLY valid JSON (double quotes, no trailing commas).
108
+ 2. NO math expressions (e.g., use 100, NOT 50+50).
109
+ 3. dataKeys MUST exactly match the property names in the data objects.
107
110
  \`\`\`chart
108
111
  {
109
112
  "type": "bar" | "line" | "pie",