studio: fix cancel to actually kill llama-server during loading
The unload endpoint checked is_loaded (requires healthy=True), but during initial loading the server is not yet healthy. Cancel had no effect because the unload route fell through to the Unsloth backend. Fix: add is_active property (process exists, loading or loaded) and check it in the unload route so cancel kills llama-server even during the download/loading phase. Also: toast cancel button now properly triggers the backend unload.
This commit is contained in:
parent
a0fdf03340
commit
226ece0c9e
2 changed files with 9 additions and 4 deletions
|
|
@ -58,6 +58,11 @@ class LlamaCppBackend:
|
|||
def is_loaded(self) -> bool:
|
||||
return self._process is not None and self._healthy
|
||||
|
||||
@property
|
||||
def is_active(self) -> bool:
|
||||
"""True if a llama-server process exists (loading or loaded)."""
|
||||
return self._process is not None
|
||||
|
||||
@property
|
||||
def base_url(self) -> str:
|
||||
return f"http://127.0.0.1:{self._port}"
|
||||
|
|
|
|||
|
|
@ -343,11 +343,11 @@ async def unload_model(
|
|||
Routes to the correct backend (llama-server for GGUF, Unsloth otherwise).
|
||||
"""
|
||||
try:
|
||||
# Check if the GGUF backend has this model loaded
|
||||
# Check if the GGUF backend has this model loaded or is loading it
|
||||
llama_backend = get_llama_cpp_backend()
|
||||
if (
|
||||
llama_backend.is_loaded
|
||||
and llama_backend.model_identifier == request.model_path
|
||||
if llama_backend.is_active and (
|
||||
llama_backend.model_identifier == request.model_path
|
||||
or not llama_backend.is_loaded
|
||||
):
|
||||
llama_backend.unload_model()
|
||||
logger.info(f"Unloaded GGUF model: {request.model_path}")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue