import { useState } from "react"; import { motion } from "framer-motion"; import { Settings, Server, Key, Sparkles, ChevronRight, ExternalLink, Eye, EyeOff, } from "lucide-react"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { ScrollArea } from "@/components/ui/scroll-area"; import { AppSettings, AIProvider } from "@/types/chat"; import { cn } from "@/lib/utils"; interface SettingsPanelProps { settings: AppSettings; onUpdate: (settings: Partial) => void; } const providers: { id: AIProvider; name: string; description: string; icon: React.ReactNode }[] = [ { id: "ollama", name: "Ollama", description: "Run AI models locally on your machine", icon: , }, { id: "openai", name: "OpenAI", description: "Use GPT-4, GPT-4o and other OpenAI models", icon: , }, ]; export function SettingsPanel({ settings, onUpdate }: SettingsPanelProps) { const [showApiKey, setShowApiKey] = useState(false); return (
{/* Header */}

Settings

{/* Provider Selection */}
{providers.map((provider) => ( onUpdate({ provider: provider.id })} className={cn( "w-full p-3 rounded-xl text-left transition-all glass-card", settings.provider === provider.id ? "border-primary/50 bg-primary/5" : "hover:bg-accent/50" )} >
{provider.icon}
{provider.name} {settings.provider === provider.id && ( Active )}

{provider.description}

))}
{/* Ollama Settings */} {settings.provider === "ollama" && (
onUpdate({ ollamaUrl: e.target.value })} placeholder="http://localhost:11434" className="mt-1.5 bg-input/50" />

Make sure Ollama is running with CORS enabled

onUpdate({ ollamaModel: e.target.value })} placeholder="llama3.2" className="mt-1.5 bg-input/50" />
)} {/* OpenAI Settings */} {settings.provider === "openai" && (
onUpdate({ openaiApiKey: e.target.value })} placeholder="sk-..." className="pr-10 bg-input/50" />

Your API key is stored locally in your browser

onUpdate({ openaiModel: e.target.value })} placeholder="gpt-4o-mini" className="mt-1.5 bg-input/50" />
)} {/* Help */}
); }