diff --git a/studio/backend/core/inference/llama_cpp.py b/studio/backend/core/inference/llama_cpp.py index 9561280bcc..3ed4589dc0 100644 --- a/studio/backend/core/inference/llama_cpp.py +++ b/studio/backend/core/inference/llama_cpp.py @@ -405,9 +405,7 @@ class LlamaCppBackend: files = list_repo_files(hf_repo, token = hf_token) variant_lower = hf_variant.lower() boundary = re.compile( - r"(? 0: @@ -506,11 +502,7 @@ class LlamaCppBackend: logger.info( f"Downloading GGUF: {hf_repo}/{gguf_filename}" - + ( - f" (+{len(gguf_extra_shards)} shards)" - if gguf_extra_shards - else "" - ) + + (f" (+{len(gguf_extra_shards)} shards)" if gguf_extra_shards else "") ) try: if self._cancel_event.is_set(): diff --git a/studio/backend/core/inference/orchestrator.py b/studio/backend/core/inference/orchestrator.py index 6c50f2b753..99c43bbd88 100644 --- a/studio/backend/core/inference/orchestrator.py +++ b/studio/backend/core/inference/orchestrator.py @@ -124,8 +124,7 @@ class InferenceOrchestrator: if resp.status_code == 200: models = resp.json() gguf_ids = [ - m["id"] for m in models - if m.get("id", "").upper().endswith("-GGUF") + m["id"] for m in models if m.get("id", "").upper().endswith("-GGUF") ][:4] if gguf_ids: self._top_gguf_cache = gguf_ids diff --git a/studio/backend/routes/models.py b/studio/backend/routes/models.py index 2b1fb09b79..4258731712 100644 --- a/studio/backend/routes/models.py +++ b/studio/backend/routes/models.py @@ -14,11 +14,14 @@ import structlog from loggers import get_logger import re as _re + _VALID_REPO_ID = _re.compile(r"^[A-Za-z0-9._-]+/[A-Za-z0-9._-]+$") + def _is_valid_repo_id(repo_id: str) -> bool: return bool(_VALID_REPO_ID.fullmatch(repo_id)) + # Add backend directory to path backend_path = Path(__file__).parent.parent.parent if str(backend_path) not in sys.path: