"use client"; import { usePoll } from "@/lib/use-poll"; import type { OverviewStats } from "@/lib/types"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; import { StatusBadge } from "./status-badge"; function tempColor(temp: number): string { if (temp < 50) return "text-green-400"; if (temp < 70) return "text-amber-400"; return "text-red-400"; } function tempBarGradient(temp: number): string { if (temp < 50) return "from-green-500 to-green-400"; if (temp < 70) return "from-green-500 via-amber-500 to-amber-400"; return "from-green-500 via-amber-500 to-red-500"; } function vramGradient(pct: number): string { if (pct < 50) return "from-blue-500 to-cyan-400"; if (pct < 80) return "from-blue-500 via-violet-500 to-purple-400"; return "from-violet-500 via-pink-500 to-red-400"; } export function OllamaCard() { const { data } = usePoll("/api/stats/overview", 60000); const gpu = data?.gpu; const ollamaUp = data?.ollama?.available ?? data?.ollama_available ?? false; const vramUsed = gpu?.vram_used_mb ?? gpu?.memory_used_mb; const vramTotal = gpu?.vram_total_mb ?? gpu?.memory_total_mb; const power = gpu?.power_w ?? gpu?.power_draw_w; const vramPct = vramUsed != null && vramTotal != null ? (vramUsed / vramTotal) * 100 : 0; return (
LLM / GPU {data && ( )} {!data ? (

Loading...

) : gpu?.available ? ( <> {gpu.name && (

{gpu.name}

)}
{vramUsed != null && vramTotal != null && (

VRAM

{(vramUsed / 1024).toFixed(1)} /{" "} {(vramTotal / 1024).toFixed(1)} GB

)} {gpu.temp_c != null && (

Temperature

{gpu.temp_c}°C

)} {power != null && (

Power

{power}W {gpu.power_limit_w ? ` / ${gpu.power_limit_w}W` : ""}

)} {gpu.utilization_pct != null && (

Utilization

{gpu.utilization_pct}%

)}
) : (

GPU not available

)} ); }