@spteck/react-controls-v2 2.0.13 → 2.0.14

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/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
- onResponse == null ? void 0 : onResponse(currentResponse).then((response) => {
25671
- const { message, status } = response;
25672
- dispatch({
25673
- type: "UPDATE_LAST_ASSISTANT_MESSAGE",
25674
- message: {
25675
- ...assistantMessage,
25676
- message: message ? message : currentResponse,
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);