@rodrigocoliveira/agno-react 1.1.4 → 1.1.6

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/ui.mjs CHANGED
@@ -2719,7 +2719,8 @@ function AgnoMessageItem({
2719
2719
  showToolCalls = true,
2720
2720
  showFilePreview = true,
2721
2721
  showImageLightbox = true,
2722
- formatTimestamp
2722
+ formatTimestamp,
2723
+ toolResultRenderers
2723
2724
  }) {
2724
2725
  const isUser = message.role === "user";
2725
2726
  const hasError = message.streamingError;
@@ -2919,6 +2920,15 @@ function AgnoMessageItem({
2919
2920
  }, tool.tool_call_id, false, undefined, this);
2920
2921
  })
2921
2922
  }, undefined, false, undefined, this),
2923
+ toolResultRenderers && message.tool_calls?.map((tool) => {
2924
+ const renderer = toolResultRenderers[tool.tool_name];
2925
+ const content = tool.result ?? tool.content;
2926
+ if (!renderer || !content)
2927
+ return null;
2928
+ return /* @__PURE__ */ jsxDEV35("div", {
2929
+ children: renderer(tool.tool_args, content)
2930
+ }, `result-${tool.tool_call_id}`, false, undefined, this);
2931
+ }),
2922
2932
  renderMedia ? renderMedia(message) : (() => {
2923
2933
  const mediaClassName = classNames?.assistant?.media;
2924
2934
  return /* @__PURE__ */ jsxDEV35(Fragment5, {
@@ -3459,11 +3469,14 @@ function AgnoChatRoot({
3459
3469
  children,
3460
3470
  toolHandlers = {},
3461
3471
  autoExecuteTools = true,
3472
+ toolResultRenderers,
3462
3473
  className,
3463
3474
  ...divProps
3464
3475
  }) {
3465
3476
  const chat = useAgnoChat();
3466
- const toolExec = useAgnoToolExecution(toolHandlers, autoExecuteTools);
3477
+ const toolExec = useAgnoToolExecution(toolHandlers, autoExecuteTools, {
3478
+ skipHydration: toolResultRenderers ? Object.keys(toolResultRenderers) : undefined
3479
+ });
3467
3480
  const containerRef = useRef6(null);
3468
3481
  const sendRef = useRef6(chat.sendMessage);
3469
3482
  sendRef.current = chat.sendMessage;
@@ -3513,7 +3526,8 @@ function AgnoChatRoot({
3513
3526
  executionError,
3514
3527
  handleSend,
3515
3528
  inputDisabled: isStreaming || isPaused,
3516
- dropZoneContainerRef: containerRef
3529
+ dropZoneContainerRef: containerRef,
3530
+ toolResultRenderers
3517
3531
  }), [
3518
3532
  messages,
3519
3533
  sendMessage,
@@ -3532,7 +3546,8 @@ function AgnoChatRoot({
3532
3546
  executeTools,
3533
3547
  continueWithResults,
3534
3548
  executionError,
3535
- handleSend
3549
+ handleSend,
3550
+ toolResultRenderers
3536
3551
  ]);
3537
3552
  return /* @__PURE__ */ jsxDEV37(AgnoChatContext.Provider, {
3538
3553
  value: contextValue,
@@ -3612,9 +3627,11 @@ function AgnoChatMessages({
3612
3627
  suggestedPrompts = DEFAULT_PROMPTS,
3613
3628
  children,
3614
3629
  showThinkingIndicator = true,
3615
- renderThinkingIndicator
3630
+ renderThinkingIndicator,
3631
+ toolResultRenderers: propToolResultRenderers
3616
3632
  }) {
3617
- const { messages, isStreaming } = useAgnoChatContext();
3633
+ const { messages, isStreaming, toolResultRenderers: contextToolResultRenderers } = useAgnoChatContext();
3634
+ const toolResultRenderers = propToolResultRenderers ?? contextToolResultRenderers;
3618
3635
  const lastMessage = messages[messages.length - 1];
3619
3636
  const isThinking = showThinkingIndicator && isStreaming && (!lastMessage || lastMessage.role !== "user") && !lastMessage?.content;
3620
3637
  let lastAssistantIndex = -1;
@@ -3636,7 +3653,8 @@ function AgnoChatMessages({
3636
3653
  ...renderContent !== undefined && { renderContent },
3637
3654
  ...renderMedia !== undefined && { renderMedia },
3638
3655
  ...formatTimestamp !== undefined && { formatTimestamp },
3639
- ...messageClassNames !== undefined && { classNames: messageClassNames }
3656
+ ...messageClassNames !== undefined && { classNames: messageClassNames },
3657
+ ...toolResultRenderers !== undefined && { toolResultRenderers }
3640
3658
  };
3641
3659
  const resolvedEmptyState = children ?? emptyState ?? /* @__PURE__ */ jsxDEV39("div", {
3642
3660
  className: "flex flex-col items-center gap-6",
@@ -4074,4 +4092,4 @@ export {
4074
4092
  Accordion
4075
4093
  };
4076
4094
 
4077
- //# debugId=6E9B25001B68B11264756E2164756E21
4095
+ //# debugId=1E8D621BCAD3259064756E2164756E21