Components / AI Chat Interfaces

AI Model Selector

A dropdown model selector for choosing between AI models (GPT-4, Claude, Gemini) with model info badges and capability indicators.

Live Preview — ai-model-selector-01
GPT-4

State-of-the-art LLM from OpenAI, versatile in chat and coding tasks.

ChatCodeReasoning

Installation

Dependencies

Install the core libraries required for this component.

npm
npm install react

Shadcn UI Setup

Add the necessary Shadcn UI primitives.

npm
npx shadcn-ui@latest add select badge input button

Source Code

ai-model-selector-01.tsx
import { useState } from "react";
import {
    Select,
    SelectTrigger,
    SelectValue,
    SelectContent,
    SelectItem,
    SelectGroup,
    SelectLabel,
    SelectSeparator,
} from "@/components/ui/select";
import { Badge } from "@/components/ui/badge";
import { Input } from "@/components/ui/input";
import { Button } from "@/components/ui/button";

interface AIModel {
    id: string;
    name: string;
    capabilities: string[];
    status: "active" | "beta" | "deprecated";
    description: string;
}

const models: AIModel[] = [
    {
        id: "gpt4",
        name: "GPT-4",
        capabilities: ["Chat", "Code", "Reasoning"],
        status: "active",
        description: "State-of-the-art LLM from OpenAI, versatile in chat and coding tasks.",
    },
    {
        id: "claude",
        name: "Claude",
        capabilities: ["Chat", "Summarization"],
        status: "beta",
        description: "Anthropic AI model focused on safe and coherent chat outputs.",
    },
    {
        id: "gemini",
        name: "Gemini",
        capabilities: ["Chat", "Reasoning", "Math"],
        status: "active",
        description: "Google’s Gemini AI for multi-modal reasoning tasks.",
    },
    {
        id: "custom-llm",
        name: "Custom LLM",
        capabilities: ["Custom"],
        status: "active",
        description: "Your own trained LLM integrated with the system.",
    },
];

export default function AIModelSelector01() {
    const [selectedModel, setSelectedModel] = useState<string>("gpt4");
    const [searchQuery, setSearchQuery] = useState("");

    // Filter models by search
    const filteredModels = models.filter((m) =>
        m.name.toLowerCase().includes(searchQuery.toLowerCase())
    );

    const activeModel = models.find((m) => m.id === selectedModel);

    return (
        <div className="flex flex-col gap-2 w-[320px]">
            {/* Search input */}
            <Input
                placeholder="Search AI models..."
                value={searchQuery}
                onChange={(e) => setSearchQuery(e.target.value)}
            />

            {/* Model dropdown */}
            <Select onValueChange={setSelectedModel} defaultValue={selectedModel}>
                <SelectTrigger className="w-full">
                    <SelectValue placeholder="Select model" />
                </SelectTrigger>
                <SelectContent>
                    {filteredModels.map((model) => (
                        <SelectItem key={model.id} value={model.id}>
                            <div className="flex flex-col">
                                <div className="flex items-center justify-between">
                                    <span>{model.name}</span>
                                </div>
                            </div>
                        </SelectItem>
                    ))}
                </SelectContent>
            </Select>

            {/* Model info */}
            {activeModel && (
                <div className="border border-border rounded-md p-2 text-sm flex flex-col gap-1">
                    <span className="font-medium">{activeModel.name}</span>
                    <p className="text-muted-foreground">{activeModel.description}</p>
                    <div className="flex gap-1 flex-wrap">
                        {activeModel.capabilities.map((cap) => (
                            <Badge key={cap} variant="outline" className="text-xs">
                                {cap}
                            </Badge>
                        ))}
                    </div>
                </div>
            )}

            {/* Optional action */}
            <Button size="sm" className="w-full mt-1">
                Configure Model
            </Button>
        </div>
    );
}

Shadcn Components

Primitives required in your @/components/ui directory.

Component Path
select @/components/ui/select
badge @/components/ui/badge
input @/components/ui/input
button @/components/ui/button

Type Reference

Types and interfaces defined in this component.

AIModel
interface AIModel {
    id: string;
    name: string;
    capabilities: string[];
    status: "active" | "beta" | "deprecated";
    description: string;
}

Functional Logic

Internal functions used to handle component logic.

Function Parameters
AIModelSelector01() None

State Management

React state variables managed within this component.

Variable Initial Value
searchQuery ""

Variables

All variable declarations found in this component.

Name Kind Value
filteredModels const models.filter((m) =>
activeModel const models.find((m) => m.id === selectedModel)

JSX Tags Usage

Every JSX/HTML tag used in this component, with usage count and source.

Tag Count Type Source
<Badge> Library @/components/ui/badge
<SelectContent> Library @/components/ui/select
<SelectItem> Library @/components/ui/select
<SelectTrigger> Library @/components/ui/select
<SelectValue> Library @/components/ui/select
<Button> Native Native HTML
<div> Native Native HTML
<Input> Native Native HTML
<p> Native Native HTML
<Select> Native Native HTML
<span> Native Native HTML
<string> Native Native HTML

Related Components

  • AI Chat Bubble — A conversational chat bubble component with typing indicator, avatar support, and message timestamps for AI chat interfaces.
  • AI Chat Input Bar — A modern chat input bar with send button, attachment support, and auto-resize textarea for AI conversation interfaces.
  • AI Chat Window — A full-featured AI chat window with message history, streaming response animation, and conversation management.
  • AI Streaming Text — A typewriter-style streaming text component that simulates token-by-token AI response generation with cursor animation.
  • AI Chat Sidebar — A conversation history sidebar listing previous AI chat sessions with search, date grouping, and active state indicators.
  • AI Response Actions — An action bar for AI responses with copy, regenerate, thumbs up/down, and share buttons with tooltip labels.