"use client"; import type { ToolCallMessagePartComponent } from "@assistant-ui/react"; import { MapPinIcon, Loader2Icon } from "lucide-react"; type LocationArgs = { name: string; address?: string; lat: number; lng: number; }; type LocationResult = { success: boolean; }; export const LocationToolUI: ToolCallMessagePartComponent< LocationArgs, LocationResult > = function LocationUI({ args, status }) { if (status.type === "running" && (args.lat == null || args.lng == null)) { return (
Loading location...
); } const { name, address, lat, lng } = args; if (lat == null || lng == null) return null; const mapSrc = `https://www.openstreetmap.org/export/embed.html?bbox=${lng - 0.01},${lat - 0.01},${lng + 0.01},${lat + 0.01}&layer=mapnik&marker=${lat},${lng}`; return (

{name}

{address && (

{address}

)}