@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.
- package/dist/{chunk-5K7EU4KW.mjs → chunk-EE2Z4HNW.mjs} +8 -9
- package/dist/handlers/index.js +8 -9
- package/dist/handlers/index.mjs +1 -1
- package/dist/index.js +6 -3
- package/dist/index.mjs +6 -3
- package/dist/server.js +8 -9
- package/dist/server.mjs +1 -1
- package/package.json +1 -1
- package/src/components/MessageBubble.tsx +11 -8
- package/src/core/Pipeline.ts +8 -9
|
@@ -2263,15 +2263,14 @@ var Pipeline = class {
|
|
|
2263
2263
|
const chartInstruction = `
|
|
2264
2264
|
|
|
2265
2265
|
${CHART_MARKER}
|
|
2266
|
-
### UNIVERSAL UI PROTOCOL
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
-
|
|
2271
|
-
-
|
|
2272
|
-
-
|
|
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",
|
package/dist/handlers/index.js
CHANGED
|
@@ -3826,15 +3826,14 @@ var Pipeline = class {
|
|
|
3826
3826
|
const chartInstruction = `
|
|
3827
3827
|
|
|
3828
3828
|
${CHART_MARKER}
|
|
3829
|
-
### UNIVERSAL UI PROTOCOL
|
|
3830
|
-
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
-
|
|
3834
|
-
-
|
|
3835
|
-
-
|
|
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",
|
package/dist/handlers/index.mjs
CHANGED
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(/(
|
|
842
|
-
if (match.includes("```")) return match;
|
|
841
|
+
raw = raw.replace(/(\{[\s\S]+?\})(?!\s*```)/g, (match) => {
|
|
843
842
|
if (!looksLikeStructuredPayload(match)) return match;
|
|
844
|
-
const
|
|
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(/(
|
|
805
|
-
if (match.includes("```")) return match;
|
|
804
|
+
raw = raw.replace(/(\{[\s\S]+?\})(?!\s*```)/g, (match) => {
|
|
806
805
|
if (!looksLikeStructuredPayload(match)) return match;
|
|
807
|
-
const
|
|
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
|
-
|
|
3922
|
-
|
|
3923
|
-
|
|
3924
|
-
-
|
|
3925
|
-
-
|
|
3926
|
-
-
|
|
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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@retrivora-ai/rag-engine",
|
|
3
|
-
"version": "1.6.
|
|
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 ```
|
|
701
|
+
// This handles models (like Llama 3.2) that often omit the ```ui markers.
|
|
702
702
|
if (!isStreaming) {
|
|
703
|
-
//
|
|
704
|
-
raw = raw.replace(/(
|
|
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
|
-
|
|
709
|
-
|
|
710
|
-
|
|
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
|
}
|
package/src/core/Pipeline.ts
CHANGED
|
@@ -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
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
-
|
|
111
|
-
-
|
|
112
|
-
-
|
|
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",
|