Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions ods/extensions/services/dashboard-api/routers/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1961,8 +1961,12 @@ def download_model(model_id: str, api_key: str = Depends(verify_api_key)):
detail={**bootstrap_conflict, "requestedModelId": model_id},
)

gguf_file = model.get("gguf_file")
if not gguf_file:
raise HTTPException(status_code=404, detail=f"Model '{model_id}' is missing a GGUF file reference")

payload = {
"gguf_file": model["gguf_file"],
"gguf_file": gguf_file,
"gguf_url": model.get("gguf_url", ""),
"gguf_sha256": model.get("gguf_sha256", ""),
}
Expand Down Expand Up @@ -2066,8 +2070,12 @@ def delete_model(model_id: str, api_key: str = Depends(verify_api_key)):
if model is None:
raise HTTPException(status_code=404, detail=f"Model '{model_id}' not found in library or local GGUF files")

gguf_file = model.get("gguf_file")
if not gguf_file:
raise HTTPException(status_code=404, detail=f"Model '{model_id}' is missing a GGUF file reference")

payload = {
"gguf_file": model["gguf_file"],
"gguf_file": gguf_file,
}
if model.get("gguf_parts"):
payload["gguf_parts"] = model["gguf_parts"]
Expand Down
24 changes: 24 additions & 0 deletions ods/extensions/services/dashboard-api/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2655,3 +2655,27 @@ def test_load_model_rejects_local_gguf_path_separators(test_client, monkeypatch,
)

assert resp.status_code == 404


def test_download_and_delete_reject_library_record_missing_gguf_file(test_client, monkeypatch, tmp_path):
models_router, install_dir, data_dir = _patch_model_router_paths(monkeypatch, tmp_path)
_write_model_library(install_dir, [{"id": "legacy-model", "name": "Legacy Model"}])
monkeypatch.setattr(
models_router,
"_call_agent_model",
lambda *_args, **_kwargs: (_ for _ in ()).throw(
AssertionError("host agent reached for record without gguf_file")
),
)

download_response = test_client.post(
"/api/models/legacy-model/download",
headers=test_client.auth_headers,
)
delete_response = test_client.delete(
"/api/models/legacy-model",
headers=test_client.auth_headers,
)

assert download_response.status_code == 404
assert delete_response.status_code == 404
Loading