From 64c399738e21b3665c328b45887b13dbcf064a1d Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Tue, 5 May 2026 00:21:59 +0900 Subject: [PATCH] fix: store HF models directly under models/ for llama-server discovery MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit llama-server's --models-dir scanner only checks one level of subdirectories. Downloaded models were stored two levels deep at models/huggingface//, making them invisible. Changed the cache directory from models/huggingface/ to models/ so models land at models// — exactly one level deep. Includes automatic migration of existing models from the legacy huggingface/ subdirectory on first run. Fixes #177 --- CHANGELOG.md | 6 ++++++ package.json | 2 +- src/main/utils/huggingface.ts | 31 +++++++++++++++++++++++++++++-- 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ada89bf..4e9ecbb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.0.18] - 2026-05-05 + +### Fixed + +- **Downloaded Models Not Recognized by llama.cpp.** Models downloaded from Hugging Face are now stored directly under the `models/` directory instead of a nested `models/huggingface/` subdirectory, so llama-server's model scanner discovers them without manual symlinks. Existing models in the old location are automatically migrated on startup (#177). + ## [0.0.17] - 2026-05-03 ### Added diff --git a/package.json b/package.json index 53d672f..f4123d3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "open-webui", - "version": "0.0.17", + "version": "0.0.18", "license": "AGPL-3.0", "description": "Open WebUI Desktop", "main": "./out/main/index.js", diff --git a/src/main/utils/huggingface.ts b/src/main/utils/huggingface.ts index 2994ba5..62cf424 100644 --- a/src/main/utils/huggingface.ts +++ b/src/main/utils/huggingface.ts @@ -5,7 +5,7 @@ * Downloads files from HF repos, manages a local model cache, * and provides listing/deletion of cached models. * - * Cache dir: /models/huggingface// + * Cache dir: /models// */ import * as fs from 'fs' @@ -33,10 +33,37 @@ export interface HfDownloadProgress { // ─── Paths ────────────────────────────────────────────── const getHfCacheDir = (): string => { - const dir = path.join(getInstallDir(), 'models', 'huggingface') + const dir = path.join(getInstallDir(), 'models') if (!fs.existsSync(dir)) { fs.mkdirSync(dir, { recursive: true }) } + + // Migrate models from legacy models/huggingface// to models// + const legacyDir = path.join(dir, 'huggingface') + if (fs.existsSync(legacyDir)) { + try { + const entries = fs.readdirSync(legacyDir, { withFileTypes: true }) + for (const entry of entries) { + if (entry.isDirectory()) { + const src = path.join(legacyDir, entry.name) + const dest = path.join(dir, entry.name) + if (!fs.existsSync(dest)) { + fs.renameSync(src, dest) + log.info(`[huggingface] Migrated ${entry.name} from legacy cache`) + } + } + } + // Remove legacy dir if empty (manifest.json may remain) + const remaining = fs.readdirSync(legacyDir) + if (remaining.length === 0) { + fs.rmdirSync(legacyDir) + log.info('[huggingface] Removed empty legacy huggingface/ directory') + } + } catch (e) { + log.warn('[huggingface] Failed to migrate legacy cache:', e) + } + } + return dir }