Model selection: - Add sdxl_offload tier (eff_vram ≥ 4.0 GB) for GTX 1060 6GB and Quadro 6GB cards that were falling through to SD 2.1 despite SDXL fitting with model_cpu_offload. Cards with 5.3 GB effective VRAM now get SDXL quality. - Update _tier_label(), _caps(), _build_warnings() for new tier. Frontend GPU display: - api.js: add getGpuStatus() fetching /api/gpu/status - capabilities.js: add getGpuStatus() export with own LRU cache; refreshCapabilities() now also resets GPU status cache - provider-badge.js: when AI_PROVIDER=local_gpu show green badge with GPU name, tier, VRAM, CC, feature flags, and capabilities in tooltip. Strip "NVIDIA GeForce" prefix so "GTX 1060 6GB" fits in badge. - ai_provider_settings.js: add local_gpu to all provider dropdowns; show GPU info panel (device, VRAM, CC, features, tier, model table per operation) in the settings dialog when a GPU is detected. https://claude.ai/code/session_01WVDg7amsy1TTtxvpku7bcM
85 lines
2.3 KiB
JavaScript
85 lines
2.3 KiB
JavaScript
/**
|
|
* Backend capabilities singleton.
|
|
* Fetched once on load from GET /api/config.
|
|
* Tools use this to decide whether to show, grey out, or show tooltips.
|
|
*
|
|
* Shape:
|
|
* {
|
|
* local: { lama, rembg, opencv, gpu_detected },
|
|
* remote: { provider, capabilities: string[], healthy }
|
|
* }
|
|
*/
|
|
|
|
import apiService from '../services/api.js';
|
|
|
|
const DEFAULT_CAPS = {
|
|
local: { lama: false, rembg: false, opencv: true, gpu_detected: false },
|
|
remote: { provider: null, capabilities: [], healthy: false },
|
|
};
|
|
|
|
let _caps = null;
|
|
let _fetchPromise = null;
|
|
let _gpuStatus = null;
|
|
let _gpuFetchPromise = null;
|
|
|
|
/**
|
|
* Return capabilities (fetched lazily, cached thereafter).
|
|
* Always resolves — falls back to DEFAULT_CAPS on network error.
|
|
*/
|
|
export async function getCapabilities() {
|
|
if (_caps) return _caps;
|
|
if (!_fetchPromise) {
|
|
_fetchPromise = apiService.getConfig()
|
|
.then(data => { _caps = data || DEFAULT_CAPS; return _caps; })
|
|
.catch(() => { _caps = DEFAULT_CAPS; return _caps; });
|
|
}
|
|
return _fetchPromise;
|
|
}
|
|
|
|
/**
|
|
* Synchronous check — returns cached value or DEFAULT_CAPS if not yet loaded.
|
|
*/
|
|
export function getCachedCapabilities() {
|
|
return _caps || DEFAULT_CAPS;
|
|
}
|
|
|
|
/**
|
|
* True if the remote provider is configured and healthy.
|
|
*/
|
|
export function hasRemote() {
|
|
return !!(_caps?.remote?.healthy);
|
|
}
|
|
|
|
/**
|
|
* Fetch and cache detailed GPU status (hardware, feature flags, model selection per op).
|
|
* Calls /api/gpu/status — only meaningful when AI_PROVIDER=local_gpu.
|
|
* Returns null on error.
|
|
*/
|
|
export async function getGpuStatus() {
|
|
if (_gpuStatus !== null) return _gpuStatus;
|
|
if (!_gpuFetchPromise) {
|
|
_gpuFetchPromise = apiService.getGpuStatus()
|
|
.then(data => { _gpuStatus = data; return _gpuStatus; })
|
|
.catch(() => { _gpuStatus = null; return null; });
|
|
}
|
|
return _gpuFetchPromise;
|
|
}
|
|
|
|
/**
|
|
* Invalidate cache and re-fetch (call after saving provider settings).
|
|
*/
|
|
export async function refreshCapabilities() {
|
|
_caps = null;
|
|
_fetchPromise = null;
|
|
_gpuStatus = null;
|
|
_gpuFetchPromise = null;
|
|
return getCapabilities();
|
|
}
|
|
|
|
/**
|
|
* Kick off the fetch immediately at module load time so it's ready when tools need it.
|
|
*/
|
|
getCapabilities();
|
|
|
|
export default { getCapabilities, getCachedCapabilities, hasRemote, refreshCapabilities, getGpuStatus };
|