Skip to content

Import derives model name from URI repo root instead of selected GGUF file when URI lacks a file component #10587

Description

@ackalker

LocalAI version:
v4.5.5, source code analysis for d1cee4c

Environment, CPU architecture, OS, and Version:
Linux miki-linux-ai 7.1.2-2-cachyos #1 SMP PREEMPT_DYNAMIC Sun, 28 Jun 2026 15:38:15 +0000 x86_64 GNU/Linux
CPU: AMD Ryzen 9950X3D
OS: CachyOS, rolling release

Describe the bug
When importing a HuggingFace GGUF model via the Web UI, if the user enters a URI that points to a repository root without a specific file (e.g. hf://owner/repo or huggingface://owner/repo) and leaves the "Model Name" field empty, the importer uses the repository name (the last path component of the URI) as the model name — not the name of the individual GGUF file the importer would select from the repository's file listing.

This happens even when the user explicitly picks a specific GGUF file from the repository's available files. The gallery entry files are correctly grouped into shards, but the model: field in the emitted YAML configuration and the gallery entry Filename both derive from filepath.Base(details.URI), which for a repo-root URI is the repo name, not the file name.

To Reproduce

  1. In the Web UI, navigate to "Import New Model"
  2. Set Mode to "Advanced" (Power mode)
  3. In the Model URI field, enter hf://TheBloke/Llama-2-7B-Chat-GGUF (no filename)
  4. Leave the "Model Name" field empty
  5. Click "Import Model"
  6. Observe that the resulting YAML configuration has model: set to Llama-2-7B-Chat-GGUF instead of the actual filename of the GGUF file selected from the repository

Expected behavior
The model name should be the name (minus extension) of the specific GGUF file for the primary (non-MMProj, non-MTP) model file selected from the repository. This corresponds to what the help text in the input box for the model name suggests.. The importer iterates details.HuggingFace.Files to find and group shard files, but the emitted YAML's model: field and gallery Filename should derive from the actual selected file, not filepath.Base(details.URI).

Additional context
The relevant code is in core/gallery/importers/llama-cpp.go, LlamaCPPImporter.Import():

name, ok := preferencesMap["name"].(string)
if !ok {
    name = filepath.Base(details.URI)
}

When the URI is hf://owner/repo (no file component), filepath.Base() returns the repository name. The HF branch then correctly scans and groups files in details.HuggingFace.Files, but the name variable used for the gallery entry path prefix and the YAML model: field is the repo name, not the actual file name.

The same issue would affect any importer that matches a repo-root URI without a file component (e.g. llama-cpp, mlx, transformers, etc.) — all of them use filepath.Base(details.URI) as the fallback name.

Related code paths

  • core/gallery/importers/llama-cpp.goImport() function, lines ~85-170
  • core/gallery/importers/importers.goDiscoverModelConfig() function
  • pkg/downloader/uri.goResolveURL() for HuggingFace URIs
  • core/http/endpoints/localai/import_model.goImportModelURIEndpoint()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions