mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-05 17:58:55 +00:00
updated api
This commit is contained in:
1 parent
ae10ad5084
commit
b033305879
3 files changed
+176
-158
No files matched your search
+12
-3
@@ -34,13 +34,22 @@ impl Default for OmniGenImageModelsProvider {
|
||||
#[derive(Serialize, ToSchema, Clone)]
|
||||
pub struct OmniGenImageModelsResponse {
|
||||
pub success: bool,
|
||||
pub providers: Vec<OmniGenImageProviderModels>,
|
||||
pub models: Vec<OmniGenImageModelDetails>,
|
||||
pub providers: Vec<OmniGenImageModelProviderDetails>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, ToSchema, Clone)]
|
||||
pub struct OmniGenImageProviderModels {
|
||||
pub struct OmniGenImageModelProviderDetails {
|
||||
pub provider: GenerationProvider,
|
||||
pub models: Vec<OmniGenImageModelDetails>,
|
||||
pub models: Vec<OmniGenImageProviderModelDetails>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, ToSchema, Clone)]
|
||||
pub struct OmniGenImageProviderModelDetails {
|
||||
pub model: CommonImageModel,
|
||||
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub overrides: Option<OmniGenImageModelDetails>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, ToSchema, Clone)]
|
||||
|
||||
@@ -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<Vec<OmniGenImageProviderModels>> = Lazy::new(|| {
|
||||
build_omni_gen_image_models()
|
||||
pub const OMNI_GEN_IMAGE_MODELS_AND_PROVIDERS: Lazy<OmniGenImageModelsResponse> = 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<OmniGenImageProviderModels> {
|
||||
fn build_omni_gen_image_models() -> Vec<OmniGenImageModelDetails> {
|
||||
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<OmniGenImageModelProviderDetails> {
|
||||
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
|
||||
}
|
||||
+3
-7
@@ -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<OmniGenImageModelsQuery>,
|
||||
_server_state: web::Data<Arc<ServerState>>,
|
||||
) -> Result<Json<OmniGenImageModelsResponse>, 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))
|
||||
}
|
||||
Reference in new issue
Block a user