super-stt-app/src/daemon/client/v1/pipeline/backend.rs
Line | Count | Source |
1 | | // SPDX-License-Identifier: GPL-3.0-only |
2 | | //! `/pipeline/{stage}/backend/list` — the backends that can fill a stage. |
3 | | //! |
4 | | //! The slot itself is [`super::stage`], one level up: it reports the backend |
5 | | //! filling the position and selects one. This is the menu that selection |
6 | | //! accepts. |
7 | | //! |
8 | | //! Asked rather than derived. The app holds the whole `/backend/list` catalog |
9 | | //! and could filter it on each model\'s role — it did — but that is a second |
10 | | //! implementation of the rule `POST /pipeline/{stage}` enforces, and a picker |
11 | | //! built from a filter that drifts offers a backend the daemon then refuses. |
12 | | |
13 | | use crate::daemon::client::internal::response::require_success; |
14 | | use crate::daemon::client::internal::session::with_settings_token; |
15 | | use super_stt_shared::daemon::http_client::HttpResult; |
16 | | use super_stt_shared::daemon::http_client::transport; |
17 | | |
18 | | use crate::daemon::backends::BackendInfo; |
19 | | |
20 | | /// The backends that can fill `stage`, each carrying only the models it can run |
21 | | /// there (HTTP `GET /pipeline/{stage}/backend/list`). |
22 | | /// |
23 | | /// Narrowed on both axes by the daemon, so a picker renders straight from it: |
24 | | /// which backends, and which of their models. |
25 | 0 | pub async fn list_stage_backends(stage: u32) -> HttpResult<Vec<BackendInfo>> { |
26 | 0 | with_settings_token(move |socket, token| async move { |
27 | 0 | let path = format!("/pipeline/{stage}/backend/list"); |
28 | 0 | let resp = require_success( |
29 | 0 | transport::settings_get(socket, &token, &path).await?, |
30 | 0 | "list_stage_backends", |
31 | 0 | )?; |
32 | 0 | Ok(resp |
33 | 0 | .backends |
34 | 0 | .and_then(|v| serde_json::from_value(v).ok()) |
35 | 0 | .unwrap_or_default()) |
36 | 0 | }) |
37 | 0 | .await |
38 | 0 | } |