This commit is contained in:
Brandon Thomas committed 2026-04-10 01:05:08 -04:00
1 parent 7769e6585c
commit 0aa0db22a8
17 files changed
+27 -10

No files matched your search

@@ -38,6 +38,8 @@ pub enum CommonAspectRatio {
// These are from the Seedream models
#[serde(rename = "auto_2k")]
Auto2k,
#[serde(rename = "auto_3k")]
Auto3k,
#[serde(rename = "auto_4k")]
Auto4k,
@@ -80,7 +80,7 @@ fn plan_image_size(
match aspect_ratio {
None => Ok(None),
Some(CommonAspectRatio::Auto) | Some(CommonAspectRatio::Auto2k) | Some(CommonAspectRatio::Auto4k) => {
Some(CommonAspectRatio::Auto) | Some(CommonAspectRatio::Auto2k) | Some(CommonAspectRatio::Auto3k) | Some(CommonAspectRatio::Auto4k) => {
Ok(Some(S::SquareHd))
}
@@ -121,6 +121,7 @@ fn plan_image_size(aspect_ratio: Option<CommonAspectRatio>) -> Option<ArtcraftGp
None
| Some(CommonAspectRatio::Auto)
| Some(CommonAspectRatio::Auto2k)
| Some(CommonAspectRatio::Auto3k)
| Some(CommonAspectRatio::Auto4k) => None,
Some(CommonAspectRatio::Square) | Some(CommonAspectRatio::SquareHd) => Some(S::Square),
@@ -79,6 +79,7 @@ fn plan_image_size(
None
| Some(CommonAspectRatio::Auto)
| Some(CommonAspectRatio::Auto2k)
| Some(CommonAspectRatio::Auto3k)
| Some(CommonAspectRatio::Auto4k) => Ok(None),
// Square
@@ -82,7 +82,7 @@ fn plan_image_size(
match aspect_ratio {
None => Ok(None),
Some(CommonAspectRatio::Auto) | Some(CommonAspectRatio::Auto2k) | Some(CommonAspectRatio::Auto4k) => {
Some(CommonAspectRatio::Auto) | Some(CommonAspectRatio::Auto2k) | Some(CommonAspectRatio::Auto3k) | Some(CommonAspectRatio::Auto4k) => {
Ok(Some(S::SquareHd))
}
@@ -72,7 +72,7 @@ fn plan_image_size(
if is_edit_mode { Ok(Some(S::Auto)) } else { Ok(Some(S::Square)) }
}
Some(CommonAspectRatio::Auto2k) => Ok(Some(S::Auto2k)),
Some(CommonAspectRatio::Auto2k) | Some(CommonAspectRatio::Auto3k) => Ok(Some(S::Auto2k)),
Some(CommonAspectRatio::Auto4k) => Ok(Some(S::Auto4k)),
// Square
@@ -72,7 +72,7 @@ fn plan_image_size(
if is_edit_mode { Ok(Some(S::Auto2k)) } else { Ok(Some(S::Square)) }
}
Some(CommonAspectRatio::Auto2k) => Ok(Some(S::Auto2k)),
Some(CommonAspectRatio::Auto2k) | Some(CommonAspectRatio::Auto3k) => Ok(Some(S::Auto2k)),
Some(CommonAspectRatio::Auto4k) => Ok(Some(S::Auto4k)),
// Square
@@ -73,6 +73,7 @@ fn plan_image_size(
}
Some(CommonAspectRatio::Auto2k) => Ok(Some(S::Auto2k)),
Some(CommonAspectRatio::Auto3k) => Ok(Some(S::Auto3k)),
// 5 Lite max is auto_3K; map Auto4k down to Auto3k
Some(CommonAspectRatio::Auto4k) => Ok(Some(S::Auto3k)),
@@ -148,8 +149,6 @@ mod tests {
use super::*;
use crate::api::common_aspect_ratio::CommonAspectRatio;
use crate::api::image_list_ref::ImageListRef;
use crate::errors::artcraft_router_error::ArtcraftRouterError;
use crate::errors::client_error::ClientError;
use crate::test_helpers::base_seedream_5_lite_image_request;
use artcraft_api_defs::generate::image::multi_function::bytedance_seedream_5_lite_multi_function_image_gen::{
BytedanceSeedream5LiteMultiFunctionImageGenImageSize as S,
@@ -96,6 +96,7 @@ fn plan_image_size(aspect_ratio: Option<CommonAspectRatio>) -> Option<FalGptImag
None
| Some(CommonAspectRatio::Auto)
| Some(CommonAspectRatio::Auto2k)
| Some(CommonAspectRatio::Auto3k)
| Some(CommonAspectRatio::Auto4k) => None,
Some(CommonAspectRatio::Square) | Some(CommonAspectRatio::SquareHd) => Some(S::Square),
@@ -93,6 +93,7 @@ fn plan_image_size(aspect_ratio: Option<CommonAspectRatio>) -> Option<FalGptImag
None
| Some(CommonAspectRatio::Auto)
| Some(CommonAspectRatio::Auto2k)
| Some(CommonAspectRatio::Auto3k)
| Some(CommonAspectRatio::Auto4k) => None,
Some(CommonAspectRatio::Square) | Some(CommonAspectRatio::SquareHd) => Some(S::Square),
@@ -84,7 +84,7 @@ fn plan_image_size(
Some(CommonAspectRatio::Auto) => {
if is_edit_mode { Ok(Some(S::Auto)) } else { Ok(Some(S::Square)) }
}
Some(CommonAspectRatio::Auto2k) => Ok(Some(S::Auto2k)),
Some(CommonAspectRatio::Auto2k) | Some(CommonAspectRatio::Auto3k) => Ok(Some(S::Auto2k)),
Some(CommonAspectRatio::Auto4k) => Ok(Some(S::Auto4k)),
Some(CommonAspectRatio::Square) => Ok(Some(S::Square)),
@@ -78,7 +78,7 @@ fn plan_image_size(
None => Ok(None),
// No bare Auto for v4.5 — fall back to Auto2k.
Some(CommonAspectRatio::Auto) | Some(CommonAspectRatio::Auto2k) => Ok(Some(S::Auto2k)),
Some(CommonAspectRatio::Auto) | Some(CommonAspectRatio::Auto2k) | Some(CommonAspectRatio::Auto3k) => Ok(Some(S::Auto2k)),
Some(CommonAspectRatio::Auto4k) => Ok(Some(S::Auto4k)),
Some(CommonAspectRatio::Square) => Ok(Some(S::Square)),
@@ -87,6 +87,7 @@ fn plan_image_size(
},
Some(CommonAspectRatio::Auto) | Some(CommonAspectRatio::Auto2k) => Ok(Some(S::Auto2k)),
Some(CommonAspectRatio::Auto3k) => Ok(Some(S::Auto3k)),
// No 4K — fall back to 3K.
Some(CommonAspectRatio::Auto4k) => Ok(Some(S::Auto3k)),
@@ -34,6 +34,8 @@ pub enum CommonAspectRatio {
Tall,
#[serde(rename = "auto_2k")]
Auto2k,
#[serde(rename = "auto_3k")]
Auto3k,
#[serde(rename = "auto_4k")]
Auto4k,
SquareHd,
@@ -61,6 +63,7 @@ impl CommonAspectRatio {
Self::Wide => "wide",
Self::Tall => "tall",
Self::Auto2k => "auto_2k",
Self::Auto3k => "auto_3k",
Self::Auto4k => "auto_4k",
Self::SquareHd => "square_hd",
}
@@ -83,6 +86,7 @@ impl CommonAspectRatio {
"wide" => Ok(Self::Wide),
"tall" => Ok(Self::Tall),
"auto_2k" => Ok(Self::Auto2k),
"auto_3k" => Ok(Self::Auto3k),
"auto_4k" => Ok(Self::Auto4k),
"square_hd" => Ok(Self::SquareHd),
_ => Err(EnumError::CouldNotConvertFromString(value.to_string())),
@@ -106,6 +110,7 @@ impl CommonAspectRatio {
Self::Wide,
Self::Tall,
Self::Auto2k,
Self::Auto3k,
Self::Auto4k,
Self::SquareHd,
])
@@ -139,6 +144,7 @@ mod tests {
assert_serialization(CommonAspectRatio::Wide, "wide");
assert_serialization(CommonAspectRatio::Tall, "tall");
assert_serialization(CommonAspectRatio::Auto2k, "auto_2k");
assert_serialization(CommonAspectRatio::Auto3k, "auto_3k");
assert_serialization(CommonAspectRatio::Auto4k, "auto_4k");
assert_serialization(CommonAspectRatio::SquareHd, "square_hd");
}
@@ -160,6 +166,7 @@ mod tests {
assert_eq!(CommonAspectRatio::Wide.to_str(), "wide");
assert_eq!(CommonAspectRatio::Tall.to_str(), "tall");
assert_eq!(CommonAspectRatio::Auto2k.to_str(), "auto_2k");
assert_eq!(CommonAspectRatio::Auto3k.to_str(), "auto_3k");
assert_eq!(CommonAspectRatio::Auto4k.to_str(), "auto_4k");
assert_eq!(CommonAspectRatio::SquareHd.to_str(), "square_hd");
}
@@ -181,6 +188,7 @@ mod tests {
assert_eq!(CommonAspectRatio::from_str("wide").unwrap(), CommonAspectRatio::Wide);
assert_eq!(CommonAspectRatio::from_str("tall").unwrap(), CommonAspectRatio::Tall);
assert_eq!(CommonAspectRatio::from_str("auto_2k").unwrap(), CommonAspectRatio::Auto2k);
assert_eq!(CommonAspectRatio::from_str("auto_3k").unwrap(), CommonAspectRatio::Auto3k);
assert_eq!(CommonAspectRatio::from_str("auto_4k").unwrap(), CommonAspectRatio::Auto4k);
assert_eq!(CommonAspectRatio::from_str("square_hd").unwrap(), CommonAspectRatio::SquareHd);
}
@@ -199,7 +207,7 @@ mod tests {
#[test]
fn all_variants() {
let variants = CommonAspectRatio::all_variants();
assert_eq!(variants.len(), 17);
assert_eq!(variants.len(), 18);
}
}
@@ -289,6 +289,7 @@ fn build_omni_gen_image_models() -> Vec<OmniGenImageModelDetails> {
image_refs_supported: Some(true),
aspect_ratio_options: Some(vec![
CommonAspectRatio::Auto2k,
CommonAspectRatio::Auto3k,
CommonAspectRatio::Square,
CommonAspectRatio::SquareHd,
CommonAspectRatio::WideFourByThree,
@@ -297,7 +298,7 @@ fn build_omni_gen_image_models() -> Vec<OmniGenImageModelDetails> {
CommonAspectRatio::TallNineBySixteen,
]),
aspect_ratio_default: Some(CommonAspectRatio::Square),
aspect_ratio_default_when_editing: Some(CommonAspectRatio::Auto2k),
aspect_ratio_default_when_editing: Some(CommonAspectRatio::Auto3k),
batch_size_min: Some(1),
batch_size_max: Some(4),
batch_size_default: Some(1),
@@ -159,6 +159,7 @@ fn map_aspect_ratio(ar: CommonAspectRatio) -> RouterAspectRatio {
CommonAspectRatio::Wide => RouterAspectRatio::Wide,
CommonAspectRatio::Tall => RouterAspectRatio::Tall,
CommonAspectRatio::Auto2k => RouterAspectRatio::Auto2k,
CommonAspectRatio::Auto3k => RouterAspectRatio::Auto3k,
CommonAspectRatio::Auto4k => RouterAspectRatio::Auto4k,
CommonAspectRatio::SquareHd => RouterAspectRatio::SquareHd,
}
@@ -168,6 +168,7 @@ fn map_aspect_ratio(ar: CommonAspectRatio) -> RouterAspectRatio {
CommonAspectRatio::Wide => RouterAspectRatio::Wide,
CommonAspectRatio::Tall => RouterAspectRatio::Tall,
CommonAspectRatio::Auto2k => RouterAspectRatio::Auto2k,
CommonAspectRatio::Auto3k => RouterAspectRatio::Auto3k,
CommonAspectRatio::Auto4k => RouterAspectRatio::Auto4k,
CommonAspectRatio::SquareHd => RouterAspectRatio::SquareHd,
}