@assistant-ui/react 0.5.45 → 0.5.46
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 +13 -5
- package/dist/index.d.ts +13 -5
- package/dist/index.js +33 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +33 -13
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
@@ -2156,6 +2156,7 @@ var makeAssistantTool = (tool) => {
|
|
2156
2156
|
useAssistantTool(tool);
|
2157
2157
|
return null;
|
2158
2158
|
};
|
2159
|
+
Tool.unstable_tool = tool;
|
2159
2160
|
return Tool;
|
2160
2161
|
};
|
2161
2162
|
|
@@ -2177,6 +2178,7 @@ var makeAssistantToolUI = (tool) => {
|
|
2177
2178
|
useAssistantToolUI(tool);
|
2178
2179
|
return null;
|
2179
2180
|
};
|
2181
|
+
ToolUI.unstable_tool = tool;
|
2180
2182
|
return ToolUI;
|
2181
2183
|
};
|
2182
2184
|
|
@@ -3033,21 +3035,22 @@ ContentPartPrimitiveInProgress.displayName = "ContentPartPrimitive.InProgress";
|
|
3033
3035
|
|
3034
3036
|
// src/primitives/message/MessageContent.tsx
|
3035
3037
|
import { jsx as jsx22, jsxs as jsxs3 } from "react/jsx-runtime";
|
3038
|
+
var ToolUIDisplay = ({
|
3039
|
+
UI,
|
3040
|
+
...props
|
3041
|
+
}) => {
|
3042
|
+
const { useToolUIs } = useAssistantContext();
|
3043
|
+
const Render = useToolUIs((s) => s.getToolUI(props.part.toolName)) ?? UI;
|
3044
|
+
if (!Render) return null;
|
3045
|
+
return /* @__PURE__ */ jsx22(Render, { ...props });
|
3046
|
+
};
|
3036
3047
|
var defaultComponents = {
|
3037
3048
|
Text: () => /* @__PURE__ */ jsxs3("p", { style: { whiteSpace: "pre-line" }, children: [
|
3038
3049
|
/* @__PURE__ */ jsx22(ContentPartPrimitiveText, {}),
|
3039
3050
|
/* @__PURE__ */ jsx22(ContentPartPrimitiveInProgress, { children: /* @__PURE__ */ jsx22("span", { style: { fontFamily: "revert" }, children: " \u25CF" }) })
|
3040
3051
|
] }),
|
3041
3052
|
Image: () => /* @__PURE__ */ jsx22(ContentPartPrimitiveImage, {}),
|
3042
|
-
UI: () => /* @__PURE__ */ jsx22(ContentPartPrimitiveDisplay, {})
|
3043
|
-
tools: {
|
3044
|
-
Fallback: (props) => {
|
3045
|
-
const { useToolUIs } = useAssistantContext();
|
3046
|
-
const Render = useToolUIs((s) => s.getToolUI(props.part.toolName));
|
3047
|
-
if (!Render) return null;
|
3048
|
-
return /* @__PURE__ */ jsx22(Render, { ...props });
|
3049
|
-
}
|
3050
|
-
}
|
3053
|
+
UI: () => /* @__PURE__ */ jsx22(ContentPartPrimitiveDisplay, {})
|
3051
3054
|
};
|
3052
3055
|
var MessageContentPartComponent = ({
|
3053
3056
|
components: {
|
@@ -3055,7 +3058,7 @@ var MessageContentPartComponent = ({
|
|
3055
3058
|
Text: Text2 = defaultComponents.Text,
|
3056
3059
|
Image: Image2 = defaultComponents.Image,
|
3057
3060
|
UI = defaultComponents.UI,
|
3058
|
-
tools: { by_name = {}, Fallback: Fallback2 =
|
3061
|
+
tools: { by_name = {}, Fallback: Fallback2 = void 0 } = {}
|
3059
3062
|
} = {}
|
3060
3063
|
}) => {
|
3061
3064
|
const { useThreadActions } = useThreadContext();
|
@@ -3086,7 +3089,15 @@ var MessageContentPartComponent = ({
|
|
3086
3089
|
toolCallId: part.toolCallId,
|
3087
3090
|
result
|
3088
3091
|
});
|
3089
|
-
return /* @__PURE__ */ jsx22(
|
3092
|
+
return /* @__PURE__ */ jsx22(
|
3093
|
+
ToolUIDisplay,
|
3094
|
+
{
|
3095
|
+
UI: Tool,
|
3096
|
+
part,
|
3097
|
+
status,
|
3098
|
+
addResult
|
3099
|
+
}
|
3100
|
+
);
|
3090
3101
|
}
|
3091
3102
|
default:
|
3092
3103
|
const unhandledType = type;
|
@@ -3955,13 +3966,22 @@ var AssistantMessageContentWrapper = withDefaults("div", {
|
|
3955
3966
|
className: "aui-assistant-message-content"
|
3956
3967
|
});
|
3957
3968
|
var AssistantMessageContent = forwardRef22(({ components: componentsProp, ...rest }, ref) => {
|
3958
|
-
const { assistantMessage: { components = {} } = {} } = useThreadConfig();
|
3969
|
+
const { tools, assistantMessage: { components = {} } = {} } = useThreadConfig();
|
3959
3970
|
return /* @__PURE__ */ jsx36(AssistantMessageContentWrapper, { ...rest, ref, children: /* @__PURE__ */ jsx36(
|
3960
3971
|
message_exports.Content,
|
3961
3972
|
{
|
3962
3973
|
components: {
|
3963
3974
|
...componentsProp,
|
3964
|
-
Text: componentsProp?.Text ?? components.Text ?? content_part_default.Text
|
3975
|
+
Text: componentsProp?.Text ?? components.Text ?? content_part_default.Text,
|
3976
|
+
tools: {
|
3977
|
+
by_name: !tools ? void 0 : Object.fromEntries(
|
3978
|
+
tools.map((t) => [
|
3979
|
+
t.unstable_tool.toolName,
|
3980
|
+
t.unstable_tool.render
|
3981
|
+
])
|
3982
|
+
),
|
3983
|
+
Fallback: components.ToolFallback
|
3984
|
+
}
|
3965
3985
|
}
|
3966
3986
|
}
|
3967
3987
|
) });
|