"use client"; import { defineToolkit, useAui, AuiProvider, Suggestions, Tools, } from "@assistant-ui/react"; import { Thread } from "@/components/assistant-ui/thread"; import { PlusIcon } from "lucide-react"; const toolkit = defineToolkit({ browser_alert: { description: "Display a native browser alert dialog to the user.", parameters: { type: "object", properties: { message: { type: "string", description: "Text to display inside the alert dialog.", }, }, required: ["message"], }, execute: async ({ message }) => { alert(message); return { status: "shown" }; }, render: ({ args, result }) => (

browser_alert

Requested alert with message: {JSON.stringify(args.message)}

{result?.status === "shown" && (

Alert displayed in this tab.

)}
), }, }); function NewThreadButton() { const aui = useAui(); return ( ); } function ThreadWithSuggestions() { const aui = useAui({ suggestions: Suggestions([ { title: "Run a web search", label: "for recent AI news", prompt: "Search the web for the latest AI news.", }, { title: "Show a browser alert", label: "using the alert tool", prompt: "Show me a browser alert saying hello!", }, ]), }); return ( ); } export default function Home() { const aui = useAui({ tools: Tools({ toolkit }), }); return (
); }