@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.d.mts CHANGED
@@ -258,6 +258,7 @@ declare function useChat<T extends UseChatOptions>(threadId: string | null, opti
258
258
  stopStreaming: () => void;
259
259
  loadMessages: (limit?: number) => Promise<void>;
260
260
  clearMessages: () => void;
261
+ clearError: () => void;
261
262
  };
262
263
 
263
264
  /**
@@ -359,6 +360,7 @@ interface ChatingProps {
359
360
  tenant_id: string;
360
361
  messages: any[];
361
362
  isLoading: boolean;
363
+ error?: Error | null;
362
364
  sendMessage: (params: any) => void;
363
365
  stopStreaming: () => void;
364
366
  default_submit_message?: string;
@@ -367,6 +369,7 @@ interface ChatingProps {
367
369
  uploadAction?: string;
368
370
  onOpenSidePanel: (data: any) => void;
369
371
  onReminderClick: () => void;
372
+ onClearError?: () => void;
370
373
  styles: any;
371
374
  reminderCount: number;
372
375
  handleMDResponseEvent: (action: string, data?: any, message?: string, agent?: string) => void;
package/dist/index.d.ts CHANGED
@@ -258,6 +258,7 @@ declare function useChat<T extends UseChatOptions>(threadId: string | null, opti
258
258
  stopStreaming: () => void;
259
259
  loadMessages: (limit?: number) => Promise<void>;
260
260
  clearMessages: () => void;
261
+ clearError: () => void;
261
262
  };
262
263
 
263
264
  /**
@@ -359,6 +360,7 @@ interface ChatingProps {
359
360
  tenant_id: string;
360
361
  messages: any[];
361
362
  isLoading: boolean;
363
+ error?: Error | null;
362
364
  sendMessage: (params: any) => void;
363
365
  stopStreaming: () => void;
364
366
  default_submit_message?: string;
@@ -367,6 +369,7 @@ interface ChatingProps {
367
369
  uploadAction?: string;
368
370
  onOpenSidePanel: (data: any) => void;
369
371
  onReminderClick: () => void;
372
+ onClearError?: () => void;
370
373
  styles: any;
371
374
  reminderCount: number;
372
375
  handleMDResponseEvent: (action: string, data?: any, message?: string, agent?: string) => void;
package/dist/index.js CHANGED
@@ -321,6 +321,12 @@ function useChat(threadId, options = {}) {
321
321
  streamingMessage: null
322
322
  }));
323
323
  }, []);
324
+ const clearError = (0, import_react2.useCallback)(() => {
325
+ setState((prev) => ({
326
+ ...prev,
327
+ error: null
328
+ }));
329
+ }, []);
324
330
  (0, import_react2.useEffect)(() => {
325
331
  if (threadId) {
326
332
  loadMessages();
@@ -339,7 +345,8 @@ function useChat(threadId, options = {}) {
339
345
  sendMessage,
340
346
  stopStreaming,
341
347
  loadMessages,
342
- clearMessages
348
+ clearMessages,
349
+ clearError
343
350
  };
344
351
  }
345
352
 
@@ -1632,10 +1639,12 @@ var Chating = ({
1632
1639
  tenant_id,
1633
1640
  messages,
1634
1641
  isLoading,
1642
+ error,
1635
1643
  sendMessage,
1636
1644
  stopStreaming,
1637
1645
  onOpenSidePanel,
1638
1646
  onReminderClick,
1647
+ onClearError,
1639
1648
  styles,
1640
1649
  reminderCount,
1641
1650
  handleMDResponseEvent,
@@ -1680,7 +1689,7 @@ var Chating = ({
1680
1689
  }
1681
1690
  );
1682
1691
  }
1683
- } catch (error) {
1692
+ } catch (error2) {
1684
1693
  }
1685
1694
  const tool_calls_md = message2.tool_calls?.map((tool_call) => {
1686
1695
  return `\`\`\`tool_call
@@ -1730,8 +1739,8 @@ ${JSON.stringify(tool_call)}
1730
1739
  element.action(jsonData);
1731
1740
  }
1732
1741
  }
1733
- } catch (error) {
1734
- console.error(error);
1742
+ } catch (error2) {
1743
+ console.error(error2);
1735
1744
  }
1736
1745
  }
1737
1746
  }
@@ -1897,7 +1906,7 @@ ${JSON.stringify(tool_call)}
1897
1906
  if (Element) {
1898
1907
  let childrenData;
1899
1908
  try {
1900
- } catch (error) {
1909
+ } catch (error2) {
1901
1910
  }
1902
1911
  return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1903
1912
  Element,
@@ -1946,6 +1955,16 @@ ${JSON.stringify(tool_call)}
1946
1955
  }
1947
1956
  ) : /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { style: { flex: 1 } }),
1948
1957
  isLoading ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_x.Bubble, { loading: isLoading, variant: "borderless" }) }) : /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_x.Prompts, { items: senderPromptsItems, onItemClick: onPromptsItemClick }),
1958
+ error && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { style: { padding: "0 16px 8px" }, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1959
+ import_antd6.Alert,
1960
+ {
1961
+ type: "error",
1962
+ banner: true,
1963
+ closable: true,
1964
+ onClose: () => onClearError?.(),
1965
+ message: `${error.message}`
1966
+ }
1967
+ ) }),
1949
1968
  /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1950
1969
  import_x.Sender,
1951
1970
  {