unsloth/studio/backend/hub/dependencies.py
Eyera aec41d17ed
feat(studio): Hub + Download Manager (#5916)
Adds the Studio Hub and download manager: browse Hugging Face models and datasets, download GGUF and safetensors with live progress and cancellation, and manage on-device inventory. The Hub does not require a GPU, so it is available on chat-only hosts.

CI: all substantive checks pass, including the three Core jobs after unsloth-zoo#736. The two red checks are non-code flakes, a transient npm-registry DNS resolution failure in the package scan and one quantized vision-model output assertion whose sibling shards passed.
2026-06-09 04:11:24 -07:00

24 lines
604 B
Python

# 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 FastAPI dependencies for Hub routes."""
from __future__ import annotations
from typing import Optional
from fastapi import Header
HUB_HF_TOKEN_HEADER = "X-Unsloth-HF-Token"
HUB_HF_TOKEN_MAX_LENGTH = 512
def get_hf_token(
hf_token: Optional[str] = Header(
None,
alias = HUB_HF_TOKEN_HEADER,
max_length = HUB_HF_TOKEN_MAX_LENGTH,
),
) -> Optional[str]:
token = (hf_token or "").strip()
return token or None