"use client"; import { ExampleNav } from "@/components/example-nav"; import { AssistantMessageGui } from "@/components/assistant-message-gui"; import { Thread, type ThreadComponents, } from "@/components/assistant-ui/thread"; import { AssistantRuntimeProvider, Suggestions, useAssistantInstructions, useAui, } from "@assistant-ui/react"; import { useChatRuntime } from "@assistant-ui/react-ai-sdk"; import { lastAssistantMessageIsCompleteWithToolCalls } from "ai"; import { renderGuiChatInstructions } from "@/lib/render-gui-tool"; const GuiChatInstructions = () => { useAssistantInstructions(renderGuiChatInstructions); return null; }; const GuiWelcome = () => { return (

Compose UI from a spec

Ask the agent to call render_gui with Card, Button, and Stack.

); }; const THREAD_COMPONENTS: ThreadComponents = { AssistantMessage: AssistantMessageGui, Welcome: GuiWelcome, }; export default function GuiChatPage() { const runtime = useChatRuntime({ sendAutomaticallyWhen: lastAssistantMessageIsCompleteWithToolCalls, }); const aui = useAui({ suggestions: Suggestions([ { title: "Welcome card", label: "with a Get started button", prompt: "Show me a welcome card with a Get started button using render_gui.", }, { title: "Stats dashboard", label: "revenue and users", prompt: "Use render_gui to show a stats card with Revenue $124k and Active Users 8.2k.", }, ]), }); return (
); }