Tool calling
prompt-kit/tool-callingFreeItem
A chatbot with tool calling feature. It uses prompt-kit, shadcn/ui, and AI SDK V5.
Live preview
live · rendered by the registry
Rendered by prompt-kit on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://raw.githubusercontent.com/ibelick/prompt-kit/HEAD/public/c/tool-calling.jsonSource
1"use client"23import {4 ChatContainerContent,5 ChatContainerRoot,6} from "@/components/prompt-kit/chat-container"7import { DotsLoader } from "@/components/prompt-kit/loader"8import {9 Message,10 MessageAction,11 MessageActions,12 MessageContent,13} from "@/components/prompt-kit/message"14import {15 PromptInput,16 PromptInputActions,17 PromptInputTextarea,18} from "@/components/prompt-kit/prompt-input"19import { Tool } from "@/components/prompt-kit/tool"20import type { ToolPart } from "@/components/prompt-kit/tool"21import { Button } from "@/components/ui/button"22import { cn } from "@/lib/utils"23import { useChat } from "@ai-sdk/react"24import { DefaultChatTransport } from "ai"25import type { UIMessage, UIMessagePart } from "ai"26import {27 AlertTriangle,28 ArrowUp,29 Copy,30 ThumbsDown,31 ThumbsUp,32} from "lucide-react"33import { memo, useState } from "react"3435type MessageComponentProps = {36 message: UIMessage37 isLastMessage: boolean38}3940const renderToolPart = (41 part: UIMessagePart<any, any>,42 index: number43): React.ReactNode => {44 if (!part.type?.startsWith("tool-")) return null4546 return <Tool key={`${part.type}-${index}`} toolPart={part as ToolPart} />47}4849export const MessageComponent = memo(50 ({ message, isLastMessage }: MessageComponentProps) => {51 const isAssistant = message?.role === "assistant"5253 return (54 <Message55 className={cn(56 "mx-auto flex w-full max-w-3xl flex-col gap-2 px-2 md:px-10",57 isAssistant ? "items-start" : "items-end"58 )}59 >60 {isAssistant ? (61 <div className="group flex w-full flex-col gap-0 space-y-2">62 <div className="w-full">63 {message?.parts64 .filter(65 (part: any) => part.type && part.type.startsWith("tool-")66 )67 .map((part: any, index: number) => renderToolPart(part, index))}68 </div>69 <MessageContent70 className="text-foreground prose w-full min-w-0 flex-1 rounded-lg bg-transparent p-0"71 markdown72 >73 {message?.parts74 .filter((part: any) => part.type === "text")75 .map((part: any) => part.text)76 .join("")}77 </MessageContent>7879 <MessageActions80 className={cn(81 "-ml-2.5 flex gap-0 opacity-0 transition-opacity duration-150 group-hover:opacity-100",82 isLastMessage && "opacity-100"83 )}84// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from prompt-kit
All 23 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Chatbotchatbot | prompt-kit | Other | Free | 10 deps · 8 files |
