@prismiq/react 0.2.0 → 0.2.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/{ChatBubble-ARocmvZD.d.cts → ChatBubble-3mFpV7yX.d.ts} +4 -2
- package/dist/{ChatBubble-BN_CjIpk.d.ts → ChatBubble-CMkEupzn.d.cts} +4 -2
- package/dist/{DashboardDialog-Z-HypxmG.d.cts → DashboardDialog-DMmZ3bnf.d.cts} +1 -1
- package/dist/{DashboardDialog-UhUGXx2h.d.ts → DashboardDialog-RlcPkdMt.d.ts} +1 -1
- package/dist/charts/index.d.cts +2 -2
- package/dist/charts/index.d.ts +2 -2
- package/dist/{chunk-JBJ5LEAG.js → chunk-F6QYNQEW.js} +12 -4
- package/dist/chunk-F6QYNQEW.js.map +1 -0
- package/dist/{chunk-FKXCINUF.cjs → chunk-N6I3QOHG.cjs} +201 -193
- package/dist/chunk-N6I3QOHG.cjs.map +1 -0
- package/dist/{chunk-PG7QBH3G.cjs → chunk-NXXKG4GN.cjs} +50 -15
- package/dist/chunk-NXXKG4GN.cjs.map +1 -0
- package/dist/{chunk-GELI7MDZ.js → chunk-VEFYFB5H.js} +50 -15
- package/dist/chunk-VEFYFB5H.js.map +1 -0
- package/dist/components/index.cjs +56 -56
- package/dist/components/index.d.cts +2 -2
- package/dist/components/index.d.ts +2 -2
- package/dist/components/index.js +1 -1
- package/dist/dashboard/index.cjs +34 -34
- package/dist/dashboard/index.d.cts +3 -3
- package/dist/dashboard/index.d.ts +3 -3
- package/dist/dashboard/index.js +2 -2
- package/dist/export/index.d.cts +1 -1
- package/dist/export/index.d.ts +1 -1
- package/dist/{index-B8DelfpL.d.cts → index-BA2VUhgN.d.cts} +1 -1
- package/dist/{index-RbfYPQD_.d.ts → index-BPo89ZAj.d.ts} +1 -1
- package/dist/index.cjs +100 -100
- package/dist/index.d.cts +11 -8
- package/dist/index.d.ts +11 -8
- package/dist/index.js +4 -4
- package/dist/{types-ccB9Ps3k.d.cts → types-BaI6sSAG.d.cts} +20 -2
- package/dist/{types-ccB9Ps3k.d.ts → types-BaI6sSAG.d.ts} +20 -2
- package/dist/utils/index.d.cts +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/package.json +1 -1
- package/dist/chunk-FKXCINUF.cjs.map +0 -1
- package/dist/chunk-GELI7MDZ.js.map +0 -1
- package/dist/chunk-JBJ5LEAG.js.map +0 -1
- package/dist/chunk-PG7QBH3G.cjs.map +0 -1
|
@@ -2859,9 +2859,10 @@ var PrismiqClient = class {
|
|
|
2859
2859
|
* @param history - Previous conversation messages.
|
|
2860
2860
|
* @param currentSql - Current SQL in the editor (for context).
|
|
2861
2861
|
* @param signal - Optional AbortSignal for cancellation.
|
|
2862
|
+
* @param widgetContext - Optional widget context for targeted SQL generation.
|
|
2862
2863
|
* @yields StreamChunk objects as the response is generated.
|
|
2863
2864
|
*/
|
|
2864
|
-
async *streamChat(message, history, currentSql, signal) {
|
|
2865
|
+
async *streamChat(message, history, currentSql, signal, widgetContext) {
|
|
2865
2866
|
const url = `${this.endpoint}/llm/chat`;
|
|
2866
2867
|
const headers = {
|
|
2867
2868
|
"Content-Type": "application/json",
|
|
@@ -2874,14 +2875,18 @@ var PrismiqClient = class {
|
|
|
2874
2875
|
const token = await this.getToken();
|
|
2875
2876
|
headers["Authorization"] = `Bearer ${token}`;
|
|
2876
2877
|
}
|
|
2878
|
+
const body = {
|
|
2879
|
+
message,
|
|
2880
|
+
history,
|
|
2881
|
+
current_sql: currentSql
|
|
2882
|
+
};
|
|
2883
|
+
if (widgetContext) {
|
|
2884
|
+
body.widget_context = widgetContext;
|
|
2885
|
+
}
|
|
2877
2886
|
const response = await fetch(url, {
|
|
2878
2887
|
method: "POST",
|
|
2879
2888
|
headers,
|
|
2880
|
-
body: JSON.stringify(
|
|
2881
|
-
message,
|
|
2882
|
-
history,
|
|
2883
|
-
current_sql: currentSql
|
|
2884
|
-
}),
|
|
2889
|
+
body: JSON.stringify(body),
|
|
2885
2890
|
signal
|
|
2886
2891
|
});
|
|
2887
2892
|
if (!response.ok) {
|
|
@@ -4020,12 +4025,13 @@ function useLLMChat() {
|
|
|
4020
4025
|
const [streamingContent, setStreamingContent] = useState("");
|
|
4021
4026
|
const [suggestedSql, setSuggestedSql] = useState(null);
|
|
4022
4027
|
const [error, setError] = useState(null);
|
|
4028
|
+
const [statusMessage, setStatusMessage] = useState(null);
|
|
4023
4029
|
const abortRef = useRef(null);
|
|
4024
4030
|
const isStreamingRef = useRef(false);
|
|
4025
4031
|
const messagesRef = useRef([]);
|
|
4026
4032
|
messagesRef.current = messages;
|
|
4027
4033
|
const sendMessage = useCallback(
|
|
4028
|
-
async (message, currentSql) => {
|
|
4034
|
+
async (message, currentSql, widgetContext) => {
|
|
4029
4035
|
if (!client || isStreamingRef.current) return;
|
|
4030
4036
|
abortRef.current?.abort();
|
|
4031
4037
|
const controller = new AbortController();
|
|
@@ -4037,6 +4043,7 @@ function useLLMChat() {
|
|
|
4037
4043
|
setStreamingContent("");
|
|
4038
4044
|
setSuggestedSql(null);
|
|
4039
4045
|
setError(null);
|
|
4046
|
+
setStatusMessage(null);
|
|
4040
4047
|
let accumulatedText = "";
|
|
4041
4048
|
let lastSql = null;
|
|
4042
4049
|
try {
|
|
@@ -4048,22 +4055,28 @@ function useLLMChat() {
|
|
|
4048
4055
|
message,
|
|
4049
4056
|
history,
|
|
4050
4057
|
currentSql,
|
|
4051
|
-
controller.signal
|
|
4058
|
+
controller.signal,
|
|
4059
|
+
widgetContext
|
|
4052
4060
|
)) {
|
|
4053
4061
|
if (controller.signal.aborted) break;
|
|
4054
4062
|
switch (chunk.type) {
|
|
4055
4063
|
case "text":
|
|
4056
4064
|
accumulatedText += chunk.content ?? "";
|
|
4057
4065
|
setStreamingContent(accumulatedText);
|
|
4066
|
+
setStatusMessage(null);
|
|
4058
4067
|
break;
|
|
4059
4068
|
case "sql":
|
|
4060
4069
|
lastSql = chunk.content ?? null;
|
|
4061
4070
|
setSuggestedSql(lastSql);
|
|
4062
4071
|
break;
|
|
4072
|
+
case "status":
|
|
4073
|
+
setStatusMessage(chunk.content ?? null);
|
|
4074
|
+
break;
|
|
4063
4075
|
case "error":
|
|
4064
4076
|
setError(chunk.content ?? "Unknown error");
|
|
4065
4077
|
break;
|
|
4066
4078
|
case "done":
|
|
4079
|
+
setStatusMessage(null);
|
|
4067
4080
|
break;
|
|
4068
4081
|
}
|
|
4069
4082
|
}
|
|
@@ -4074,6 +4087,7 @@ function useLLMChat() {
|
|
|
4074
4087
|
} finally {
|
|
4075
4088
|
isStreamingRef.current = false;
|
|
4076
4089
|
setIsStreaming(false);
|
|
4090
|
+
setStatusMessage(null);
|
|
4077
4091
|
if (accumulatedText) {
|
|
4078
4092
|
const assistantMsg = {
|
|
4079
4093
|
role: "assistant",
|
|
@@ -4098,6 +4112,7 @@ function useLLMChat() {
|
|
|
4098
4112
|
setSuggestedSql(null);
|
|
4099
4113
|
setError(null);
|
|
4100
4114
|
setIsStreaming(false);
|
|
4115
|
+
setStatusMessage(null);
|
|
4101
4116
|
}, []);
|
|
4102
4117
|
return {
|
|
4103
4118
|
messages,
|
|
@@ -4106,7 +4121,8 @@ function useLLMChat() {
|
|
|
4106
4121
|
suggestedSql,
|
|
4107
4122
|
sendMessage,
|
|
4108
4123
|
clearHistory,
|
|
4109
|
-
error
|
|
4124
|
+
error,
|
|
4125
|
+
statusMessage
|
|
4110
4126
|
};
|
|
4111
4127
|
}
|
|
4112
4128
|
var nodeStyles = {
|
|
@@ -9457,7 +9473,7 @@ function ChatBubble({ message, onApplySql }) {
|
|
|
9457
9473
|
return /* @__PURE__ */ jsx("span", { children: part.value }, i);
|
|
9458
9474
|
}) });
|
|
9459
9475
|
}
|
|
9460
|
-
function ChatPanel({ currentSql, onApplySql }) {
|
|
9476
|
+
function ChatPanel({ currentSql, onApplySql, widgetContext }) {
|
|
9461
9477
|
const { theme } = useTheme();
|
|
9462
9478
|
const {
|
|
9463
9479
|
messages,
|
|
@@ -9466,7 +9482,8 @@ function ChatPanel({ currentSql, onApplySql }) {
|
|
|
9466
9482
|
suggestedSql,
|
|
9467
9483
|
sendMessage,
|
|
9468
9484
|
clearHistory,
|
|
9469
|
-
error
|
|
9485
|
+
error,
|
|
9486
|
+
statusMessage
|
|
9470
9487
|
} = useLLMChat();
|
|
9471
9488
|
const [input, setInput] = useState("");
|
|
9472
9489
|
const messagesEndRef = useRef(null);
|
|
@@ -9477,8 +9494,8 @@ function ChatPanel({ currentSql, onApplySql }) {
|
|
|
9477
9494
|
const trimmed = input.trim();
|
|
9478
9495
|
if (!trimmed) return;
|
|
9479
9496
|
setInput("");
|
|
9480
|
-
void sendMessage(trimmed, currentSql);
|
|
9481
|
-
}, [input, currentSql, sendMessage]);
|
|
9497
|
+
void sendMessage(trimmed, currentSql, widgetContext);
|
|
9498
|
+
}, [input, currentSql, widgetContext, sendMessage]);
|
|
9482
9499
|
const handleKeyDown = useCallback(
|
|
9483
9500
|
(e) => {
|
|
9484
9501
|
if (e.key === "Enter" && !e.shiftKey) {
|
|
@@ -9599,6 +9616,24 @@ function ChatPanel({ currentSql, onApplySql }) {
|
|
|
9599
9616
|
"\u258D"
|
|
9600
9617
|
] }),
|
|
9601
9618
|
isStreaming && !streamingContent && /* @__PURE__ */ jsx("div", { style: streamingStyle, "data-testid": "chat-streaming", children: "Thinking..." }),
|
|
9619
|
+
isStreaming && statusMessage && /* @__PURE__ */ jsxs(
|
|
9620
|
+
"div",
|
|
9621
|
+
{
|
|
9622
|
+
style: {
|
|
9623
|
+
display: "flex",
|
|
9624
|
+
alignItems: "center",
|
|
9625
|
+
gap: theme.spacing.xs,
|
|
9626
|
+
fontSize: theme.fontSizes.xs,
|
|
9627
|
+
color: theme.colors.textMuted,
|
|
9628
|
+
padding: `${theme.spacing.xs} 0`
|
|
9629
|
+
},
|
|
9630
|
+
"data-testid": "chat-status",
|
|
9631
|
+
children: [
|
|
9632
|
+
/* @__PURE__ */ jsx(Icon, { name: "sync", size: 12 }),
|
|
9633
|
+
/* @__PURE__ */ jsx("span", { children: statusMessage })
|
|
9634
|
+
]
|
|
9635
|
+
}
|
|
9636
|
+
),
|
|
9602
9637
|
/* @__PURE__ */ jsx("div", { ref: messagesEndRef })
|
|
9603
9638
|
] }),
|
|
9604
9639
|
error && /* @__PURE__ */ jsx("div", { style: errorStyle, "data-testid": "chat-error", children: error }),
|
|
@@ -9633,5 +9668,5 @@ function ChatPanel({ currentSql, onApplySql }) {
|
|
|
9633
9668
|
}
|
|
9634
9669
|
|
|
9635
9670
|
export { AggregationPicker, AnalyticsProvider, AutoSaveIndicator, Badge, Button, CalculatedFieldBuilder, ChatBubble, ChatPanel, Checkbox, CollapsibleSection, ColorPaletteSelector, ColumnNode, ColumnSelector, CrossFilterProvider, CustomSQLEditor, Dialog, DialogFooter, DialogHeader, Dropdown, DropdownItem, DropdownSeparator, EmptyDashboard, EmptyState, ErrorBoundary, ErrorFallback, ExpressionEditor, FilterBuilder, FilterRow, FilterValueInput, Icon, Input, JoinBuilder, JoinRow, NoData, NoResults, Pagination, PrismiqClient, PrismiqError, QueryBuilder, QueryBuilderToolbar, QueryPreview, ResultsTable, SavedQueryPicker, SchemaExplorer, Select, SelectedColumn, Skeleton, SkeletonChart, SkeletonMetricCard, SkeletonTable, SkeletonText, SortBuilder, SortRow, TableCell, TableHeader, TableNode, TableRow, TableSelector, TimeSeriesConfig, Tooltip, WidgetErrorBoundary, useAnalytics, useAnalyticsCallbacks, useChartData, useCrossFilterOptional, useCustomSQL, useDashboard, useDashboardMutations, useDashboardPinStatus, useDashboards, useDebouncedLayoutSave, useLLMChat, useLLMStatus, usePinMutations, usePinnedDashboards, useQuery, useSavedQueries, useSchema };
|
|
9636
|
-
//# sourceMappingURL=chunk-
|
|
9637
|
-
//# sourceMappingURL=chunk-
|
|
9671
|
+
//# sourceMappingURL=chunk-VEFYFB5H.js.map
|
|
9672
|
+
//# sourceMappingURL=chunk-VEFYFB5H.js.map
|