@retrivora-ai/rag-engine 1.7.8 → 1.8.0
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/{DocumentChunker-DMZVv6hi.d.ts → DocumentChunker-C1GEEosY.d.ts} +1 -1
- package/dist/{DocumentChunker-wKE98F_G.d.mts → DocumentChunker-CFEiRopR.d.mts} +1 -1
- package/dist/{chunk-UHGYLTTY.mjs → chunk-PV3MFHWU.mjs} +80 -61
- package/dist/handlers/index.d.mts +2 -2
- package/dist/handlers/index.d.ts +2 -2
- package/dist/handlers/index.js +80 -61
- package/dist/handlers/index.mjs +1 -1
- package/dist/{index-B1u4loP6.d.mts → index-Bb2yEopi.d.mts} +1 -1
- package/dist/{index-D9w9fLjh.d.ts → index-CkbTzj9J.d.ts} +1 -1
- package/dist/{index-DfsVx0a4.d.mts → index-DPsQodME.d.mts} +2 -1
- package/dist/{index-DfsVx0a4.d.ts → index-DPsQodME.d.ts} +2 -1
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +18 -38
- package/dist/index.mjs +18 -38
- package/dist/server.d.mts +5 -5
- package/dist/server.d.ts +5 -5
- package/dist/server.js +80 -61
- package/dist/server.mjs +1 -1
- package/package.json +1 -1
- package/src/components/DynamicChart.tsx +10 -35
- package/src/components/MessageBubble.tsx +16 -8
- package/src/core/Pipeline.ts +48 -46
- package/src/hooks/useRagChat.ts +3 -3
- package/src/types/chat.ts +1 -1
- package/src/types/index.ts +1 -0
- package/src/utils/UITransformer.ts +37 -17
|
@@ -2291,11 +2291,15 @@ var UITransformer = class {
|
|
|
2291
2291
|
static transformToPieChart(data) {
|
|
2292
2292
|
const categories = this.detectCategories(data);
|
|
2293
2293
|
const categoryData = this.aggregateByCategory(data, categories);
|
|
2294
|
-
const pieData = Object.entries(categoryData).map(([label, count]) =>
|
|
2295
|
-
label,
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2294
|
+
const pieData = Object.entries(categoryData).map(([label, count]) => {
|
|
2295
|
+
const { inStockCount, outOfStockCount } = this.calculateStockCounts(label, data);
|
|
2296
|
+
return {
|
|
2297
|
+
label,
|
|
2298
|
+
value: count,
|
|
2299
|
+
inStockCount,
|
|
2300
|
+
outOfStockCount
|
|
2301
|
+
};
|
|
2302
|
+
});
|
|
2299
2303
|
return {
|
|
2300
2304
|
type: "pie_chart",
|
|
2301
2305
|
title: "Distribution by Category",
|
|
@@ -2309,11 +2313,15 @@ var UITransformer = class {
|
|
|
2309
2313
|
static transformToBarChart(data) {
|
|
2310
2314
|
const categories = this.detectCategories(data);
|
|
2311
2315
|
const categoryData = this.aggregateByCategory(data, categories);
|
|
2312
|
-
const barData = Object.entries(categoryData).map(([category, value]) =>
|
|
2313
|
-
category,
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2316
|
+
const barData = Object.entries(categoryData).map(([category, value]) => {
|
|
2317
|
+
const { inStockCount, outOfStockCount } = this.calculateStockCounts(category, data);
|
|
2318
|
+
return {
|
|
2319
|
+
category,
|
|
2320
|
+
value,
|
|
2321
|
+
inStockCount,
|
|
2322
|
+
outOfStockCount
|
|
2323
|
+
};
|
|
2324
|
+
});
|
|
2317
2325
|
return {
|
|
2318
2326
|
type: "bar_chart",
|
|
2319
2327
|
title: "Comparison by Category",
|
|
@@ -2510,14 +2518,23 @@ var UITransformer = class {
|
|
|
2510
2518
|
});
|
|
2511
2519
|
}
|
|
2512
2520
|
/**
|
|
2513
|
-
* Helper:
|
|
2521
|
+
* Helper: Calculate stock counts by category
|
|
2514
2522
|
*/
|
|
2515
|
-
static
|
|
2516
|
-
|
|
2523
|
+
static calculateStockCounts(category, data) {
|
|
2524
|
+
let inStock = 0;
|
|
2525
|
+
let outOfStock = 0;
|
|
2526
|
+
data.forEach((d) => {
|
|
2517
2527
|
const meta = d.metadata || {};
|
|
2518
|
-
|
|
2528
|
+
const itemCategory = meta.category || meta.type || "Other";
|
|
2529
|
+
if (itemCategory === category) {
|
|
2530
|
+
if (this.determineStockStatus(d)) {
|
|
2531
|
+
inStock++;
|
|
2532
|
+
} else {
|
|
2533
|
+
outOfStock++;
|
|
2534
|
+
}
|
|
2535
|
+
}
|
|
2519
2536
|
});
|
|
2520
|
-
return
|
|
2537
|
+
return { inStockCount: inStock, outOfStockCount: outOfStock };
|
|
2521
2538
|
}
|
|
2522
2539
|
/**
|
|
2523
2540
|
* Helper: Determine if item is in stock
|
|
@@ -2626,19 +2643,19 @@ Classify the query into ONE of the following intents:
|
|
|
2626
2643
|
|
|
2627
2644
|
---
|
|
2628
2645
|
|
|
2629
|
-
## 2. VIEW
|
|
2646
|
+
## 2. VIEW SELECTION (DYNAMIC)
|
|
2630
2647
|
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2648
|
+
Choose the best primary "view" ("carousel", "chart", or "table") based on the data:
|
|
2649
|
+
- TRENDS/GROWTH \u2192 "chart" (type: "line")
|
|
2650
|
+
- DISTRIBUTIONS/RATIOS \u2192 "chart" (type: "pie")
|
|
2651
|
+
- COMPARISONS \u2192 "chart" (type: "bar")
|
|
2652
|
+
- PRODUCT LISTS \u2192 "carousel"
|
|
2653
|
+
- RAW DATA/SPECS \u2192 "table"
|
|
2637
2654
|
|
|
2638
|
-
\u26A0\uFE0F
|
|
2639
|
-
- If query
|
|
2640
|
-
- If
|
|
2641
|
-
- NEVER
|
|
2655
|
+
\u26A0\uFE0F Dynamic Overrides:
|
|
2656
|
+
- If query is "show products", ALWAYS use carousel.
|
|
2657
|
+
- If data is statistical, ALWAYS use a chart.
|
|
2658
|
+
- NEVER explain why you chose a view.
|
|
2642
2659
|
|
|
2643
2660
|
---
|
|
2644
2661
|
|
|
@@ -2696,7 +2713,8 @@ Classify the query into ONE of the following intents:
|
|
|
2696
2713
|
{
|
|
2697
2714
|
"label": "string",
|
|
2698
2715
|
"value": number,
|
|
2699
|
-
"
|
|
2716
|
+
"inStockCount": number (optional),
|
|
2717
|
+
"outOfStockCount": number (optional)
|
|
2700
2718
|
}
|
|
2701
2719
|
|
|
2702
2720
|
### \u{1F539} TABLE FORMAT
|
|
@@ -2707,14 +2725,14 @@ Classify the query into ONE of the following intents:
|
|
|
2707
2725
|
|
|
2708
2726
|
## 5. DATA RULES
|
|
2709
2727
|
|
|
2710
|
-
- NEVER hallucinate fields or data
|
|
2711
|
-
- ONLY use
|
|
2712
|
-
-
|
|
2713
|
-
-
|
|
2714
|
-
-
|
|
2715
|
-
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2728
|
+
- NEVER hallucinate fields or data.
|
|
2729
|
+
- ONLY use data provided in the retrieved context.
|
|
2730
|
+
- STRICT DATA ISOLATION: The labels and numbers in the EXAMPLES section below are placeholders. NEVER use them.
|
|
2731
|
+
- IF NO DATA IS FOUND: You MUST NOT generate a chart. You MUST NOT say "This example assumes" or provide hypothetical numbers. Simply state "No relevant data found in the database." and STOP.
|
|
2732
|
+
- NO META-COMMENTARY: NEVER talk about the task itself (e.g., "I've used JSON", "In a real-world app", "Dedicated library").
|
|
2733
|
+
- NEVER explain YOUR formatting choice.
|
|
2734
|
+
- Aggregate BEFORE rendering chart.
|
|
2735
|
+
- DYNAMIC INTELLIGENCE: Autonomously extract relevant categories/values from the context and calculate totals for the "data" array based on the user query.
|
|
2718
2736
|
|
|
2719
2737
|
---
|
|
2720
2738
|
|
|
@@ -2731,11 +2749,12 @@ Classify the query into ONE of the following intents:
|
|
|
2731
2749
|
|
|
2732
2750
|
## 7. OUTPUT RULES
|
|
2733
2751
|
|
|
2734
|
-
- ALWAYS return EXACTLY ONE \`\`\`ui\`\`\` block
|
|
2735
|
-
- JSON must be VALID
|
|
2736
|
-
-
|
|
2737
|
-
-
|
|
2738
|
-
- If
|
|
2752
|
+
- ALWAYS return EXACTLY ONE \`\`\`ui\`\`\` block.
|
|
2753
|
+
- JSON must be VALID.
|
|
2754
|
+
- FIELD MAPPING (MANDATORY): Always use "label" for the name/category and "value" for the numeric count.
|
|
2755
|
+
- NO xKey or yKeys: Do not include these fields; the UI uses "label" and "value" by default.
|
|
2756
|
+
- SILENT DATA: If a chart is provided, DO NOT say "Here is the JSON" or "Below is the data". Simply output the block.
|
|
2757
|
+
- TEXT OUTSIDE THE BLOCK: One brief sentence maximum.
|
|
2739
2758
|
|
|
2740
2759
|
---
|
|
2741
2760
|
|
|
@@ -2746,8 +2765,8 @@ User: "show me beauty products"
|
|
|
2746
2765
|
\`\`\`ui
|
|
2747
2766
|
{
|
|
2748
2767
|
"view": "carousel",
|
|
2749
|
-
"title": "
|
|
2750
|
-
"description": "
|
|
2768
|
+
"title": "TITLE",
|
|
2769
|
+
"description": "DESCRIPTION",
|
|
2751
2770
|
"metadata": {
|
|
2752
2771
|
"intent": "explore",
|
|
2753
2772
|
"confidence": 0.95
|
|
@@ -2755,43 +2774,41 @@ User: "show me beauty products"
|
|
|
2755
2774
|
"carousel": {
|
|
2756
2775
|
"items": [
|
|
2757
2776
|
{
|
|
2758
|
-
"id": "
|
|
2759
|
-
"name": "
|
|
2760
|
-
"brand": "
|
|
2761
|
-
"price":
|
|
2762
|
-
"image": "
|
|
2763
|
-
"link": "
|
|
2777
|
+
"id": "ID",
|
|
2778
|
+
"name": "PRODUCT_NAME",
|
|
2779
|
+
"brand": "BRAND",
|
|
2780
|
+
"price": 0,
|
|
2781
|
+
"image": "URL",
|
|
2782
|
+
"link": "URL",
|
|
2764
2783
|
"inStock": true
|
|
2765
2784
|
}
|
|
2766
2785
|
]
|
|
2767
2786
|
},
|
|
2768
|
-
"insights": ["
|
|
2787
|
+
"insights": ["INSIGHT"]
|
|
2769
2788
|
}
|
|
2770
2789
|
\`\`\`
|
|
2771
2790
|
|
|
2772
2791
|
---
|
|
2773
2792
|
|
|
2774
|
-
|
|
2793
|
+
|
|
2775
2794
|
|
|
2776
2795
|
\`\`\`ui
|
|
2777
2796
|
{
|
|
2778
2797
|
"view": "chart",
|
|
2779
|
-
"title": "
|
|
2780
|
-
"description": "
|
|
2798
|
+
"title": "TITLE",
|
|
2799
|
+
"description": "DESCRIPTION",
|
|
2781
2800
|
"metadata": {
|
|
2782
2801
|
"intent": "analyze",
|
|
2783
2802
|
"confidence": 0.98
|
|
2784
2803
|
},
|
|
2785
2804
|
"chart": {
|
|
2786
2805
|
"type": "pie",
|
|
2787
|
-
"xKey": "label",
|
|
2788
|
-
"yKeys": ["value"],
|
|
2789
2806
|
"data": [
|
|
2790
|
-
{ "label": "
|
|
2791
|
-
{ "label": "
|
|
2807
|
+
{ "label": "LABEL_A", "value": 0, "inStockCount": 0, "outOfStockCount": 0 },
|
|
2808
|
+
{ "label": "LABEL_B", "value": 0, "inStockCount": 0, "outOfStockCount": 0 }
|
|
2792
2809
|
]
|
|
2793
2810
|
},
|
|
2794
|
-
"insights": ["
|
|
2811
|
+
"insights": ["INSIGHT"]
|
|
2795
2812
|
}
|
|
2796
2813
|
\`\`\`
|
|
2797
2814
|
`;
|
|
@@ -2952,14 +2969,16 @@ User: "distribution of products across categories"
|
|
|
2952
2969
|
let reply = "";
|
|
2953
2970
|
let sources = [];
|
|
2954
2971
|
let graphData;
|
|
2972
|
+
let uiTransformation;
|
|
2955
2973
|
try {
|
|
2956
2974
|
for (var iter = __forAwait(stream), more, temp, error; more = !(temp = await iter.next()).done; more = false) {
|
|
2957
2975
|
const chunk = temp.value;
|
|
2958
2976
|
if (typeof chunk === "string") {
|
|
2959
2977
|
reply += chunk;
|
|
2960
|
-
} else if ("
|
|
2961
|
-
sources = chunk.sources;
|
|
2962
|
-
graphData = chunk.graphData;
|
|
2978
|
+
} else if (typeof chunk === "object" && chunk !== null) {
|
|
2979
|
+
if ("sources" in chunk) sources = chunk.sources;
|
|
2980
|
+
if ("graphData" in chunk) graphData = chunk.graphData;
|
|
2981
|
+
if ("ui_transformation" in chunk) uiTransformation = chunk.ui_transformation;
|
|
2963
2982
|
}
|
|
2964
2983
|
}
|
|
2965
2984
|
} catch (temp) {
|
|
@@ -2972,7 +2991,7 @@ User: "distribution of products across categories"
|
|
|
2972
2991
|
throw error[0];
|
|
2973
2992
|
}
|
|
2974
2993
|
}
|
|
2975
|
-
return { reply, sources, graphData };
|
|
2994
|
+
return { reply, sources, graphData, ui_transformation: uiTransformation };
|
|
2976
2995
|
}
|
|
2977
2996
|
/**
|
|
2978
2997
|
* High-performance streaming RAG flow.
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import '../index-
|
|
2
|
-
export { c as createChatHandler, d as createHealthHandler, e as createIngestHandler, f as createStreamHandler, k as createSuggestionsHandler, g as createUploadHandler, s as sseErrorFrame, h as sseFrame, i as sseMetaFrame, j as sseTextFrame, l as sseUIFrame } from '../index-
|
|
1
|
+
import '../index-DPsQodME.mjs';
|
|
2
|
+
export { c as createChatHandler, d as createHealthHandler, e as createIngestHandler, f as createStreamHandler, k as createSuggestionsHandler, g as createUploadHandler, s as sseErrorFrame, h as sseFrame, i as sseMetaFrame, j as sseTextFrame, l as sseUIFrame } from '../index-Bb2yEopi.mjs';
|
|
3
3
|
import 'next/server';
|
package/dist/handlers/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import '../index-
|
|
2
|
-
export { c as createChatHandler, d as createHealthHandler, e as createIngestHandler, f as createStreamHandler, k as createSuggestionsHandler, g as createUploadHandler, s as sseErrorFrame, h as sseFrame, i as sseMetaFrame, j as sseTextFrame, l as sseUIFrame } from '../index-
|
|
1
|
+
import '../index-DPsQodME.js';
|
|
2
|
+
export { c as createChatHandler, d as createHealthHandler, e as createIngestHandler, f as createStreamHandler, k as createSuggestionsHandler, g as createUploadHandler, s as sseErrorFrame, h as sseFrame, i as sseMetaFrame, j as sseTextFrame, l as sseUIFrame } from '../index-CkbTzj9J.js';
|
|
3
3
|
import 'next/server';
|
package/dist/handlers/index.js
CHANGED
|
@@ -3855,11 +3855,15 @@ var UITransformer = class {
|
|
|
3855
3855
|
static transformToPieChart(data) {
|
|
3856
3856
|
const categories = this.detectCategories(data);
|
|
3857
3857
|
const categoryData = this.aggregateByCategory(data, categories);
|
|
3858
|
-
const pieData = Object.entries(categoryData).map(([label, count]) =>
|
|
3859
|
-
label,
|
|
3860
|
-
|
|
3861
|
-
|
|
3862
|
-
|
|
3858
|
+
const pieData = Object.entries(categoryData).map(([label, count]) => {
|
|
3859
|
+
const { inStockCount, outOfStockCount } = this.calculateStockCounts(label, data);
|
|
3860
|
+
return {
|
|
3861
|
+
label,
|
|
3862
|
+
value: count,
|
|
3863
|
+
inStockCount,
|
|
3864
|
+
outOfStockCount
|
|
3865
|
+
};
|
|
3866
|
+
});
|
|
3863
3867
|
return {
|
|
3864
3868
|
type: "pie_chart",
|
|
3865
3869
|
title: "Distribution by Category",
|
|
@@ -3873,11 +3877,15 @@ var UITransformer = class {
|
|
|
3873
3877
|
static transformToBarChart(data) {
|
|
3874
3878
|
const categories = this.detectCategories(data);
|
|
3875
3879
|
const categoryData = this.aggregateByCategory(data, categories);
|
|
3876
|
-
const barData = Object.entries(categoryData).map(([category, value]) =>
|
|
3877
|
-
category,
|
|
3878
|
-
|
|
3879
|
-
|
|
3880
|
-
|
|
3880
|
+
const barData = Object.entries(categoryData).map(([category, value]) => {
|
|
3881
|
+
const { inStockCount, outOfStockCount } = this.calculateStockCounts(category, data);
|
|
3882
|
+
return {
|
|
3883
|
+
category,
|
|
3884
|
+
value,
|
|
3885
|
+
inStockCount,
|
|
3886
|
+
outOfStockCount
|
|
3887
|
+
};
|
|
3888
|
+
});
|
|
3881
3889
|
return {
|
|
3882
3890
|
type: "bar_chart",
|
|
3883
3891
|
title: "Comparison by Category",
|
|
@@ -4074,14 +4082,23 @@ var UITransformer = class {
|
|
|
4074
4082
|
});
|
|
4075
4083
|
}
|
|
4076
4084
|
/**
|
|
4077
|
-
* Helper:
|
|
4085
|
+
* Helper: Calculate stock counts by category
|
|
4078
4086
|
*/
|
|
4079
|
-
static
|
|
4080
|
-
|
|
4087
|
+
static calculateStockCounts(category, data) {
|
|
4088
|
+
let inStock = 0;
|
|
4089
|
+
let outOfStock = 0;
|
|
4090
|
+
data.forEach((d) => {
|
|
4081
4091
|
const meta = d.metadata || {};
|
|
4082
|
-
|
|
4092
|
+
const itemCategory = meta.category || meta.type || "Other";
|
|
4093
|
+
if (itemCategory === category) {
|
|
4094
|
+
if (this.determineStockStatus(d)) {
|
|
4095
|
+
inStock++;
|
|
4096
|
+
} else {
|
|
4097
|
+
outOfStock++;
|
|
4098
|
+
}
|
|
4099
|
+
}
|
|
4083
4100
|
});
|
|
4084
|
-
return
|
|
4101
|
+
return { inStockCount: inStock, outOfStockCount: outOfStock };
|
|
4085
4102
|
}
|
|
4086
4103
|
/**
|
|
4087
4104
|
* Helper: Determine if item is in stock
|
|
@@ -4190,19 +4207,19 @@ Classify the query into ONE of the following intents:
|
|
|
4190
4207
|
|
|
4191
4208
|
---
|
|
4192
4209
|
|
|
4193
|
-
## 2. VIEW
|
|
4210
|
+
## 2. VIEW SELECTION (DYNAMIC)
|
|
4194
4211
|
|
|
4195
|
-
|
|
4196
|
-
|
|
4197
|
-
|
|
4198
|
-
|
|
4199
|
-
|
|
4200
|
-
|
|
4212
|
+
Choose the best primary "view" ("carousel", "chart", or "table") based on the data:
|
|
4213
|
+
- TRENDS/GROWTH \u2192 "chart" (type: "line")
|
|
4214
|
+
- DISTRIBUTIONS/RATIOS \u2192 "chart" (type: "pie")
|
|
4215
|
+
- COMPARISONS \u2192 "chart" (type: "bar")
|
|
4216
|
+
- PRODUCT LISTS \u2192 "carousel"
|
|
4217
|
+
- RAW DATA/SPECS \u2192 "table"
|
|
4201
4218
|
|
|
4202
|
-
\u26A0\uFE0F
|
|
4203
|
-
- If query
|
|
4204
|
-
- If
|
|
4205
|
-
- NEVER
|
|
4219
|
+
\u26A0\uFE0F Dynamic Overrides:
|
|
4220
|
+
- If query is "show products", ALWAYS use carousel.
|
|
4221
|
+
- If data is statistical, ALWAYS use a chart.
|
|
4222
|
+
- NEVER explain why you chose a view.
|
|
4206
4223
|
|
|
4207
4224
|
---
|
|
4208
4225
|
|
|
@@ -4260,7 +4277,8 @@ Classify the query into ONE of the following intents:
|
|
|
4260
4277
|
{
|
|
4261
4278
|
"label": "string",
|
|
4262
4279
|
"value": number,
|
|
4263
|
-
"
|
|
4280
|
+
"inStockCount": number (optional),
|
|
4281
|
+
"outOfStockCount": number (optional)
|
|
4264
4282
|
}
|
|
4265
4283
|
|
|
4266
4284
|
### \u{1F539} TABLE FORMAT
|
|
@@ -4271,14 +4289,14 @@ Classify the query into ONE of the following intents:
|
|
|
4271
4289
|
|
|
4272
4290
|
## 5. DATA RULES
|
|
4273
4291
|
|
|
4274
|
-
- NEVER hallucinate fields or data
|
|
4275
|
-
- ONLY use
|
|
4276
|
-
-
|
|
4277
|
-
-
|
|
4278
|
-
-
|
|
4279
|
-
-
|
|
4280
|
-
|
|
4281
|
-
|
|
4292
|
+
- NEVER hallucinate fields or data.
|
|
4293
|
+
- ONLY use data provided in the retrieved context.
|
|
4294
|
+
- STRICT DATA ISOLATION: The labels and numbers in the EXAMPLES section below are placeholders. NEVER use them.
|
|
4295
|
+
- IF NO DATA IS FOUND: You MUST NOT generate a chart. You MUST NOT say "This example assumes" or provide hypothetical numbers. Simply state "No relevant data found in the database." and STOP.
|
|
4296
|
+
- NO META-COMMENTARY: NEVER talk about the task itself (e.g., "I've used JSON", "In a real-world app", "Dedicated library").
|
|
4297
|
+
- NEVER explain YOUR formatting choice.
|
|
4298
|
+
- Aggregate BEFORE rendering chart.
|
|
4299
|
+
- DYNAMIC INTELLIGENCE: Autonomously extract relevant categories/values from the context and calculate totals for the "data" array based on the user query.
|
|
4282
4300
|
|
|
4283
4301
|
---
|
|
4284
4302
|
|
|
@@ -4295,11 +4313,12 @@ Classify the query into ONE of the following intents:
|
|
|
4295
4313
|
|
|
4296
4314
|
## 7. OUTPUT RULES
|
|
4297
4315
|
|
|
4298
|
-
- ALWAYS return EXACTLY ONE \`\`\`ui\`\`\` block
|
|
4299
|
-
- JSON must be VALID
|
|
4300
|
-
-
|
|
4301
|
-
-
|
|
4302
|
-
- If
|
|
4316
|
+
- ALWAYS return EXACTLY ONE \`\`\`ui\`\`\` block.
|
|
4317
|
+
- JSON must be VALID.
|
|
4318
|
+
- FIELD MAPPING (MANDATORY): Always use "label" for the name/category and "value" for the numeric count.
|
|
4319
|
+
- NO xKey or yKeys: Do not include these fields; the UI uses "label" and "value" by default.
|
|
4320
|
+
- SILENT DATA: If a chart is provided, DO NOT say "Here is the JSON" or "Below is the data". Simply output the block.
|
|
4321
|
+
- TEXT OUTSIDE THE BLOCK: One brief sentence maximum.
|
|
4303
4322
|
|
|
4304
4323
|
---
|
|
4305
4324
|
|
|
@@ -4310,8 +4329,8 @@ User: "show me beauty products"
|
|
|
4310
4329
|
\`\`\`ui
|
|
4311
4330
|
{
|
|
4312
4331
|
"view": "carousel",
|
|
4313
|
-
"title": "
|
|
4314
|
-
"description": "
|
|
4332
|
+
"title": "TITLE",
|
|
4333
|
+
"description": "DESCRIPTION",
|
|
4315
4334
|
"metadata": {
|
|
4316
4335
|
"intent": "explore",
|
|
4317
4336
|
"confidence": 0.95
|
|
@@ -4319,43 +4338,41 @@ User: "show me beauty products"
|
|
|
4319
4338
|
"carousel": {
|
|
4320
4339
|
"items": [
|
|
4321
4340
|
{
|
|
4322
|
-
"id": "
|
|
4323
|
-
"name": "
|
|
4324
|
-
"brand": "
|
|
4325
|
-
"price":
|
|
4326
|
-
"image": "
|
|
4327
|
-
"link": "
|
|
4341
|
+
"id": "ID",
|
|
4342
|
+
"name": "PRODUCT_NAME",
|
|
4343
|
+
"brand": "BRAND",
|
|
4344
|
+
"price": 0,
|
|
4345
|
+
"image": "URL",
|
|
4346
|
+
"link": "URL",
|
|
4328
4347
|
"inStock": true
|
|
4329
4348
|
}
|
|
4330
4349
|
]
|
|
4331
4350
|
},
|
|
4332
|
-
"insights": ["
|
|
4351
|
+
"insights": ["INSIGHT"]
|
|
4333
4352
|
}
|
|
4334
4353
|
\`\`\`
|
|
4335
4354
|
|
|
4336
4355
|
---
|
|
4337
4356
|
|
|
4338
|
-
|
|
4357
|
+
|
|
4339
4358
|
|
|
4340
4359
|
\`\`\`ui
|
|
4341
4360
|
{
|
|
4342
4361
|
"view": "chart",
|
|
4343
|
-
"title": "
|
|
4344
|
-
"description": "
|
|
4362
|
+
"title": "TITLE",
|
|
4363
|
+
"description": "DESCRIPTION",
|
|
4345
4364
|
"metadata": {
|
|
4346
4365
|
"intent": "analyze",
|
|
4347
4366
|
"confidence": 0.98
|
|
4348
4367
|
},
|
|
4349
4368
|
"chart": {
|
|
4350
4369
|
"type": "pie",
|
|
4351
|
-
"xKey": "label",
|
|
4352
|
-
"yKeys": ["value"],
|
|
4353
4370
|
"data": [
|
|
4354
|
-
{ "label": "
|
|
4355
|
-
{ "label": "
|
|
4371
|
+
{ "label": "LABEL_A", "value": 0, "inStockCount": 0, "outOfStockCount": 0 },
|
|
4372
|
+
{ "label": "LABEL_B", "value": 0, "inStockCount": 0, "outOfStockCount": 0 }
|
|
4356
4373
|
]
|
|
4357
4374
|
},
|
|
4358
|
-
"insights": ["
|
|
4375
|
+
"insights": ["INSIGHT"]
|
|
4359
4376
|
}
|
|
4360
4377
|
\`\`\`
|
|
4361
4378
|
`;
|
|
@@ -4516,14 +4533,16 @@ User: "distribution of products across categories"
|
|
|
4516
4533
|
let reply = "";
|
|
4517
4534
|
let sources = [];
|
|
4518
4535
|
let graphData;
|
|
4536
|
+
let uiTransformation;
|
|
4519
4537
|
try {
|
|
4520
4538
|
for (var iter = __forAwait(stream), more, temp, error; more = !(temp = await iter.next()).done; more = false) {
|
|
4521
4539
|
const chunk = temp.value;
|
|
4522
4540
|
if (typeof chunk === "string") {
|
|
4523
4541
|
reply += chunk;
|
|
4524
|
-
} else if ("
|
|
4525
|
-
sources = chunk.sources;
|
|
4526
|
-
graphData = chunk.graphData;
|
|
4542
|
+
} else if (typeof chunk === "object" && chunk !== null) {
|
|
4543
|
+
if ("sources" in chunk) sources = chunk.sources;
|
|
4544
|
+
if ("graphData" in chunk) graphData = chunk.graphData;
|
|
4545
|
+
if ("ui_transformation" in chunk) uiTransformation = chunk.ui_transformation;
|
|
4527
4546
|
}
|
|
4528
4547
|
}
|
|
4529
4548
|
} catch (temp) {
|
|
@@ -4536,7 +4555,7 @@ User: "distribution of products across categories"
|
|
|
4536
4555
|
throw error[0];
|
|
4537
4556
|
}
|
|
4538
4557
|
}
|
|
4539
|
-
return { reply, sources, graphData };
|
|
4558
|
+
return { reply, sources, graphData, ui_transformation: uiTransformation };
|
|
4540
4559
|
}
|
|
4541
4560
|
/**
|
|
4542
4561
|
* High-performance streaming RAG flow.
|
package/dist/handlers/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { h as RagConfig, C as ChatMessage, d as ChatResponse, I as IngestDocument } from './index-
|
|
1
|
+
import { h as RagConfig, C as ChatMessage, d as ChatResponse, I as IngestDocument } from './index-DPsQodME.mjs';
|
|
2
2
|
import { NextRequest, NextResponse } from 'next/server';
|
|
3
3
|
|
|
4
4
|
interface ValidationError {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { h as RagConfig, C as ChatMessage, d as ChatResponse, I as IngestDocument } from './index-
|
|
1
|
+
import { h as RagConfig, C as ChatMessage, d as ChatResponse, I as IngestDocument } from './index-DPsQodME.js';
|
|
2
2
|
import { NextRequest, NextResponse } from 'next/server';
|
|
3
3
|
|
|
4
4
|
interface ValidationError {
|
|
@@ -6,7 +6,7 @@ interface ChatMessage {
|
|
|
6
6
|
interface RagMessage extends ChatMessage {
|
|
7
7
|
id: string;
|
|
8
8
|
sources?: VectorMatch[];
|
|
9
|
-
uiTransformation?:
|
|
9
|
+
uiTransformation?: unknown;
|
|
10
10
|
createdAt: string;
|
|
11
11
|
}
|
|
12
12
|
interface ChatOptions {
|
|
@@ -243,6 +243,7 @@ interface ChatResponse {
|
|
|
243
243
|
reply: string;
|
|
244
244
|
sources: VectorMatch[];
|
|
245
245
|
graphData?: GraphSearchResult;
|
|
246
|
+
ui_transformation?: unknown;
|
|
246
247
|
}
|
|
247
248
|
interface GraphNode {
|
|
248
249
|
id: string;
|
|
@@ -6,7 +6,7 @@ interface ChatMessage {
|
|
|
6
6
|
interface RagMessage extends ChatMessage {
|
|
7
7
|
id: string;
|
|
8
8
|
sources?: VectorMatch[];
|
|
9
|
-
uiTransformation?:
|
|
9
|
+
uiTransformation?: unknown;
|
|
10
10
|
createdAt: string;
|
|
11
11
|
}
|
|
12
12
|
interface ChatOptions {
|
|
@@ -243,6 +243,7 @@ interface ChatResponse {
|
|
|
243
243
|
reply: string;
|
|
244
244
|
sources: VectorMatch[];
|
|
245
245
|
graphData?: GraphSearchResult;
|
|
246
|
+
ui_transformation?: unknown;
|
|
246
247
|
}
|
|
247
248
|
interface GraphNode {
|
|
248
249
|
id: string;
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { CSSProperties, MouseEvent, ReactNode } from 'react';
|
|
2
|
-
import { P as Product, U as UIConfig, R as RagMessage, V as VectorMatch, a as UseRagChatOptions, b as UseRagChatReturn } from './index-
|
|
3
|
-
export { C as ChatMessage, c as ChatOptions, d as ChatResponse, E as EmbeddingConfig, e as EmbeddingProvider, I as IngestDocument, L as LLMConfig, f as LLMProvider, g as RAGConfig, h as RagConfig, i as UpsertDocument, j as VectorDBConfig, k as VectorDBProvider } from './index-
|
|
4
|
-
export { C as Chunk, a as ChunkOptions, E as EmbedOptions, I as ILLMProvider } from './DocumentChunker-
|
|
2
|
+
import { P as Product, U as UIConfig, R as RagMessage, V as VectorMatch, a as UseRagChatOptions, b as UseRagChatReturn } from './index-DPsQodME.mjs';
|
|
3
|
+
export { C as ChatMessage, c as ChatOptions, d as ChatResponse, E as EmbeddingConfig, e as EmbeddingProvider, I as IngestDocument, L as LLMConfig, f as LLMProvider, g as RAGConfig, h as RagConfig, i as UpsertDocument, j as VectorDBConfig, k as VectorDBProvider } from './index-DPsQodME.mjs';
|
|
4
|
+
export { C as Chunk, a as ChunkOptions, E as EmbedOptions, I as ILLMProvider } from './DocumentChunker-CFEiRopR.mjs';
|
|
5
5
|
|
|
6
6
|
type ChatViewportSize = 'compact' | 'medium' | 'large';
|
|
7
7
|
interface ChatWindowProps {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { CSSProperties, MouseEvent, ReactNode } from 'react';
|
|
2
|
-
import { P as Product, U as UIConfig, R as RagMessage, V as VectorMatch, a as UseRagChatOptions, b as UseRagChatReturn } from './index-
|
|
3
|
-
export { C as ChatMessage, c as ChatOptions, d as ChatResponse, E as EmbeddingConfig, e as EmbeddingProvider, I as IngestDocument, L as LLMConfig, f as LLMProvider, g as RAGConfig, h as RagConfig, i as UpsertDocument, j as VectorDBConfig, k as VectorDBProvider } from './index-
|
|
4
|
-
export { C as Chunk, a as ChunkOptions, E as EmbedOptions, I as ILLMProvider } from './DocumentChunker-
|
|
2
|
+
import { P as Product, U as UIConfig, R as RagMessage, V as VectorMatch, a as UseRagChatOptions, b as UseRagChatReturn } from './index-DPsQodME.js';
|
|
3
|
+
export { C as ChatMessage, c as ChatOptions, d as ChatResponse, E as EmbeddingConfig, e as EmbeddingProvider, I as IngestDocument, L as LLMConfig, f as LLMProvider, g as RAGConfig, h as RagConfig, i as UpsertDocument, j as VectorDBConfig, k as VectorDBProvider } from './index-DPsQodME.js';
|
|
4
|
+
export { C as Chunk, a as ChunkOptions, E as EmbedOptions, I as ILLMProvider } from './DocumentChunker-C1GEEosY.js';
|
|
5
5
|
|
|
6
6
|
type ChatViewportSize = 'compact' | 'medium' | 'large';
|
|
7
7
|
interface ChatWindowProps {
|