Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

924 B
Raw Blame
# SPDX-License-Identifier: AGPL-3.0-only
# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0

"""Shared helpers for the Hub service layer."""

from __future__ import annotations

from typing import Iterable

from hub.utils.hf_cache_state import resolve_destructive_case_matches


def resolve_destructive_repo_ids(repo_id: str, candidates: Iterable[str], *, noun: str) -> set[str]:
    """Refuses with 409 on ambiguous case-only matches, so a delete never removes the wrong casing."""
    resolved = resolve_destructive_case_matches(repo_id, candidates)
    if resolved is None:
        from fastapi import HTTPException
        raise HTTPException(
            status_code = 409,
            detail = (
                f"Multiple cached {noun} differ only by case. "
                "Delete the exact repo casing from On Device."
            ),
        )
    return resolved