use axum::{ extract::{Path, State}, http::StatusCode, Json, }; use serde::Deserialize; use crate::{ model::{ProviderModel, ProviderModelInput}, Result, }; use super::{ControlService, DiscoveredModels}; #[derive(Deserialize)] pub struct SaveModels { pub models: Vec, } pub async fn list(State(service): State) -> Result>> { Ok(Json(service.models().await?)) } pub async fn save( State(service): State, Path(provider_id): Path, Json(input): Json, ) -> Result<(StatusCode, Json>)> { Ok(( StatusCode::CREATED, Json(service.save_models(provider_id, &input.models).await?), )) } pub async fn remove( State(service): State, Path(model_hash): Path, ) -> Result { service.delete_model(&model_hash).await?; Ok(StatusCode::NO_CONTENT) } pub async fn discover( State(service): State, Path(provider_id): Path, ) -> Result> { Ok(Json(service.discover_models(provider_id).await?)) }