From b033305879eed534576a76efd19bb62a51690619 Mon Sep 17 00:00:00 2001 From: Brandon Thomas Date: Sat, 28 Mar 2026 16:17:25 -0400 Subject: [PATCH] updated api --- .../omni_gen/models/omni_gen_image_models.rs | 15 +- .../src/configs/omni_gen/image_models.rs | 309 +++++++++--------- .../image/omni_gen_image_models_handler.rs | 10 +- 3 files changed, 176 insertions(+), 158 deletions(-) diff --git a/crates/api_clients/artcraft/artcraft_api_defs/src/omni_gen/models/omni_gen_image_models.rs b/crates/api_clients/artcraft/artcraft_api_defs/src/omni_gen/models/omni_gen_image_models.rs index 2101c684b2..c968262a4a 100644 --- a/crates/api_clients/artcraft/artcraft_api_defs/src/omni_gen/models/omni_gen_image_models.rs +++ b/crates/api_clients/artcraft/artcraft_api_defs/src/omni_gen/models/omni_gen_image_models.rs @@ -34,13 +34,22 @@ impl Default for OmniGenImageModelsProvider { #[derive(Serialize, ToSchema, Clone)] pub struct OmniGenImageModelsResponse { pub success: bool, - pub providers: Vec, + pub models: Vec, + pub providers: Vec, } #[derive(Serialize, ToSchema, Clone)] -pub struct OmniGenImageProviderModels { +pub struct OmniGenImageModelProviderDetails { pub provider: GenerationProvider, - pub models: Vec, + pub models: Vec, +} + +#[derive(Serialize, ToSchema, Clone)] +pub struct OmniGenImageProviderModelDetails { + pub model: CommonImageModel, + + #[serde(skip_serializing_if = "Option::is_none")] + pub overrides: Option, } #[derive(Serialize, ToSchema, Clone)] diff --git a/crates/service/web/storyteller_web/src/configs/omni_gen/image_models.rs b/crates/service/web/storyteller_web/src/configs/omni_gen/image_models.rs index 3895ea43aa..3edf4ab2dd 100644 --- a/crates/service/web/storyteller_web/src/configs/omni_gen/image_models.rs +++ b/crates/service/web/storyteller_web/src/configs/omni_gen/image_models.rs @@ -1,172 +1,185 @@ -use artcraft_api_defs::omni_gen::models::omni_gen_image_models::{OmniGenImageModelDetails, OmniGenImageProviderModels}; +use artcraft_api_defs::omni_gen::models::omni_gen_image_models::{OmniGenImageModelDetails, OmniGenImageModelProviderDetails, OmniGenImageModelsResponse, OmniGenImageProviderModelDetails}; use enums::common::generation::common_aspect_ratio::CommonAspectRatio; use enums::common::generation::common_image_model::CommonImageModel; use enums::common::generation::common_resolution::CommonResolution; use enums::common::generation_provider::GenerationProvider; use once_cell::sync::Lazy; -pub const OMNI_GEN_IMAGE_MODELS: Lazy> = Lazy::new(|| { - build_omni_gen_image_models() +pub const OMNI_GEN_IMAGE_MODELS_AND_PROVIDERS: Lazy = Lazy::new(|| { + let models = build_omni_gen_image_models(); + let providers = build_omni_gen_image_model_providers(); + OmniGenImageModelsResponse { + success: true, + models, + providers, + } }); -fn build_omni_gen_image_models() -> Vec { +fn build_omni_gen_image_models() -> Vec { let mut models = Vec::new(); - models.push(OmniGenImageProviderModels { - provider: GenerationProvider::Artcraft, - models: vec![ - OmniGenImageModelDetails { - model: CommonImageModel::Flux1Dev, - full_name: None, - text_prompt_supported: Some(true), - aspect_ratio_options: Some(vec![ - CommonAspectRatio::SquareHd, - CommonAspectRatio::Square, - CommonAspectRatio::TallThreeByFour, - CommonAspectRatio::TallNineBySixteen, - CommonAspectRatio::WideFourByThree, - CommonAspectRatio::WideSixteenByNine, - ]), - aspect_ratio_default: Some(CommonAspectRatio::Square), - batch_size_min: Some(1), - batch_size_max: Some(4), - batch_size_default: Some(4), - ..Default::default() - }, - ], + models.push(OmniGenImageModelDetails { + model: CommonImageModel::Flux1Dev, + full_name: None, + text_prompt_supported: Some(true), + aspect_ratio_options: Some(vec![ + CommonAspectRatio::SquareHd, + CommonAspectRatio::Square, + CommonAspectRatio::TallThreeByFour, + CommonAspectRatio::TallNineBySixteen, + CommonAspectRatio::WideFourByThree, + CommonAspectRatio::WideSixteenByNine, + ]), + aspect_ratio_default: Some(CommonAspectRatio::Square), + batch_size_min: Some(1), + batch_size_max: Some(4), + batch_size_default: Some(4), + ..Default::default() }); - models.push(OmniGenImageProviderModels { - provider: GenerationProvider::Artcraft, - models: vec![ - OmniGenImageModelDetails { - model: CommonImageModel::Flux1Schnell, - full_name: None, - text_prompt_supported: Some(true), - aspect_ratio_options: Some(vec![ - CommonAspectRatio::SquareHd, - CommonAspectRatio::Square, - CommonAspectRatio::TallThreeByFour, - CommonAspectRatio::TallNineBySixteen, - CommonAspectRatio::WideFourByThree, - CommonAspectRatio::WideSixteenByNine, - ]), - aspect_ratio_default: Some(CommonAspectRatio::Square), - batch_size_min: Some(1), - batch_size_max: Some(4), - batch_size_default: Some(4), - ..Default::default() - }, - ], + models.push(OmniGenImageModelDetails { + model: CommonImageModel::Flux1Schnell, + full_name: None, + text_prompt_supported: Some(true), + aspect_ratio_options: Some(vec![ + CommonAspectRatio::SquareHd, + CommonAspectRatio::Square, + CommonAspectRatio::TallThreeByFour, + CommonAspectRatio::TallNineBySixteen, + CommonAspectRatio::WideFourByThree, + CommonAspectRatio::WideSixteenByNine, + ]), + aspect_ratio_default: Some(CommonAspectRatio::Square), + batch_size_min: Some(1), + batch_size_max: Some(4), + batch_size_default: Some(4), + ..Default::default() }); // ... - models.push(OmniGenImageProviderModels { - provider: GenerationProvider::Artcraft, - models: vec![ - OmniGenImageModelDetails { - model: CommonImageModel::NanaBanana, // NB: currently Gemini25Flash in our system - full_name: None, - text_prompt_supported: Some(true), - image_refs_supported: Some(true), - aspect_ratio_options: Some(vec![ - CommonAspectRatio::Auto, - CommonAspectRatio::WideTwentyOneByNine, - CommonAspectRatio::WideSixteenByNine, - CommonAspectRatio::WideThreeByTwo, - CommonAspectRatio::WideFourByThree, - CommonAspectRatio::WideFiveByFour, - CommonAspectRatio::Square, - CommonAspectRatio::TallFourByFive, - CommonAspectRatio::TallThreeByFour, - CommonAspectRatio::TallTwoByThree, - CommonAspectRatio::TallNineBySixteen, - ]), - aspect_ratio_default: Some(CommonAspectRatio::Square), - aspect_ratio_default_when_editing: Some(CommonAspectRatio::Auto), - batch_size_min: Some(1), - batch_size_max: Some(4), - batch_size_default: Some(4), - ..Default::default() - }, - ], + models.push(OmniGenImageModelDetails { + model: CommonImageModel::NanaBanana, // NB: currently Gemini25Flash in our system + full_name: None, + text_prompt_supported: Some(true), + image_refs_supported: Some(true), + aspect_ratio_options: Some(vec![ + CommonAspectRatio::Auto, + CommonAspectRatio::WideTwentyOneByNine, + CommonAspectRatio::WideSixteenByNine, + CommonAspectRatio::WideThreeByTwo, + CommonAspectRatio::WideFourByThree, + CommonAspectRatio::WideFiveByFour, + CommonAspectRatio::Square, + CommonAspectRatio::TallFourByFive, + CommonAspectRatio::TallThreeByFour, + CommonAspectRatio::TallTwoByThree, + CommonAspectRatio::TallNineBySixteen, + ]), + aspect_ratio_default: Some(CommonAspectRatio::Square), + aspect_ratio_default_when_editing: Some(CommonAspectRatio::Auto), + batch_size_min: Some(1), + batch_size_max: Some(4), + batch_size_default: Some(4), + ..Default::default() }); - models.push(OmniGenImageProviderModels { - provider: GenerationProvider::Artcraft, - models: vec![ - OmniGenImageModelDetails { - model: CommonImageModel::NanaBanana2, - full_name: None, - text_prompt_supported: Some(true), - image_refs_supported: Some(true), - aspect_ratio_options: Some(vec![ - CommonAspectRatio::Auto, - CommonAspectRatio::WideTwentyOneByNine, - CommonAspectRatio::WideSixteenByNine, - CommonAspectRatio::WideThreeByTwo, - CommonAspectRatio::WideFourByThree, - CommonAspectRatio::WideFiveByFour, - CommonAspectRatio::Square, - CommonAspectRatio::TallFourByFive, - CommonAspectRatio::TallThreeByFour, - CommonAspectRatio::TallTwoByThree, - CommonAspectRatio::TallNineBySixteen, - ]), - aspect_ratio_default: Some(CommonAspectRatio::Square), - aspect_ratio_default_when_editing: Some(CommonAspectRatio::Auto), - resolution_options: Some(vec![ - CommonResolution::HalfK, - CommonResolution::OneK, - CommonResolution::TwoK, - CommonResolution::FourK, - ]), - resolution_default: Some(CommonResolution::OneK), - batch_size_min: Some(1), - batch_size_max: Some(4), - batch_size_default: Some(4), - ..Default::default() - }, - ], + models.push(OmniGenImageModelDetails { + model: CommonImageModel::NanaBanana2, + full_name: None, + text_prompt_supported: Some(true), + image_refs_supported: Some(true), + aspect_ratio_options: Some(vec![ + CommonAspectRatio::Auto, + CommonAspectRatio::WideTwentyOneByNine, + CommonAspectRatio::WideSixteenByNine, + CommonAspectRatio::WideThreeByTwo, + CommonAspectRatio::WideFourByThree, + CommonAspectRatio::WideFiveByFour, + CommonAspectRatio::Square, + CommonAspectRatio::TallFourByFive, + CommonAspectRatio::TallThreeByFour, + CommonAspectRatio::TallTwoByThree, + CommonAspectRatio::TallNineBySixteen, + ]), + aspect_ratio_default: Some(CommonAspectRatio::Square), + aspect_ratio_default_when_editing: Some(CommonAspectRatio::Auto), + resolution_options: Some(vec![ + CommonResolution::HalfK, + CommonResolution::OneK, + CommonResolution::TwoK, + CommonResolution::FourK, + ]), + resolution_default: Some(CommonResolution::OneK), + batch_size_min: Some(1), + batch_size_max: Some(4), + batch_size_default: Some(4), + ..Default::default() }); - models.push(OmniGenImageProviderModels { - provider: GenerationProvider::Artcraft, - models: vec![ - OmniGenImageModelDetails { - model: CommonImageModel::NanaBananaPro, - full_name: None, - text_prompt_supported: Some(true), - image_refs_supported: Some(true), - aspect_ratio_options: Some(vec![ - CommonAspectRatio::Auto, - CommonAspectRatio::WideTwentyOneByNine, - CommonAspectRatio::WideSixteenByNine, - CommonAspectRatio::WideThreeByTwo, - CommonAspectRatio::WideFourByThree, - CommonAspectRatio::WideFiveByFour, - CommonAspectRatio::Square, - CommonAspectRatio::TallFourByFive, - CommonAspectRatio::TallThreeByFour, - CommonAspectRatio::TallTwoByThree, - CommonAspectRatio::TallNineBySixteen, - ]), - aspect_ratio_default: Some(CommonAspectRatio::Square), - aspect_ratio_default_when_editing: Some(CommonAspectRatio::Auto), - resolution_options: Some(vec![ - CommonResolution::OneK, - CommonResolution::TwoK, - CommonResolution::FourK, - ]), - resolution_default: Some(CommonResolution::OneK), - batch_size_min: Some(1), - batch_size_max: Some(4), - batch_size_default: Some(4), - ..Default::default() - }, - ], + models.push(OmniGenImageModelDetails { + model: CommonImageModel::NanaBananaPro, + full_name: None, + text_prompt_supported: Some(true), + image_refs_supported: Some(true), + aspect_ratio_options: Some(vec![ + CommonAspectRatio::Auto, + CommonAspectRatio::WideTwentyOneByNine, + CommonAspectRatio::WideSixteenByNine, + CommonAspectRatio::WideThreeByTwo, + CommonAspectRatio::WideFourByThree, + CommonAspectRatio::WideFiveByFour, + CommonAspectRatio::Square, + CommonAspectRatio::TallFourByFive, + CommonAspectRatio::TallThreeByFour, + CommonAspectRatio::TallTwoByThree, + CommonAspectRatio::TallNineBySixteen, + ]), + aspect_ratio_default: Some(CommonAspectRatio::Square), + aspect_ratio_default_when_editing: Some(CommonAspectRatio::Auto), + resolution_options: Some(vec![ + CommonResolution::OneK, + CommonResolution::TwoK, + CommonResolution::FourK, + ]), + resolution_default: Some(CommonResolution::OneK), + batch_size_min: Some(1), + batch_size_max: Some(4), + batch_size_default: Some(4), + ..Default::default() }); models } + +fn build_omni_gen_image_model_providers() -> Vec { + let mut providers = Vec::new(); + + providers.push(OmniGenImageModelProviderDetails { + provider: GenerationProvider::Artcraft, + models: vec![ + OmniGenImageProviderModelDetails { + model: CommonImageModel::Flux1Dev, + overrides: None, + }, + OmniGenImageProviderModelDetails { + model: CommonImageModel::Flux1Schnell, + overrides: None, + }, + OmniGenImageProviderModelDetails { + model: CommonImageModel::NanaBanana, + overrides: None, + }, + OmniGenImageProviderModelDetails { + model: CommonImageModel::NanaBanana2, + overrides: None, + }, + OmniGenImageProviderModelDetails { + model: CommonImageModel::NanaBananaPro, + overrides: None, + }, + ], + }); + + providers +} diff --git a/crates/service/web/storyteller_web/src/http_server/endpoints/omni_gen/models/image/omni_gen_image_models_handler.rs b/crates/service/web/storyteller_web/src/http_server/endpoints/omni_gen/models/image/omni_gen_image_models_handler.rs index 6da2a0ff4c..2e236aa826 100644 --- a/crates/service/web/storyteller_web/src/http_server/endpoints/omni_gen/models/image/omni_gen_image_models_handler.rs +++ b/crates/service/web/storyteller_web/src/http_server/endpoints/omni_gen/models/image/omni_gen_image_models_handler.rs @@ -1,6 +1,6 @@ use std::sync::Arc; -use crate::configs::omni_gen::image_models::OMNI_GEN_IMAGE_MODELS; +use crate::configs::omni_gen::image_models::OMNI_GEN_IMAGE_MODELS_AND_PROVIDERS; use crate::http_server::common_responses::common_web_error::CommonWebError; use crate::state::server_state::ServerState; use actix_web::web::{Json, Query}; @@ -9,7 +9,6 @@ use artcraft_api_defs::omni_gen::models::omni_gen_image_models::{ OmniGenImageModelsQuery, OmniGenImageModelsResponse, }; -use log::info; /// List available image models. #[utoipa::path( @@ -27,9 +26,6 @@ pub async fn omni_gen_image_models_handler( _query: Query, _server_state: web::Data>, ) -> Result, CommonWebError> { - let providers = (*OMNI_GEN_IMAGE_MODELS).clone(); - Ok(Json(OmniGenImageModelsResponse { - success: true, - providers, - })) + let response = (*OMNI_GEN_IMAGE_MODELS_AND_PROVIDERS).clone(); + Ok(Json(response)) }