diff --git a/Cargo.lock b/Cargo.lock index 8ad51f4..3083440 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -700,7 +700,7 @@ dependencies = [ [[package]] name = "nexus" -version = "0.1.17-rc6" +version = "0.1.17-rc7" dependencies = [ "axum", "nexus-adapter", @@ -715,7 +715,7 @@ dependencies = [ [[package]] name = "nexus-adapter" -version = "0.1.17-rc6" +version = "0.1.17-rc7" dependencies = [ "async-trait", "libc", @@ -730,7 +730,7 @@ dependencies = [ [[package]] name = "nexus-api" -version = "0.1.17-rc6" +version = "0.1.17-rc7" dependencies = [ "async-trait", "axum", @@ -750,7 +750,7 @@ dependencies = [ [[package]] name = "nexus-core" -version = "0.1.17-rc6" +version = "0.1.17-rc7" dependencies = [ "argon2", "serde", @@ -761,14 +761,14 @@ dependencies = [ [[package]] name = "nexus-scheduler" -version = "0.1.17-rc6" +version = "0.1.17-rc7" dependencies = [ "nexus-core", ] [[package]] name = "nexus-store" -version = "0.1.17-rc6" +version = "0.1.17-rc7" dependencies = [ "nexus-core", "rusqlite", diff --git a/Cargo.toml b/Cargo.toml index 8803c69..19b0dca 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ resolver = "3" members = ["crates/nexus-core", "crates/nexus-scheduler", "crates/nexus-store", "crates/nexus-adapter", "crates/nexus-api", "crates/nexus"] [workspace.package] -version = "0.1.17-rc6" +version = "0.1.17-rc7" edition = "2024" license = "MIT" repository = "ssh://git@git.wlkns.org:2222/wlkns-dev/nexus.git" diff --git a/crates/nexus-api/src/models.rs b/crates/nexus-api/src/models.rs index 536272f..c79cb90 100644 --- a/crates/nexus-api/src/models.rs +++ b/crates/nexus-api/src/models.rs @@ -11,6 +11,18 @@ use crate::auth::Authed; use crate::error::ApiError; use crate::state::AppState; +/// Sprachmodelle, die auf dem Rechner des Studios nicht installiert sind, stehen nicht im Katalog (sie ließen sich +/// nicht starten, → #1110, #1146). Andere Engines bleiben unverändert. +fn angeboten(state: &AppState, name: &str) -> bool { + let plan = state.store().start_plan(name); + match plan { + Ok(Some(plan)) if plan.engine_name == "tts" => state + .runtime + .model_installed("tts", &plan.model_path.to_string_lossy()), + _ => true, + } +} + fn entry(name: &str) -> Value { json!({ "id": name, "object": "model", "created": 0, "owned_by": "nexus" }) } @@ -26,7 +38,7 @@ pub async fn list( })?; let data: Vec = models .iter() - .filter(|m| key.rights.allows(&m.name)) + .filter(|m| key.rights.allows(&m.name) && angeboten(&state, &m.name)) .map(|m| entry(&m.name)) .collect(); Ok(Json(json!({ "object": "list", "data": data }))) @@ -43,7 +55,7 @@ pub async fn retrieve( tracing::error!(fehler = %e, "Modellliste nicht lesbar"); ApiError::internal() })?; - if key.rights.allows(&id) && models.iter().any(|m| m.name == id) { + if key.rights.allows(&id) && models.iter().any(|m| m.name == id) && angeboten(&state, &id) { Ok(Json(entry(&id))) } else { Err(ApiError::model_not_found(&id)) diff --git a/crates/nexus-api/tests/api.rs b/crates/nexus-api/tests/api.rs index de1ee6d..e7afa84 100644 --- a/crates/nexus-api/tests/api.rs +++ b/crates/nexus-api/tests/api.rs @@ -53,6 +53,9 @@ impl Engine for FixedEngine { capabilities: Capabilities::default(), } } + fn installed(&self, model: &str) -> bool { + !model.contains("fehlt") + } async fn voices_reachable(&self) -> bool { !self.studio_down.load(Ordering::SeqCst) } @@ -653,6 +656,29 @@ async fn modellliste_zeigt_freigegebene_modelle_je_nach_rechten_auch_ungeladene( assert_eq!(status, 200); assert_eq!(body["object"], "list"); assert_eq!(ids(&body), ["bonsai", "sprecher", "zweit"]); + // #1146: Ein Sprachmodell, das im Studio nicht installiert ist, steht nicht im Katalog und lässt sich nicht abrufen. + gw.state + .store() + .register_llm(&NewLlm { + name: "sprecher-fehlt".to_string(), + engine: "tts".to_string(), + path: PathBuf::from("Qwen/Qwen3-TTS-12Hz-0.6B-fehlt"), + quantization: None, + size_bytes: None, + gpus: vec![0], + context: None, + vram_mb: None, + ram_mb: None, + idle_secs: None, + enabled: true, + }) + .unwrap(); + let (_, _, body) = gw.get("/v1/models", Some(&gw.key)).await; + assert_eq!(ids(&body), ["bonsai", "sprecher", "zweit"]); + let (status, _, _) = gw.get("/v1/models/sprecher-fehlt", Some(&gw.key)).await; + assert_eq!(status, 404); + let (status, _, _) = gw.get("/v1/models/sprecher", Some(&gw.key)).await; + assert_eq!(status, 200); assert_eq!(body["data"][0]["object"], "model"); let (_, _, body) = gw.get("/v1/models", Some(&gw.key_bonsai)).await; assert_eq!(ids(&body), ["bonsai"]);