@retrivora-ai/rag-engine 1.2.6 → 1.2.7
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 +2 -2
- package/dist/index.mjs +2 -2
- package/package.json +1 -1
- package/src/components/MessageBubble.tsx +5 -2
package/dist/index.js
CHANGED
|
@@ -402,9 +402,9 @@ function MessageBubble({
|
|
|
402
402
|
const match = /language-(\w+)/.exec(className || "");
|
|
403
403
|
const isChart = match && match[1] === "chart";
|
|
404
404
|
if (!inline && isChart) {
|
|
405
|
-
|
|
405
|
+
const rawContent = String(children).trim();
|
|
406
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, "}");
|
|
407
|
+
return json.replace(/:\s*(\d+)\s*\+\s*(\d+)/g, (_, a, b) => `: ${Number(a) + Number(b)}`).replace(/([{,])\s*([a-zA-Z_][a-zA-Z0-9_]*)\s*:/g, '$1 "$2":').replace(/,\s*""\s*,/g, ",").replace(/\{\s*""\s*,/g, "{").replace(/,\s*""\s*\}/g, "}");
|
|
408
408
|
};
|
|
409
409
|
try {
|
|
410
410
|
const sanitized = sanitizeJson(rawContent);
|
package/dist/index.mjs
CHANGED
|
@@ -365,9 +365,9 @@ function MessageBubble({
|
|
|
365
365
|
const match = /language-(\w+)/.exec(className || "");
|
|
366
366
|
const isChart = match && match[1] === "chart";
|
|
367
367
|
if (!inline && isChart) {
|
|
368
|
-
|
|
368
|
+
const rawContent = String(children).trim();
|
|
369
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, "}");
|
|
370
|
+
return json.replace(/:\s*(\d+)\s*\+\s*(\d+)/g, (_, a, b) => `: ${Number(a) + Number(b)}`).replace(/([{,])\s*([a-zA-Z_][a-zA-Z0-9_]*)\s*:/g, '$1 "$2":').replace(/,\s*""\s*,/g, ",").replace(/\{\s*""\s*,/g, "{").replace(/,\s*""\s*\}/g, "}");
|
|
371
371
|
};
|
|
372
372
|
try {
|
|
373
373
|
const sanitized = sanitizeJson(rawContent);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@retrivora-ai/rag-engine",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.7",
|
|
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",
|
|
@@ -178,14 +178,17 @@ export function MessageBubble({
|
|
|
178
178
|
const isChart = match && match[1] === 'chart';
|
|
179
179
|
|
|
180
180
|
if (!inline && isChart) {
|
|
181
|
-
|
|
181
|
+
const rawContent = String(children).trim();
|
|
182
182
|
|
|
183
183
|
// Sanitization helper to handle LLM quirks
|
|
184
184
|
const sanitizeJson = (json: string) => {
|
|
185
185
|
return json
|
|
186
186
|
// 1. Resolve simple math: "value": 10 + 20 => "value": 30
|
|
187
187
|
.replace(/:\s*(\d+)\s*\+\s*(\d+)/g, (_, a, b) => `: ${Number(a) + Number(b)}`)
|
|
188
|
-
// 2.
|
|
188
|
+
// 2. Quote unquoted keys: { Category: "val" } => { "Category": "val" }
|
|
189
|
+
// Matches a word followed by a colon, but not inside a string
|
|
190
|
+
.replace(/([{,])\s*([a-zA-Z_][a-zA-Z0-9_]*)\s*:/g, '$1 "$2":')
|
|
191
|
+
// 3. Remove dangling empty strings
|
|
189
192
|
.replace(/,\s*""\s*,/g, ',')
|
|
190
193
|
.replace(/\{\s*""\s*,/g, '{')
|
|
191
194
|
.replace(/,\s*""\s*\}/g, '}');
|