UNPKG

@copilotkit/react-ui

Version:

<img src="https://github.com/user-attachments/assets/0a6b64d9-e193-4940-a3f6-60334ac34084" alt="banner" style="border-radius: 12px; border: 2px solid #d6d4fa;" />

34 lines (33 loc) 1.33 kB
// src/components/chat/messages/ImageRenderer.tsx import { useState } from "react"; import { jsx, jsxs } from "react/jsx-runtime"; var ImageRenderer = ({ image, content, className = "" }) => { const [imageError, setImageError] = useState(false); const imageSrc = `data:image/${image.format};base64,${image.bytes}`; const altText = content || "User uploaded image"; const handleImageError = () => { setImageError(true); }; if (imageError) { return /* @__PURE__ */ jsxs("div", { className: `copilotKitImageRendering copilotKitImageRenderingError ${className}`, children: [ /* @__PURE__ */ jsx("div", { className: "copilotKitImageRenderingErrorMessage", children: "Failed to load image" }), content && /* @__PURE__ */ jsx("div", { className: "copilotKitImageRenderingContent", children: content }) ] }); } return /* @__PURE__ */ jsxs("div", { className: `copilotKitImageRendering ${className}`, children: [ /* @__PURE__ */ jsx( "img", { src: imageSrc, alt: altText, className: "copilotKitImageRenderingImage", onError: handleImageError } ), content && /* @__PURE__ */ jsx("div", { className: "copilotKitImageRenderingContent", children: content }) ] }); }; export { ImageRenderer }; //# sourceMappingURL=chunk-DBKRAOH7.mjs.map