"use client"; import { useEffect, useState } from "react"; import { X, Settings } from "lucide-react"; import { useUserPrefs, type DevicePref } from "@/hooks/useUserPrefs"; export function SettingsButton({ onOpen }: { onOpen: () => void }) { return ( Settings ); } export function SettingsModal({ isOpen, onClose, }: { isOpen: boolean; onClose: () => void; }) { const { prefs, ready, update } = useUserPrefs(); const [tab, setTab] = useState<"general" | "execution">("general"); const [localPrompt, setLocalPrompt] = useState(""); const [device, setDevice] = useState("auto"); const [gpuIndex, setGpuIndex] = useState(0); const [numGpu, setNumGpu] = useState(1); useEffect(() => { if (!ready) return; setLocalPrompt(prefs.systemPrompt); setDevice(prefs.device); setGpuIndex(prefs.gpuIndex); setNumGpu(prefs.numGpu); }, [ready, prefs]); const handleSave = () => { update({ systemPrompt: localPrompt, device, gpuIndex, numGpu }); onClose(); }; if (!isOpen) return null; return ( Settings setTab("general")} > General setTab("execution")} > Execution {tab === "general" && ( System Prompt setLocalPrompt(e.target.value)} placeholder="Define how the AI should behave..." className="h-32 w-full resize-none rounded-md border border-border bg-background px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-accent" /> Sent at the start of a conversation to guide model behavior. )} {tab === "execution" && ( Device {(["auto", "cpu", "gpu"] as DevicePref[]).map((d) => ( setDevice(d)} className={`rounded-md border border-border px-3 py-1 text-sm ${ device === d ? "bg-[var(--surface)]" : "hover:bg-[var(--surface)]" }`} > {d.toUpperCase()} ))} CPU best-effort via num_gpu:0. For hard CPU-only, set CUDA_VISIBLE_DEVICES=-1 before starting Ollama. GPU Index (main_gpu) setGpuIndex(Number(e.target.value))} className="mt-1 w-full rounded-md border border-border bg-background px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-accent" min={0} /> Num GPUs (num_gpu) setNumGpu(Number(e.target.value))} className="mt-1 w-full rounded-md border border-border bg-background px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-accent" min={0} /> Auto: no options sent. GPU: sends num_gpu/main_gpu. CPU: sends num_gpu:0. )} Cancel Save ); }
Sent at the start of a conversation to guide model behavior.
CPU best-effort via num_gpu:0. For hard CPU-only, set CUDA_VISIBLE_DEVICES=-1 before starting Ollama.
Auto: no options sent. GPU: sends num_gpu/main_gpu. CPU: sends num_gpu:0.