AI Chat with Model Selection
blocks/ai-02FreeBlock
A ai chat with model selection block.
Install it
npx shadcn@latest add https://blocks.so/r/ai-02.jsonSource
1'use client';23import {4 IconAlertTriangle,5 IconArrowUp,6 IconCloud,7 IconFileSpark,8 IconGauge,9 IconPhotoScan,10} from '@tabler/icons-react';11import { useRef, useState } from 'react';12import { Button } from '@/components/ui/button';13import {14 Select,15 SelectContent,16 SelectItem,17 SelectTrigger,18 SelectValue,19} from '@/components/ui/select';20import { Textarea } from '@/components/ui/textarea';21import { cn } from '@/lib/utils';2223const PROMPTS = [24 {25 icon: IconFileSpark,26 text: 'Write documentation',27 prompt:28 'Write comprehensive documentation for this codebase, including setup instructions, API references, and usage examples.',29 },30 {31 icon: IconGauge,32 text: 'Optimize performance',33 prompt:34 'Analyze the codebase for performance bottlenecks and suggest optimizations to improve loading times and runtime efficiency.',35 },36 {37 icon: IconAlertTriangle,38 text: 'Find and fix 3 bugs',39 prompt:40 'Scan through the codebase to identify and fix 3 critical bugs, providing detailed explanations for each fix.',41 },42];4344const MODELS = [45 {46 value: 'gpt-5',47 name: 'GPT-5',48 description: 'Most advanced model',49 max: true,50 },51 {52 value: 'gpt-4o',53 name: 'GPT-4o',54 description: 'Fast and capable',55 },56 {57 value: 'gpt-4',58 name: 'GPT-4',59 description: 'Reliable and accurate',60 },61 {62 value: 'claude-3.5',63 name: 'Claude 3.5 Sonnet',64 description: 'Great for coding tasks',65 },66];6768export default function Ai02() {69 const [inputValue, setInputValue] = useState('');70 const [selectedModel, setSelectedModel] = useState(MODELS[0]);71 const inputRef = useRef<HTMLTextAreaElement>(null);7273 const handlePromptClick = (prompt: string) => {74 if (inputRef.current) {75 inputRef.current.value = prompt;76 setInputValue(prompt);77 inputRef.current.focus();78 }79 };8081 const handleModelChange = (value: string) => {82 const model = MODELS.find((m) => m.value === value);83 if (model) {84 setSelectedModel(model);85 }86 };8788 const renderMaxBadge = () => (89 <div className="flex h-[14px] items-center gap-1.5 rounded border border-border px-1 py-0">90 <span91 className="font-bold text-[9px] uppercase"92 style={{93 background:94 'linear-gradient(to right, rgb(129, 161, 193), rgb(125, 124, 155))',95 WebkitBackgroundClip: 'text',96 WebkitTextFillColor: 'transparent',97 }}98 >99 MAX100 </span>101// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from blocks
All 76 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| AI Chat with Voice Inputai-01 | blocks | Blocks | Free | 1 dep | |
| AI Chat Compact Interfaceai-03 | blocks | Blocks | Free | 1 dep | |
| AI Chat with File Attachmentsai-04 | blocks | Blocks | Free | 1 dep | |
| AI Elements Chatai-05 | blocks | Blocks | Free | 2 deps | |
| Command Menu with Groupscommand-menu-01 | blocks | Blocks | Free | 1 dep | |
| Command Menu with Keyboard Shortcutscommand-menu-02 | blocks | Blocks | Free | 1 dep | |
| Command Menu with Documentation Searchcommand-menu-03 | blocks | Blocks | Free | 1 dep | |
| Dialog Confirmationdialog-01 | blocks | Blocks | Free | 1 dep |
