fix(text): fail fast on empty --model instead of crashing in backend

Add early validation in create_app(): raise ValueError with a clear
message when model_path is empty and mock=False. Prevents the cryptic
HFValidationError that surfaced when cf-orch passed an empty {model}
arg (cf-orch #46). Surfaces the real problem at the service layer
rather than deep inside the HuggingFace loader.
This commit is contained in:
pyr0ball 2026-04-20 10:50:49 -07:00
parent 27f0b67908
commit 5149de0556

View file

@ -116,6 +116,12 @@ def create_app(
) -> FastAPI:
global _backend
if not mock and not model_path:
raise ValueError(
"cf-text: --model is required (got empty string). "
"Pass a GGUF path, a HuggingFace model ID, or set CF_TEXT_MOCK=1 for mock mode."
)
os.environ.setdefault("CUDA_VISIBLE_DEVICES", str(gpu_id))
_backend = make_text_backend(model_path, backend=backend, mock=mock)