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.
Components / AI Chat Interfaces
A dropdown model selector for choosing between AI models (GPT-4, Claude, Gemini) with model info badges and capability indicators.
State-of-the-art LLM from OpenAI, versatile in chat and coding tasks.
Install the core libraries required for this component.
npm install reactAdd the necessary Shadcn UI primitives.
npx shadcn-ui@latest add select badge input buttonimport { 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>
);
} 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>
);
}
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 |
Types and interfaces defined in this component.
interface AIModel {
id: string;
name: string;
capabilities: string[];
status: "active" | "beta" | "deprecated";
description: string;
} interface AIModel {
id: string;
name: string;
capabilities: string[];
status: "active" | "beta" | "deprecated";
description: string;
} Internal functions used to handle component logic.
| Function | Parameters |
|---|---|
| AIModelSelector01() | None |
React state variables managed within this component.
| Variable | Initial Value |
|---|---|
| searchQuery | "" |
All variable declarations found in this component.
| Name | Kind | Value |
|---|---|---|
| filteredModels | | models.filter((m) => |
| activeModel | | models.find((m) => m.id === selectedModel) |
Every JSX/HTML tag used in this component, with usage count and source.
| Tag | Count | Type | Source |
|---|---|---|---|
| <Badge> | 1× | | @/components/ui/badge |
| <SelectContent> | 1× | | @/components/ui/select |
| <SelectItem> | 1× | | @/components/ui/select |
| <SelectTrigger> | 1× | | @/components/ui/select |
| <SelectValue> | 1× | | @/components/ui/select |
| <Button> | 1× | | Native HTML |
| <div> | 5× | | Native HTML |
| <Input> | 1× | | Native HTML |
| <p> | 1× | | Native HTML |
| <Select> | 1× | | Native HTML |
| <span> | 2× | | Native HTML |
| <string> | 1× | | Native HTML |