@spteck/react-controls-v2 2.0.13 → 2.0.15
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/components/aiAssistant/AIAssistant.d.ts.map +1 -1
- package/dist/index.js +17 -17
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +68 -14
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -25667,20 +25667,40 @@ const AIAssistant = (props) => {
|
|
|
25667
25667
|
try {
|
|
25668
25668
|
await sendRequest(endpoint, payload, void 0, (chunk) => {
|
|
25669
25669
|
currentResponse += chunk;
|
|
25670
|
-
|
|
25671
|
-
|
|
25672
|
-
|
|
25673
|
-
|
|
25674
|
-
message:
|
|
25675
|
-
|
|
25676
|
-
|
|
25677
|
-
status: status ? status : "received"
|
|
25678
|
-
}
|
|
25679
|
-
});
|
|
25680
|
-
dispatch({
|
|
25681
|
-
type: "SET_IS_RUNNING"
|
|
25682
|
-
});
|
|
25670
|
+
dispatch({
|
|
25671
|
+
type: "UPDATE_LAST_ASSISTANT_MESSAGE",
|
|
25672
|
+
message: {
|
|
25673
|
+
...assistantMessage,
|
|
25674
|
+
message: currentResponse,
|
|
25675
|
+
status: "received"
|
|
25676
|
+
}
|
|
25683
25677
|
});
|
|
25678
|
+
if (onResponse) {
|
|
25679
|
+
onResponse(currentResponse).then((response) => {
|
|
25680
|
+
const { message, status } = response;
|
|
25681
|
+
dispatch({
|
|
25682
|
+
type: "UPDATE_LAST_ASSISTANT_MESSAGE",
|
|
25683
|
+
message: {
|
|
25684
|
+
...assistantMessage,
|
|
25685
|
+
message: message ? message : currentResponse,
|
|
25686
|
+
status: status ? status : "received"
|
|
25687
|
+
}
|
|
25688
|
+
});
|
|
25689
|
+
}).catch((err) => {
|
|
25690
|
+
console.error("onResponse callback error:", err);
|
|
25691
|
+
});
|
|
25692
|
+
}
|
|
25693
|
+
});
|
|
25694
|
+
dispatch({
|
|
25695
|
+
type: "UPDATE_LAST_ASSISTANT_MESSAGE",
|
|
25696
|
+
message: {
|
|
25697
|
+
...assistantMessage,
|
|
25698
|
+
message: currentResponse,
|
|
25699
|
+
status: "received"
|
|
25700
|
+
}
|
|
25701
|
+
});
|
|
25702
|
+
dispatch({
|
|
25703
|
+
type: "SET_IS_RUNNING"
|
|
25684
25704
|
});
|
|
25685
25705
|
} catch (err) {
|
|
25686
25706
|
console.error("Error during streaming:", err);
|
|
@@ -25734,6 +25754,40 @@ const AIAssistant = (props) => {
|
|
|
25734
25754
|
}
|
|
25735
25755
|
);
|
|
25736
25756
|
}
|
|
25757
|
+
const renderMessageContent = (message) => {
|
|
25758
|
+
if (typeof message !== "string") {
|
|
25759
|
+
return message;
|
|
25760
|
+
}
|
|
25761
|
+
const trimmedMessage = message.trim();
|
|
25762
|
+
try {
|
|
25763
|
+
const parsed = JSON.parse(trimmedMessage);
|
|
25764
|
+
if (parsed.type === "AdaptiveCard" && parsed.version) {
|
|
25765
|
+
return /* @__PURE__ */ jsx$2(
|
|
25766
|
+
AdaptiveCardHost,
|
|
25767
|
+
{
|
|
25768
|
+
card: parsed,
|
|
25769
|
+
context,
|
|
25770
|
+
onInvokeAction: (action) => {
|
|
25771
|
+
console.log("Adaptive Card action:", action);
|
|
25772
|
+
},
|
|
25773
|
+
onError: (error2) => {
|
|
25774
|
+
console.error("Adaptive Card error:", error2);
|
|
25775
|
+
}
|
|
25776
|
+
}
|
|
25777
|
+
);
|
|
25778
|
+
}
|
|
25779
|
+
} catch {
|
|
25780
|
+
}
|
|
25781
|
+
return /* @__PURE__ */ jsx$2("pre", { style: {
|
|
25782
|
+
whiteSpace: "pre-wrap",
|
|
25783
|
+
wordWrap: "break-word",
|
|
25784
|
+
fontFamily: "inherit",
|
|
25785
|
+
fontSize: "inherit",
|
|
25786
|
+
margin: 0,
|
|
25787
|
+
maxWidth: "100%",
|
|
25788
|
+
overflow: "auto"
|
|
25789
|
+
}, children: message });
|
|
25790
|
+
};
|
|
25737
25791
|
return /* @__PURE__ */ jsxs$1("div", { id: "aiAssistant", className: styles2.chatAIAssistantRoot, children: [
|
|
25738
25792
|
/* @__PURE__ */ jsx$2(Chat, { className: styles2.chatList, ref: chatListRef, children: messages.map(
|
|
25739
25793
|
(message, index) => message.senderName === "User" ? /* @__PURE__ */ jsx$2(
|
|
@@ -25760,7 +25814,7 @@ const AIAssistant = (props) => {
|
|
|
25760
25814
|
),
|
|
25761
25815
|
author: message.senderName,
|
|
25762
25816
|
timestamp: message.timeStamp,
|
|
25763
|
-
children: message.message
|
|
25817
|
+
children: renderMessageContent(message.message)
|
|
25764
25818
|
},
|
|
25765
25819
|
index
|
|
25766
25820
|
)
|