import { useState } from "react"; import { Popover, PopoverContent, PopoverTrigger, } from "@/components/ui/popover"; import { Button } from "@/components/ui/button"; import { useAiSettings, useSaveAiSettings } from "@/hooks/use-ai"; import { Settings } from "lucide-react"; import { toast } from "sonner"; import { AiSettingsFields } from "./AiSettingsFields"; export function AiSettingsPopover() { const { data: settings } = useAiSettings(); const saveMutation = useSaveAiSettings(); const [url, setUrl] = useState(null); const [model, setModel] = useState(null); const currentUrl = url ?? settings?.ollama_url ?? "http://localhost:11434"; const currentModel = model ?? settings?.model ?? ""; const handleSave = () => { saveMutation.mutate( { provider: "ollama", ollama_url: currentUrl, model: currentModel }, { onSuccess: () => toast.success("AI settings saved"), onError: (err) => toast.error("Failed to save AI settings", { description: String(err), }), } ); }; return (

Ollama Settings

); }