"use client"; import { useRouter } from "next/navigation"; import { useState } from "react"; import { toast } from "sonner"; import { FileRoleBadge } from "@/components/labels"; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"; import { Checkbox } from "@/components/ui/checkbox"; import { FILE_ROLES, type FileRole } from "@/lib/file-roles"; import { RECOMMENDABLE_ROLES } from "@/lib/recommend"; /** Example file name per kind, so the badge shows the configured label and color. */ const EXAMPLE: Partial> = { template: "chat_template.jinja", mtp: "mtp-model.gguf", vision: "mmproj-F16.gguf", draft: "model-draft.gguf", config: "config.json", tokenizer: "tokenizer.json", imatrix: "imatrix.dat", adapter: "adapter_model.safetensors", docs: "README.md", }; const HINT: Partial> = { mtp: "The variant with the same quant as your model file, otherwise the closest one.", vision: "One mmproj file: same quant if there is one, otherwise F16, BF16, Q8_0, F32.", draft: "One draft model, picked like MTP.", imatrix: "Only needed to make your own quants.", config: "GGUF files already contain it; useful for safetensors repos.", tokenizer: "GGUF files already contain it; useful for safetensors repos.", }; /** Which file kinds are selected automatically when you pick model weights. Saves on change. */ export function RecommendedSettings({ initial }: { initial: FileRole[] }) { const router = useRouter(); const [roles, setRoles] = useState(new Set(initial)); const [saving, setSaving] = useState(false); async function toggle(role: FileRole, on: boolean) { const before = roles; const next = new Set(roles); if (on) next.add(role); else next.delete(role); setRoles(next); setSaving(true); try { const res = await fetch("/api/settings/downloads", { method: "PUT", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ recommendedRoles: [...next] }), }); if (!res.ok) { const body = await res.json().catch(() => ({})); toast.error(body.error?.message ?? `Could not save (${res.status})`); setRoles(before); return; } router.refresh(); } finally { setSaving(false); } } return ( Recommended files When you pick model weights (a quant) in Add model or Download more, files of these kinds are selected along with them. You can still uncheck them before downloading.
{RECOMMENDABLE_ROLES.map((role) => ( ))}
); }