@retrivora-ai/rag-engine 1.5.0 → 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.
- package/dist/{chunk-YTL3SLQU.mjs → chunk-NXEX6XM6.mjs} +8 -12
- package/dist/handlers/index.js +8 -12
- package/dist/handlers/index.mjs +1 -1
- package/dist/index.js +2 -7
- package/dist/index.mjs +2 -7
- package/dist/server.js +8 -12
- package/dist/server.mjs +1 -1
- package/package.json +1 -1
- package/src/components/MessageBubble.tsx +2 -16
- package/src/core/Pipeline.ts +8 -12
|
@@ -2263,18 +2263,14 @@ var Pipeline = class {
|
|
|
2263
2263
|
const chartInstruction = `
|
|
2264
2264
|
|
|
2265
2265
|
${CHART_MARKER}
|
|
2266
|
-
###
|
|
2267
|
-
|
|
2268
|
-
\`\`\`chart
|
|
2269
|
-
{
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
- RULES:
|
|
2275
|
-
1. You MUST include the \`\`\`chart and \`\`\` markers. Naked JSON will NOT render.
|
|
2276
|
-
2. Output ONLY the chart block. No Python snippets. No "here is the data" text.
|
|
2277
|
-
3. Data objects MUST be FLAT. No math (e.g. use 10, NOT 5+5).`;
|
|
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
|
}
|
package/dist/handlers/index.js
CHANGED
|
@@ -3826,18 +3826,14 @@ var Pipeline = class {
|
|
|
3826
3826
|
const chartInstruction = `
|
|
3827
3827
|
|
|
3828
3828
|
${CHART_MARKER}
|
|
3829
|
-
###
|
|
3830
|
-
|
|
3831
|
-
\`\`\`chart
|
|
3832
|
-
{
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
|
|
3836
|
-
|
|
3837
|
-
- RULES:
|
|
3838
|
-
1. You MUST include the \`\`\`chart and \`\`\` markers. Naked JSON will NOT render.
|
|
3839
|
-
2. Output ONLY the chart block. No Python snippets. No "here is the data" text.
|
|
3840
|
-
3. Data objects MUST be FLAT. No math (e.g. use 10, NOT 5+5).`;
|
|
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
|
}
|
package/dist/handlers/index.mjs
CHANGED
package/dist/index.js
CHANGED
|
@@ -503,13 +503,8 @@ function MessageBubble({
|
|
|
503
503
|
};
|
|
504
504
|
});
|
|
505
505
|
}, [sources, isUser]);
|
|
506
|
-
const isVisualizationRequested = import_react5.default.useMemo(() => {
|
|
507
|
-
if (isUser) return false;
|
|
508
|
-
const text = message.content.toLowerCase();
|
|
509
|
-
return message.content.includes("```chart") || text.includes("pie chart") || text.includes("bar chart") || text.includes("line chart") || text.includes("distribution across");
|
|
510
|
-
}, [message.content, isUser]);
|
|
511
506
|
const { productsFromContent, cleanContent } = import_react5.default.useMemo(() => {
|
|
512
|
-
if (isUser
|
|
507
|
+
if (isUser) {
|
|
513
508
|
return { productsFromContent: [], cleanContent: message.content };
|
|
514
509
|
}
|
|
515
510
|
const jsonRegex = /```json\s*([\s\S]*?)\s*```/g;
|
|
@@ -535,7 +530,7 @@ function MessageBubble({
|
|
|
535
530
|
}
|
|
536
531
|
}
|
|
537
532
|
return { productsFromContent: products, cleanContent: content.trim() };
|
|
538
|
-
}, [message.content, isUser
|
|
533
|
+
}, [message.content, isUser]);
|
|
539
534
|
const allProducts = import_react5.default.useMemo(() => {
|
|
540
535
|
if (productsFromContent.length > 0) return productsFromContent;
|
|
541
536
|
const seen = /* @__PURE__ */ new Set();
|
package/dist/index.mjs
CHANGED
|
@@ -466,13 +466,8 @@ function MessageBubble({
|
|
|
466
466
|
};
|
|
467
467
|
});
|
|
468
468
|
}, [sources, isUser]);
|
|
469
|
-
const isVisualizationRequested = React5.useMemo(() => {
|
|
470
|
-
if (isUser) return false;
|
|
471
|
-
const text = message.content.toLowerCase();
|
|
472
|
-
return message.content.includes("```chart") || text.includes("pie chart") || text.includes("bar chart") || text.includes("line chart") || text.includes("distribution across");
|
|
473
|
-
}, [message.content, isUser]);
|
|
474
469
|
const { productsFromContent, cleanContent } = React5.useMemo(() => {
|
|
475
|
-
if (isUser
|
|
470
|
+
if (isUser) {
|
|
476
471
|
return { productsFromContent: [], cleanContent: message.content };
|
|
477
472
|
}
|
|
478
473
|
const jsonRegex = /```json\s*([\s\S]*?)\s*```/g;
|
|
@@ -498,7 +493,7 @@ function MessageBubble({
|
|
|
498
493
|
}
|
|
499
494
|
}
|
|
500
495
|
return { productsFromContent: products, cleanContent: content.trim() };
|
|
501
|
-
}, [message.content, isUser
|
|
496
|
+
}, [message.content, isUser]);
|
|
502
497
|
const allProducts = React5.useMemo(() => {
|
|
503
498
|
if (productsFromContent.length > 0) return productsFromContent;
|
|
504
499
|
const seen = /* @__PURE__ */ new Set();
|
package/dist/server.js
CHANGED
|
@@ -3917,18 +3917,14 @@ var Pipeline = class {
|
|
|
3917
3917
|
const chartInstruction = `
|
|
3918
3918
|
|
|
3919
3919
|
${CHART_MARKER}
|
|
3920
|
-
###
|
|
3921
|
-
|
|
3922
|
-
\`\`\`chart
|
|
3923
|
-
{
|
|
3924
|
-
|
|
3925
|
-
|
|
3926
|
-
|
|
3927
|
-
|
|
3928
|
-
- RULES:
|
|
3929
|
-
1. You MUST include the \`\`\`chart and \`\`\` markers. Naked JSON will NOT render.
|
|
3930
|
-
2. Output ONLY the chart block. No Python snippets. No "here is the data" text.
|
|
3931
|
-
3. Data objects MUST be FLAT. No math (e.g. use 10, NOT 5+5).`;
|
|
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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@retrivora-ai/rag-engine",
|
|
3
|
-
"version": "1.5.
|
|
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",
|
|
@@ -309,23 +309,9 @@ export function MessageBubble({
|
|
|
309
309
|
});
|
|
310
310
|
}, [sources, isUser]);
|
|
311
311
|
|
|
312
|
-
// ── Visualization Intent Detection ────────────────────────────────────────
|
|
313
|
-
// Robust detection to prevent UI clutter and ensure atomic rendering.
|
|
314
|
-
const isVisualizationRequested = React.useMemo(() => {
|
|
315
|
-
if (isUser) return false;
|
|
316
|
-
const text = message.content.toLowerCase();
|
|
317
|
-
return (
|
|
318
|
-
message.content.includes('```chart') ||
|
|
319
|
-
text.includes('pie chart') ||
|
|
320
|
-
text.includes('bar chart') ||
|
|
321
|
-
text.includes('line chart') ||
|
|
322
|
-
text.includes('distribution across')
|
|
323
|
-
);
|
|
324
|
-
}, [message.content, isUser]);
|
|
325
|
-
|
|
326
312
|
// ── Products + cleaned content from structured JSON blocks in the message ──
|
|
327
313
|
const { productsFromContent, cleanContent } = React.useMemo(() => {
|
|
328
|
-
if (isUser
|
|
314
|
+
if (isUser) {
|
|
329
315
|
return { productsFromContent: [] as Product[], cleanContent: message.content };
|
|
330
316
|
}
|
|
331
317
|
|
|
@@ -353,7 +339,7 @@ export function MessageBubble({
|
|
|
353
339
|
}
|
|
354
340
|
|
|
355
341
|
return { productsFromContent: products, cleanContent: content.trim() };
|
|
356
|
-
}, [message.content, isUser
|
|
342
|
+
}, [message.content, isUser]);
|
|
357
343
|
|
|
358
344
|
// ── Merge & deduplicate products ───────────────────────────────────────────
|
|
359
345
|
const allProducts = React.useMemo<Product[]>(() => {
|
package/src/core/Pipeline.ts
CHANGED
|
@@ -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
|
-
###
|
|
107
|
-
|
|
108
|
-
\`\`\`chart
|
|
109
|
-
{
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
- RULES:
|
|
115
|
-
1. You MUST include the \`\`\`chart and \`\`\` markers. Naked JSON will NOT render.
|
|
116
|
-
2. Output ONLY the chart block. No Python snippets. No "here is the data" text.
|
|
117
|
-
3. Data objects MUST be FLAT. No math (e.g. use 10, NOT 5+5).`;
|
|
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;
|