import { CheckCircle, Key, WarningCircle } from "@phosphor-icons/react"; import { Input } from "@/components/ui/Input"; import { Select } from "@/components/ui/Select"; import { useSettings } from "@/context/SettingsContext"; import { useConfig } from "@/hooks/useServerData"; import type { Provider } from "@/lib/types"; import { stripLeadingSymbols } from "@/lib/utils"; const KEY_META: Record< Provider, { label: string; store: "groq" | "gemini" | "hf"; link: string } > = { gemini: { label: "Google AI API Key", store: "gemini", link: "https://aistudio.google.com/app/apikey", }, groq: { label: "Groq API Key", store: "groq", link: "https://console.groq.com", }, hf: { label: "Endpoint token (optional)", store: "hf", link: "", }, }; /** Model dropdown + provider hint + the single dynamic API-key field. */ export function ModelSelector() { const { data: config } = useConfig(); const { selectedModel, setSelectedModel, provider, keys, setKey } = useSettings(); const models = config?.models ?? []; const current = models.find((m) => m.id === selectedModel); const meta = KEY_META[provider]; const keyValue = keys[meta.store]; return (