fix: GET /v1/models und /v1/models/{id} zeigen nicht installierte Sprachmodelle nicht (#1146); Version 0.1.17-rc7

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GmHhg6sxZ8wsKZAVLQ6Xj5
This commit is contained in:
2026-11-21 23:19:10 +01:00
parent de43516029
commit cf5009453d
4 changed files with 47 additions and 9 deletions

View File

@ -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<Value> = 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))