@axiom-lattice/react-sdk 2.0.1 → 2.0.3

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
@@ -268,6 +268,12 @@ function useChat(threadId, options = {}) {
268
268
  streamingMessage: null
269
269
  }));
270
270
  }, []);
271
+ const clearError = useCallback(() => {
272
+ setState((prev) => ({
273
+ ...prev,
274
+ error: null
275
+ }));
276
+ }, []);
271
277
  useEffect(() => {
272
278
  if (threadId) {
273
279
  loadMessages();
@@ -286,7 +292,8 @@ function useChat(threadId, options = {}) {
286
292
  sendMessage,
287
293
  stopStreaming,
288
294
  loadMessages,
289
- clearMessages
295
+ clearMessages,
296
+ clearError
290
297
  };
291
298
  }
292
299
 
@@ -1530,6 +1537,7 @@ import {
1530
1537
  Welcome
1531
1538
  } from "@ant-design/x";
1532
1539
  import {
1540
+ Alert as Alert2,
1533
1541
  Avatar,
1534
1542
  Badge,
1535
1543
  Button as Button3,
@@ -1610,10 +1618,12 @@ var Chating = ({
1610
1618
  tenant_id,
1611
1619
  messages,
1612
1620
  isLoading,
1621
+ error,
1613
1622
  sendMessage,
1614
1623
  stopStreaming,
1615
1624
  onOpenSidePanel,
1616
1625
  onReminderClick,
1626
+ onClearError,
1617
1627
  styles,
1618
1628
  reminderCount,
1619
1629
  handleMDResponseEvent,
@@ -1658,7 +1668,7 @@ var Chating = ({
1658
1668
  }
1659
1669
  );
1660
1670
  }
1661
- } catch (error) {
1671
+ } catch (error2) {
1662
1672
  }
1663
1673
  const tool_calls_md = message2.tool_calls?.map((tool_call) => {
1664
1674
  return `\`\`\`tool_call
@@ -1708,8 +1718,8 @@ ${JSON.stringify(tool_call)}
1708
1718
  element.action(jsonData);
1709
1719
  }
1710
1720
  }
1711
- } catch (error) {
1712
- console.error(error);
1721
+ } catch (error2) {
1722
+ console.error(error2);
1713
1723
  }
1714
1724
  }
1715
1725
  }
@@ -1875,7 +1885,7 @@ ${JSON.stringify(tool_call)}
1875
1885
  if (Element) {
1876
1886
  let childrenData;
1877
1887
  try {
1878
- } catch (error) {
1888
+ } catch (error2) {
1879
1889
  }
1880
1890
  return /* @__PURE__ */ jsx10(
1881
1891
  Element,
@@ -1924,6 +1934,16 @@ ${JSON.stringify(tool_call)}
1924
1934
  }
1925
1935
  ) : /* @__PURE__ */ jsx10("div", { style: { flex: 1 } }),
1926
1936
  isLoading ? /* @__PURE__ */ jsx10("div", { children: /* @__PURE__ */ jsx10(Bubble, { loading: isLoading, variant: "borderless" }) }) : /* @__PURE__ */ jsx10(Prompts, { items: senderPromptsItems, onItemClick: onPromptsItemClick }),
1937
+ error && /* @__PURE__ */ jsx10("div", { style: { padding: "0 16px 8px" }, children: /* @__PURE__ */ jsx10(
1938
+ Alert2,
1939
+ {
1940
+ type: "error",
1941
+ banner: true,
1942
+ closable: true,
1943
+ onClose: () => onClearError?.(),
1944
+ message: `${error.message}`
1945
+ }
1946
+ ) }),
1927
1947
  /* @__PURE__ */ jsx10(
1928
1948
  Sender,
1929
1949
  {