"use client"; import { makeAssistantToolUI } from "@assistant-ui/react"; import { z } from "zod"; import { ImageIcon } from "lucide-react"; const DisplayImageArgsSchema = z.object({ url: z.string().optional(), alt: z.string().optional(), caption: z.string().optional(), }); const DisplayImageResultSchema = z.object({ url: z.string().optional(), alt: z.string().optional(), caption: z.string().optional(), }).passthrough(); type DisplayImageArgs = z.infer; type DisplayImageResult = z.infer; export const DisplayImageToolUI = makeAssistantToolUI({ toolName: "display_image", render: ({ args, result, status }) => { const isLoading = status.type === "running"; const imageUrl = result?.url ?? args?.url; const altText = result?.alt ?? args?.alt ?? "Image"; const caption = result?.caption ?? args?.caption; if (isLoading) { return (
Loading image...
); } if (!imageUrl) return null; return (
{altText} {caption && (

{caption}

)}
); }, });