mirror of
https://github.com/storytold/artcraft.git
synced 2026-10-24 02:29:32 -04:00
Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
929b3a8f9b | ||
|
|
1e6f010798 | ||
|
|
31d704f52e | ||
|
|
2011c522d5 | ||
|
|
31e389bf75 |
@@ -1,12 +1,12 @@
|
||||
pub mod audio_list_ref;
|
||||
pub mod character_list_ref;
|
||||
pub mod common_aspect_ratio;
|
||||
pub mod common_image_model;
|
||||
pub mod common_quality;
|
||||
pub mod common_resolution;
|
||||
pub mod common_splat_model;
|
||||
pub mod common_video_model;
|
||||
pub mod image_list_ref;
|
||||
pub mod image_ref;
|
||||
pub mod provider;
|
||||
pub mod router_aspect_ratio;
|
||||
pub mod router_image_model;
|
||||
pub mod router_provider;
|
||||
pub mod router_quality;
|
||||
pub mod router_resolution;
|
||||
pub mod router_splat_model;
|
||||
pub mod router_video_model;
|
||||
pub mod video_list_ref;
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ use strum::EnumIter;
|
||||
#[derive(Copy, Clone, Debug, Serialize, Deserialize)]
|
||||
#[cfg_attr(test, derive(EnumIter))]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum CommonAspectRatio {
|
||||
pub enum RouterAspectRatio {
|
||||
// Auto (eg. for image editing to use the source; used by Nano Banana Pro edit image, but not text-to-image)
|
||||
Auto,
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ use serde_derive::{Deserialize, Serialize};
|
||||
/// Not all models are available through all providers.
|
||||
#[derive(Copy, Clone, Debug, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum CommonImageModel {
|
||||
pub enum RouterImageModel {
|
||||
#[serde(rename = "flux_1_dev")]
|
||||
Flux1Dev,
|
||||
#[serde(rename = "flux_1_schnell")]
|
||||
+1
-1
@@ -3,7 +3,7 @@ use serde_derive::{Deserialize, Serialize};
|
||||
/// The provider to route a generation request to.
|
||||
#[derive(Copy, Clone, Debug, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum Provider {
|
||||
pub enum RouterProvider {
|
||||
Artcraft,
|
||||
Fal,
|
||||
GmiCloud,
|
||||
+1
-1
@@ -4,7 +4,7 @@ use serde_derive::{Deserialize, Serialize};
|
||||
/// Not every model will use this; models that don't simply ignore it.
|
||||
#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum CommonQuality {
|
||||
pub enum RouterQuality {
|
||||
High,
|
||||
Medium,
|
||||
Low,
|
||||
+1
-1
@@ -5,7 +5,7 @@ use serde_derive::{Deserialize, Serialize};
|
||||
/// In the case a model doesn't support the resolution, gracefully pick the nearest option.
|
||||
#[derive(Copy, Clone, Debug, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum CommonResolution {
|
||||
pub enum RouterResolution {
|
||||
/// Models: Nano Banana Pro
|
||||
OneK,
|
||||
/// Models: Nano Banana Pro
|
||||
+1
-1
@@ -4,7 +4,7 @@ use serde_derive::{Deserialize, Serialize};
|
||||
/// Not all models are available through all providers.
|
||||
#[derive(Copy, Clone, Debug, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum CommonSplatModel {
|
||||
pub enum RouterSplatModel {
|
||||
#[serde(rename = "marble_0p1_mini")]
|
||||
Marble0p1Mini,
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ use serde_derive::{Deserialize, Serialize};
|
||||
/// Not all models are available through all providers.
|
||||
#[derive(Copy, Clone, Debug, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum CommonVideoModel {
|
||||
pub enum RouterVideoModel {
|
||||
#[serde(rename = "grok_video")]
|
||||
GrokVideo,
|
||||
|
||||
+40
-40
@@ -1,9 +1,9 @@
|
||||
use crate::api::common_aspect_ratio::CommonAspectRatio;
|
||||
use crate::api::common_image_model::CommonImageModel;
|
||||
use crate::api::common_quality::CommonQuality;
|
||||
use crate::api::common_resolution::CommonResolution;
|
||||
use crate::api::router_aspect_ratio::RouterAspectRatio;
|
||||
use crate::api::router_image_model::RouterImageModel;
|
||||
use crate::api::router_quality::RouterQuality;
|
||||
use crate::api::router_resolution::RouterResolution;
|
||||
use crate::api::image_list_ref::ImageListRef;
|
||||
use crate::api::provider::Provider;
|
||||
use crate::api::router_provider::RouterProvider;
|
||||
use crate::client::generation_mode_mismatch_strategy::GenerationModeMismatchStrategy;
|
||||
use crate::client::request_mismatch_mitigation_strategy::RequestMismatchMitigationStrategy;
|
||||
use crate::errors::artcraft_router_error::ArtcraftRouterError;
|
||||
@@ -42,10 +42,10 @@ use crate::generate::generate_image_v2::providers::fal::seedream_5_lite::build::
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct GenerateImageRequestBuilder {
|
||||
/// Which model to use.
|
||||
pub model: CommonImageModel,
|
||||
pub model: RouterImageModel,
|
||||
|
||||
/// Which provider to use.
|
||||
pub provider: Provider,
|
||||
pub provider: RouterProvider,
|
||||
|
||||
/// The prompt for the image generation.
|
||||
pub prompt: Option<String>,
|
||||
@@ -56,13 +56,13 @@ pub struct GenerateImageRequestBuilder {
|
||||
pub image_inputs: Option<ImageListRef>,
|
||||
|
||||
/// The resolution to use.
|
||||
pub resolution: Option<CommonResolution>,
|
||||
pub resolution: Option<RouterResolution>,
|
||||
|
||||
/// The aspect ratio to use.
|
||||
pub aspect_ratio: Option<CommonAspectRatio>,
|
||||
pub aspect_ratio: Option<RouterAspectRatio>,
|
||||
|
||||
/// The quality level for generation. Not all models use this.
|
||||
pub quality: Option<CommonQuality>,
|
||||
pub quality: Option<RouterQuality>,
|
||||
|
||||
/// How many images to generate.
|
||||
pub image_batch_count: Option<u16>,
|
||||
@@ -100,37 +100,37 @@ impl GenerateImageRequestBuilder {
|
||||
/// `GenerateVideoRequestBuilder::build2`.
|
||||
pub fn build2(self) -> Result<ImageGenerationDraftOrRequest, ArtcraftRouterError> {
|
||||
match (self.provider, self.model) {
|
||||
(Provider::Artcraft, CommonImageModel::Flux1Dev) => build_artcraft_flux_1_dev(self),
|
||||
(Provider::Artcraft, CommonImageModel::Flux1Schnell) => build_artcraft_flux_1_schnell(self),
|
||||
(Provider::Artcraft, CommonImageModel::FluxPro11) => build_artcraft_flux_pro_1p1(self),
|
||||
(Provider::Artcraft, CommonImageModel::FluxPro11Ultra) => build_artcraft_flux_pro_1p1_ultra(self),
|
||||
(Provider::Artcraft, CommonImageModel::GptImage1) => build_artcraft_gpt_image_1(self),
|
||||
(Provider::Artcraft, CommonImageModel::GptImage1p5) => build_artcraft_gpt_image_1p5(self),
|
||||
(Provider::Artcraft, CommonImageModel::GptImage2) => build_artcraft_gpt_image_2(self),
|
||||
(Provider::Artcraft, CommonImageModel::NanoBanana) => build_artcraft_nano_banana(self),
|
||||
(Provider::Artcraft, CommonImageModel::NanoBanana2) => build_artcraft_nano_banana_2(self),
|
||||
(Provider::Artcraft, CommonImageModel::NanoBananaPro) => build_artcraft_nano_banana_pro(self),
|
||||
(Provider::Artcraft, CommonImageModel::Seedream4) => build_artcraft_seedream_4(self),
|
||||
(Provider::Artcraft, CommonImageModel::Seedream4p5) => build_artcraft_seedream_4p5(self),
|
||||
(Provider::Artcraft, CommonImageModel::Seedream5Lite) => build_artcraft_seedream_5_lite(self),
|
||||
(Provider::Artcraft, CommonImageModel::QwenEdit2511Angles) => build_artcraft_qwen_edit_2511_angles(self),
|
||||
(Provider::Artcraft, CommonImageModel::Flux2LoraAngles) => build_artcraft_flux_2_lora_angles(self),
|
||||
(RouterProvider::Artcraft, RouterImageModel::Flux1Dev) => build_artcraft_flux_1_dev(self),
|
||||
(RouterProvider::Artcraft, RouterImageModel::Flux1Schnell) => build_artcraft_flux_1_schnell(self),
|
||||
(RouterProvider::Artcraft, RouterImageModel::FluxPro11) => build_artcraft_flux_pro_1p1(self),
|
||||
(RouterProvider::Artcraft, RouterImageModel::FluxPro11Ultra) => build_artcraft_flux_pro_1p1_ultra(self),
|
||||
(RouterProvider::Artcraft, RouterImageModel::GptImage1) => build_artcraft_gpt_image_1(self),
|
||||
(RouterProvider::Artcraft, RouterImageModel::GptImage1p5) => build_artcraft_gpt_image_1p5(self),
|
||||
(RouterProvider::Artcraft, RouterImageModel::GptImage2) => build_artcraft_gpt_image_2(self),
|
||||
(RouterProvider::Artcraft, RouterImageModel::NanoBanana) => build_artcraft_nano_banana(self),
|
||||
(RouterProvider::Artcraft, RouterImageModel::NanoBanana2) => build_artcraft_nano_banana_2(self),
|
||||
(RouterProvider::Artcraft, RouterImageModel::NanoBananaPro) => build_artcraft_nano_banana_pro(self),
|
||||
(RouterProvider::Artcraft, RouterImageModel::Seedream4) => build_artcraft_seedream_4(self),
|
||||
(RouterProvider::Artcraft, RouterImageModel::Seedream4p5) => build_artcraft_seedream_4p5(self),
|
||||
(RouterProvider::Artcraft, RouterImageModel::Seedream5Lite) => build_artcraft_seedream_5_lite(self),
|
||||
(RouterProvider::Artcraft, RouterImageModel::QwenEdit2511Angles) => build_artcraft_qwen_edit_2511_angles(self),
|
||||
(RouterProvider::Artcraft, RouterImageModel::Flux2LoraAngles) => build_artcraft_flux_2_lora_angles(self),
|
||||
|
||||
(Provider::Fal, CommonImageModel::Flux1Dev) => build_fal_flux_1_dev(self),
|
||||
(Provider::Fal, CommonImageModel::Flux1Schnell) => build_fal_flux_1_schnell(self),
|
||||
(Provider::Fal, CommonImageModel::FluxPro11) => build_fal_flux_pro_1p1(self),
|
||||
(Provider::Fal, CommonImageModel::FluxPro11Ultra) => build_fal_flux_pro_1p1_ultra(self),
|
||||
(Provider::Fal, CommonImageModel::GptImage1) => build_fal_gpt_image_1(self),
|
||||
(Provider::Fal, CommonImageModel::GptImage1p5) => build_fal_gpt_image_1p5(self),
|
||||
(Provider::Fal, CommonImageModel::GptImage2) => build_fal_gpt_image_2(self),
|
||||
(Provider::Fal, CommonImageModel::NanoBanana) => build_fal_nano_banana(self),
|
||||
(Provider::Fal, CommonImageModel::NanoBanana2) => build_fal_nano_banana_2(self),
|
||||
(Provider::Fal, CommonImageModel::NanoBananaPro) => build_fal_nano_banana_pro(self),
|
||||
(Provider::Fal, CommonImageModel::Seedream4) => build_fal_seedream_4(self),
|
||||
(Provider::Fal, CommonImageModel::Seedream4p5) => build_fal_seedream_4p5(self),
|
||||
(Provider::Fal, CommonImageModel::Seedream5Lite) => build_fal_seedream_5_lite(self),
|
||||
(Provider::Fal, CommonImageModel::QwenEdit2511Angles) => build_fal_qwen_edit_2511_angles(self),
|
||||
(Provider::Fal, CommonImageModel::Flux2LoraAngles) => build_fal_flux_2_lora_angles(self),
|
||||
(RouterProvider::Fal, RouterImageModel::Flux1Dev) => build_fal_flux_1_dev(self),
|
||||
(RouterProvider::Fal, RouterImageModel::Flux1Schnell) => build_fal_flux_1_schnell(self),
|
||||
(RouterProvider::Fal, RouterImageModel::FluxPro11) => build_fal_flux_pro_1p1(self),
|
||||
(RouterProvider::Fal, RouterImageModel::FluxPro11Ultra) => build_fal_flux_pro_1p1_ultra(self),
|
||||
(RouterProvider::Fal, RouterImageModel::GptImage1) => build_fal_gpt_image_1(self),
|
||||
(RouterProvider::Fal, RouterImageModel::GptImage1p5) => build_fal_gpt_image_1p5(self),
|
||||
(RouterProvider::Fal, RouterImageModel::GptImage2) => build_fal_gpt_image_2(self),
|
||||
(RouterProvider::Fal, RouterImageModel::NanoBanana) => build_fal_nano_banana(self),
|
||||
(RouterProvider::Fal, RouterImageModel::NanoBanana2) => build_fal_nano_banana_2(self),
|
||||
(RouterProvider::Fal, RouterImageModel::NanoBananaPro) => build_fal_nano_banana_pro(self),
|
||||
(RouterProvider::Fal, RouterImageModel::Seedream4) => build_fal_seedream_4(self),
|
||||
(RouterProvider::Fal, RouterImageModel::Seedream4p5) => build_fal_seedream_4p5(self),
|
||||
(RouterProvider::Fal, RouterImageModel::Seedream5Lite) => build_fal_seedream_5_lite(self),
|
||||
(RouterProvider::Fal, RouterImageModel::QwenEdit2511Angles) => build_fal_qwen_edit_2511_angles(self),
|
||||
(RouterProvider::Fal, RouterImageModel::Flux2LoraAngles) => build_fal_flux_2_lora_angles(self),
|
||||
|
||||
_ => self.unsupported_provider_and_model(),
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
use crate::api::provider::Provider;
|
||||
use crate::api::router_provider::RouterProvider;
|
||||
use crate::errors::artcraft_router_error::ArtcraftRouterError;
|
||||
use crate::generate::generate_image::image_generation_cost_estimate::ImageGenerationCostEstimate;
|
||||
use crate::generate::generate_image_v2::image_generation_draft_context::ImageGenerationDraftContext;
|
||||
@@ -14,7 +14,7 @@ pub enum ImageGenerationDraftRequest {
|
||||
}
|
||||
|
||||
impl ImageGenerationDraftRequest {
|
||||
pub fn get_provider(&self) -> Provider {
|
||||
pub fn get_provider(&self) -> RouterProvider {
|
||||
match *self {}
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
use crate::api::provider::Provider;
|
||||
use crate::api::router_provider::RouterProvider;
|
||||
use crate::errors::artcraft_router_error::ArtcraftRouterError;
|
||||
use crate::generate::generate_image::image_generation_cost_estimate::ImageGenerationCostEstimate;
|
||||
use crate::generate::generate_image_v2::image_generation_draft::ImageGenerationDraftRequest;
|
||||
@@ -11,7 +11,7 @@ pub enum ImageGenerationDraftOrRequest {
|
||||
}
|
||||
|
||||
impl ImageGenerationDraftOrRequest {
|
||||
pub fn get_provider(&self) -> Provider {
|
||||
pub fn get_provider(&self) -> RouterProvider {
|
||||
match self {
|
||||
Self::Draft(draft) => draft.get_provider(),
|
||||
Self::Request(request) => request.get_provider(),
|
||||
|
||||
+32
-32
@@ -1,4 +1,4 @@
|
||||
use crate::api::provider::Provider;
|
||||
use crate::api::router_provider::RouterProvider;
|
||||
use crate::client::router_client::RouterClient;
|
||||
use crate::errors::artcraft_router_error::ArtcraftRouterError;
|
||||
use crate::generate::generate_image::generate_image_response::GenerateImageResponse;
|
||||
@@ -102,39 +102,39 @@ pub enum ImageGenerationRequest {
|
||||
}
|
||||
|
||||
impl ImageGenerationRequest {
|
||||
pub fn get_provider(&self) -> Provider {
|
||||
pub fn get_provider(&self) -> RouterProvider {
|
||||
match self {
|
||||
Self::ArtcraftFlux1Dev(_) => Provider::Artcraft,
|
||||
Self::ArtcraftFlux1Schnell(_) => Provider::Artcraft,
|
||||
Self::ArtcraftFluxPro1p1(_) => Provider::Artcraft,
|
||||
Self::ArtcraftFluxPro1p1Ultra(_) => Provider::Artcraft,
|
||||
Self::ArtcraftGptImage1(_) => Provider::Artcraft,
|
||||
Self::ArtcraftGptImage1p5(_) => Provider::Artcraft,
|
||||
Self::ArtcraftGptImage2(_) => Provider::Artcraft,
|
||||
Self::ArtcraftNanoBanana(_) => Provider::Artcraft,
|
||||
Self::ArtcraftNanoBanana2(_) => Provider::Artcraft,
|
||||
Self::ArtcraftNanoBananaPro(_) => Provider::Artcraft,
|
||||
Self::ArtcraftSeedream4(_) => Provider::Artcraft,
|
||||
Self::ArtcraftSeedream4p5(_) => Provider::Artcraft,
|
||||
Self::ArtcraftSeedream5Lite(_) => Provider::Artcraft,
|
||||
Self::ArtcraftQwenEdit2511Angles(_) => Provider::Artcraft,
|
||||
Self::ArtcraftFlux2LoraAngles(_) => Provider::Artcraft,
|
||||
Self::ArtcraftFlux1Dev(_) => RouterProvider::Artcraft,
|
||||
Self::ArtcraftFlux1Schnell(_) => RouterProvider::Artcraft,
|
||||
Self::ArtcraftFluxPro1p1(_) => RouterProvider::Artcraft,
|
||||
Self::ArtcraftFluxPro1p1Ultra(_) => RouterProvider::Artcraft,
|
||||
Self::ArtcraftGptImage1(_) => RouterProvider::Artcraft,
|
||||
Self::ArtcraftGptImage1p5(_) => RouterProvider::Artcraft,
|
||||
Self::ArtcraftGptImage2(_) => RouterProvider::Artcraft,
|
||||
Self::ArtcraftNanoBanana(_) => RouterProvider::Artcraft,
|
||||
Self::ArtcraftNanoBanana2(_) => RouterProvider::Artcraft,
|
||||
Self::ArtcraftNanoBananaPro(_) => RouterProvider::Artcraft,
|
||||
Self::ArtcraftSeedream4(_) => RouterProvider::Artcraft,
|
||||
Self::ArtcraftSeedream4p5(_) => RouterProvider::Artcraft,
|
||||
Self::ArtcraftSeedream5Lite(_) => RouterProvider::Artcraft,
|
||||
Self::ArtcraftQwenEdit2511Angles(_) => RouterProvider::Artcraft,
|
||||
Self::ArtcraftFlux2LoraAngles(_) => RouterProvider::Artcraft,
|
||||
|
||||
Self::FalFlux1Dev(_) => Provider::Fal,
|
||||
Self::FalFlux1Schnell(_) => Provider::Fal,
|
||||
Self::FalFluxPro1p1(_) => Provider::Fal,
|
||||
Self::FalFluxPro1p1Ultra(_) => Provider::Fal,
|
||||
Self::FalGptImage1(_) => Provider::Fal,
|
||||
Self::FalGptImage1p5(_) => Provider::Fal,
|
||||
Self::FalGptImage2(_) => Provider::Fal,
|
||||
Self::FalNanoBanana(_) => Provider::Fal,
|
||||
Self::FalNanoBanana2(_) => Provider::Fal,
|
||||
Self::FalNanoBananaPro(_) => Provider::Fal,
|
||||
Self::FalSeedream4(_) => Provider::Fal,
|
||||
Self::FalSeedream4p5(_) => Provider::Fal,
|
||||
Self::FalSeedream5Lite(_) => Provider::Fal,
|
||||
Self::FalQwenEdit2511Angles(_) => Provider::Fal,
|
||||
Self::FalFlux2LoraAngles(_) => Provider::Fal,
|
||||
Self::FalFlux1Dev(_) => RouterProvider::Fal,
|
||||
Self::FalFlux1Schnell(_) => RouterProvider::Fal,
|
||||
Self::FalFluxPro1p1(_) => RouterProvider::Fal,
|
||||
Self::FalFluxPro1p1Ultra(_) => RouterProvider::Fal,
|
||||
Self::FalGptImage1(_) => RouterProvider::Fal,
|
||||
Self::FalGptImage1p5(_) => RouterProvider::Fal,
|
||||
Self::FalGptImage2(_) => RouterProvider::Fal,
|
||||
Self::FalNanoBanana(_) => RouterProvider::Fal,
|
||||
Self::FalNanoBanana2(_) => RouterProvider::Fal,
|
||||
Self::FalNanoBananaPro(_) => RouterProvider::Fal,
|
||||
Self::FalSeedream4(_) => RouterProvider::Fal,
|
||||
Self::FalSeedream4p5(_) => RouterProvider::Fal,
|
||||
Self::FalSeedream5Lite(_) => RouterProvider::Fal,
|
||||
Self::FalQwenEdit2511Angles(_) => RouterProvider::Fal,
|
||||
Self::FalFlux2LoraAngles(_) => RouterProvider::Fal,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+35
-35
@@ -5,9 +5,9 @@ use enums::common::generation::common_quality::CommonQuality as CommonQualityEnu
|
||||
use enums::common::generation::common_resolution::CommonResolution as CommonResolutionEnum;
|
||||
use tokens::tokens::media_files::MediaFileToken;
|
||||
|
||||
use crate::api::common_aspect_ratio::CommonAspectRatio;
|
||||
use crate::api::common_quality::CommonQuality;
|
||||
use crate::api::common_resolution::CommonResolution;
|
||||
use crate::api::router_aspect_ratio::RouterAspectRatio;
|
||||
use crate::api::router_quality::RouterQuality;
|
||||
use crate::api::router_resolution::RouterResolution;
|
||||
use crate::api::image_list_ref::ImageListRef;
|
||||
use crate::client::request_mismatch_mitigation_strategy::RequestMismatchMitigationStrategy;
|
||||
use crate::errors::artcraft_router_error::ArtcraftRouterError;
|
||||
@@ -91,46 +91,46 @@ pub fn resolve_image_list_ref(
|
||||
}
|
||||
}
|
||||
|
||||
fn to_aspect_ratio_enum(ar: CommonAspectRatio) -> CommonAspectRatioEnum {
|
||||
fn to_aspect_ratio_enum(ar: RouterAspectRatio) -> CommonAspectRatioEnum {
|
||||
match ar {
|
||||
CommonAspectRatio::Auto => CommonAspectRatioEnum::Auto,
|
||||
CommonAspectRatio::Auto2k => CommonAspectRatioEnum::Auto2k,
|
||||
CommonAspectRatio::Auto3k => CommonAspectRatioEnum::Auto3k,
|
||||
CommonAspectRatio::Auto4k => CommonAspectRatioEnum::Auto4k,
|
||||
CommonAspectRatio::Square => CommonAspectRatioEnum::Square,
|
||||
CommonAspectRatio::SquareHd => CommonAspectRatioEnum::SquareHd,
|
||||
CommonAspectRatio::WideFourByThree => CommonAspectRatioEnum::WideFourByThree,
|
||||
CommonAspectRatio::WideFiveByFour => CommonAspectRatioEnum::WideFiveByFour,
|
||||
CommonAspectRatio::WideThreeByTwo => CommonAspectRatioEnum::WideThreeByTwo,
|
||||
CommonAspectRatio::WideSixteenByNine => CommonAspectRatioEnum::WideSixteenByNine,
|
||||
CommonAspectRatio::WideTwentyOneByNine => CommonAspectRatioEnum::WideTwentyOneByNine,
|
||||
CommonAspectRatio::Wide => CommonAspectRatioEnum::Wide,
|
||||
CommonAspectRatio::TallThreeByFour => CommonAspectRatioEnum::TallThreeByFour,
|
||||
CommonAspectRatio::TallFourByFive => CommonAspectRatioEnum::TallFourByFive,
|
||||
CommonAspectRatio::TallTwoByThree => CommonAspectRatioEnum::TallTwoByThree,
|
||||
CommonAspectRatio::TallNineBySixteen => CommonAspectRatioEnum::TallNineBySixteen,
|
||||
CommonAspectRatio::TallNineByTwentyOne => CommonAspectRatioEnum::TallNineByTwentyOne,
|
||||
CommonAspectRatio::Tall => CommonAspectRatioEnum::Tall,
|
||||
RouterAspectRatio::Auto => CommonAspectRatioEnum::Auto,
|
||||
RouterAspectRatio::Auto2k => CommonAspectRatioEnum::Auto2k,
|
||||
RouterAspectRatio::Auto3k => CommonAspectRatioEnum::Auto3k,
|
||||
RouterAspectRatio::Auto4k => CommonAspectRatioEnum::Auto4k,
|
||||
RouterAspectRatio::Square => CommonAspectRatioEnum::Square,
|
||||
RouterAspectRatio::SquareHd => CommonAspectRatioEnum::SquareHd,
|
||||
RouterAspectRatio::WideFourByThree => CommonAspectRatioEnum::WideFourByThree,
|
||||
RouterAspectRatio::WideFiveByFour => CommonAspectRatioEnum::WideFiveByFour,
|
||||
RouterAspectRatio::WideThreeByTwo => CommonAspectRatioEnum::WideThreeByTwo,
|
||||
RouterAspectRatio::WideSixteenByNine => CommonAspectRatioEnum::WideSixteenByNine,
|
||||
RouterAspectRatio::WideTwentyOneByNine => CommonAspectRatioEnum::WideTwentyOneByNine,
|
||||
RouterAspectRatio::Wide => CommonAspectRatioEnum::Wide,
|
||||
RouterAspectRatio::TallThreeByFour => CommonAspectRatioEnum::TallThreeByFour,
|
||||
RouterAspectRatio::TallFourByFive => CommonAspectRatioEnum::TallFourByFive,
|
||||
RouterAspectRatio::TallTwoByThree => CommonAspectRatioEnum::TallTwoByThree,
|
||||
RouterAspectRatio::TallNineBySixteen => CommonAspectRatioEnum::TallNineBySixteen,
|
||||
RouterAspectRatio::TallNineByTwentyOne => CommonAspectRatioEnum::TallNineByTwentyOne,
|
||||
RouterAspectRatio::Tall => CommonAspectRatioEnum::Tall,
|
||||
}
|
||||
}
|
||||
|
||||
fn to_resolution_enum(r: CommonResolution) -> CommonResolutionEnum {
|
||||
fn to_resolution_enum(r: RouterResolution) -> CommonResolutionEnum {
|
||||
match r {
|
||||
CommonResolution::HalfK => CommonResolutionEnum::HalfK,
|
||||
CommonResolution::OneK => CommonResolutionEnum::OneK,
|
||||
CommonResolution::TwoK => CommonResolutionEnum::TwoK,
|
||||
CommonResolution::ThreeK => CommonResolutionEnum::ThreeK,
|
||||
CommonResolution::FourK => CommonResolutionEnum::FourK,
|
||||
CommonResolution::FourEightyP => CommonResolutionEnum::FourEightyP,
|
||||
CommonResolution::SevenTwentyP => CommonResolutionEnum::SevenTwentyP,
|
||||
CommonResolution::TenEightyP => CommonResolutionEnum::TenEightyP,
|
||||
RouterResolution::HalfK => CommonResolutionEnum::HalfK,
|
||||
RouterResolution::OneK => CommonResolutionEnum::OneK,
|
||||
RouterResolution::TwoK => CommonResolutionEnum::TwoK,
|
||||
RouterResolution::ThreeK => CommonResolutionEnum::ThreeK,
|
||||
RouterResolution::FourK => CommonResolutionEnum::FourK,
|
||||
RouterResolution::FourEightyP => CommonResolutionEnum::FourEightyP,
|
||||
RouterResolution::SevenTwentyP => CommonResolutionEnum::SevenTwentyP,
|
||||
RouterResolution::TenEightyP => CommonResolutionEnum::TenEightyP,
|
||||
}
|
||||
}
|
||||
|
||||
fn to_quality_enum(q: CommonQuality) -> CommonQualityEnum {
|
||||
fn to_quality_enum(q: RouterQuality) -> CommonQualityEnum {
|
||||
match q {
|
||||
CommonQuality::Low => CommonQualityEnum::Low,
|
||||
CommonQuality::Medium => CommonQualityEnum::Medium,
|
||||
CommonQuality::High => CommonQualityEnum::High,
|
||||
RouterQuality::Low => CommonQualityEnum::Low,
|
||||
RouterQuality::Medium => CommonQualityEnum::Medium,
|
||||
RouterQuality::High => CommonQualityEnum::High,
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -33,15 +33,15 @@ impl ArtcraftFlux1DevCostState {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::api::common_image_model::CommonImageModel;
|
||||
use crate::api::provider::Provider;
|
||||
use crate::api::router_image_model::RouterImageModel;
|
||||
use crate::api::router_provider::RouterProvider;
|
||||
use crate::client::request_mismatch_mitigation_strategy::RequestMismatchMitigationStrategy;
|
||||
use crate::generate::generate_image::generate_image_request_builder::GenerateImageRequestBuilder;
|
||||
|
||||
fn cost_cents(image_batch_count: u16) -> u64 {
|
||||
let builder = GenerateImageRequestBuilder {
|
||||
model: CommonImageModel::Flux1Dev,
|
||||
provider: Provider::Artcraft,
|
||||
model: RouterImageModel::Flux1Dev,
|
||||
provider: RouterProvider::Artcraft,
|
||||
prompt: None,
|
||||
image_inputs: None,
|
||||
resolution: None,
|
||||
|
||||
+4
-4
@@ -27,15 +27,15 @@ impl ArtcraftFlux1SchnellCostState {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::api::common_image_model::CommonImageModel;
|
||||
use crate::api::provider::Provider;
|
||||
use crate::api::router_image_model::RouterImageModel;
|
||||
use crate::api::router_provider::RouterProvider;
|
||||
use crate::client::request_mismatch_mitigation_strategy::RequestMismatchMitigationStrategy;
|
||||
use crate::generate::generate_image::generate_image_request_builder::GenerateImageRequestBuilder;
|
||||
|
||||
fn build_estimate() -> crate::generate::generate_image::image_generation_cost_estimate::ImageGenerationCostEstimate {
|
||||
let builder = GenerateImageRequestBuilder {
|
||||
model: CommonImageModel::Flux1Schnell,
|
||||
provider: Provider::Artcraft,
|
||||
model: RouterImageModel::Flux1Schnell,
|
||||
provider: RouterProvider::Artcraft,
|
||||
prompt: None,
|
||||
image_inputs: None,
|
||||
resolution: None,
|
||||
|
||||
+4
-4
@@ -32,17 +32,17 @@ impl ArtcraftFlux2LoraAnglesCostState {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::api::common_image_model::CommonImageModel;
|
||||
use crate::api::router_image_model::RouterImageModel;
|
||||
use crate::api::image_list_ref::ImageListRef;
|
||||
use crate::api::provider::Provider;
|
||||
use crate::api::router_provider::RouterProvider;
|
||||
use crate::client::request_mismatch_mitigation_strategy::RequestMismatchMitigationStrategy;
|
||||
use crate::generate::generate_image::generate_image_request_builder::GenerateImageRequestBuilder;
|
||||
use tokens::tokens::media_files::MediaFileToken;
|
||||
|
||||
fn cost_cents(image_batch_count: u16) -> u64 {
|
||||
let builder = GenerateImageRequestBuilder {
|
||||
model: CommonImageModel::Flux2LoraAngles,
|
||||
provider: Provider::Artcraft,
|
||||
model: RouterImageModel::Flux2LoraAngles,
|
||||
provider: RouterProvider::Artcraft,
|
||||
prompt: None,
|
||||
image_inputs: Some(ImageListRef::MediaFileTokens(vec![MediaFileToken::new_from_str("mf_test")])),
|
||||
resolution: None,
|
||||
|
||||
+4
-4
@@ -32,15 +32,15 @@ impl ArtcraftFluxPro1p1CostState {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::api::common_image_model::CommonImageModel;
|
||||
use crate::api::provider::Provider;
|
||||
use crate::api::router_image_model::RouterImageModel;
|
||||
use crate::api::router_provider::RouterProvider;
|
||||
use crate::client::request_mismatch_mitigation_strategy::RequestMismatchMitigationStrategy;
|
||||
use crate::generate::generate_image::generate_image_request_builder::GenerateImageRequestBuilder;
|
||||
|
||||
fn cost_cents(image_batch_count: u16) -> u64 {
|
||||
let builder = GenerateImageRequestBuilder {
|
||||
model: CommonImageModel::FluxPro11,
|
||||
provider: Provider::Artcraft,
|
||||
model: RouterImageModel::FluxPro11,
|
||||
provider: RouterProvider::Artcraft,
|
||||
prompt: None,
|
||||
image_inputs: None,
|
||||
resolution: None,
|
||||
|
||||
+4
-4
@@ -31,15 +31,15 @@ impl ArtcraftFluxPro1p1UltraCostState {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::api::common_image_model::CommonImageModel;
|
||||
use crate::api::provider::Provider;
|
||||
use crate::api::router_image_model::RouterImageModel;
|
||||
use crate::api::router_provider::RouterProvider;
|
||||
use crate::client::request_mismatch_mitigation_strategy::RequestMismatchMitigationStrategy;
|
||||
use crate::generate::generate_image::generate_image_request_builder::GenerateImageRequestBuilder;
|
||||
|
||||
fn cost_cents(image_batch_count: u16) -> u64 {
|
||||
let builder = GenerateImageRequestBuilder {
|
||||
model: CommonImageModel::FluxPro11Ultra,
|
||||
provider: Provider::Artcraft,
|
||||
model: RouterImageModel::FluxPro11Ultra,
|
||||
provider: RouterProvider::Artcraft,
|
||||
prompt: None,
|
||||
image_inputs: None,
|
||||
resolution: None,
|
||||
|
||||
+21
-21
@@ -79,19 +79,19 @@ fn is_square_or_none(aspect_ratio: Option<CommonAspectRatioEnum>) -> bool {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::api::common_aspect_ratio::CommonAspectRatio;
|
||||
use crate::api::common_image_model::CommonImageModel;
|
||||
use crate::api::common_quality::CommonQuality;
|
||||
use crate::api::router_aspect_ratio::RouterAspectRatio;
|
||||
use crate::api::router_image_model::RouterImageModel;
|
||||
use crate::api::router_quality::RouterQuality;
|
||||
use crate::api::image_list_ref::ImageListRef;
|
||||
use crate::api::provider::Provider;
|
||||
use crate::api::router_provider::RouterProvider;
|
||||
use crate::client::request_mismatch_mitigation_strategy::RequestMismatchMitigationStrategy;
|
||||
use crate::generate::generate_image::generate_image_request_builder::GenerateImageRequestBuilder;
|
||||
use tokens::tokens::media_files::MediaFileToken;
|
||||
|
||||
fn base() -> GenerateImageRequestBuilder {
|
||||
GenerateImageRequestBuilder {
|
||||
model: CommonImageModel::GptImage1,
|
||||
provider: Provider::Artcraft,
|
||||
model: RouterImageModel::GptImage1,
|
||||
provider: RouterProvider::Artcraft,
|
||||
prompt: None,
|
||||
image_inputs: None,
|
||||
resolution: None,
|
||||
@@ -107,7 +107,7 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
fn cost_text(quality: Option<CommonQuality>, aspect_ratio: Option<CommonAspectRatio>, batch: u16) -> u64 {
|
||||
fn cost_text(quality: Option<RouterQuality>, aspect_ratio: Option<RouterAspectRatio>, batch: u16) -> u64 {
|
||||
let builder = GenerateImageRequestBuilder {
|
||||
quality,
|
||||
aspect_ratio,
|
||||
@@ -117,7 +117,7 @@ mod tests {
|
||||
builder.build2().unwrap().estimate_cost().unwrap().cost_in_usd_cents.unwrap()
|
||||
}
|
||||
|
||||
fn cost_edit(quality: Option<CommonQuality>, aspect_ratio: Option<CommonAspectRatio>, batch: u16, num_inputs: usize) -> u64 {
|
||||
fn cost_edit(quality: Option<RouterQuality>, aspect_ratio: Option<RouterAspectRatio>, batch: u16, num_inputs: usize) -> u64 {
|
||||
let tokens: Vec<MediaFileToken> = (0..num_inputs)
|
||||
.map(|i| MediaFileToken::new_from_str(&format!("mf_test{:028}", i)))
|
||||
.collect();
|
||||
@@ -142,53 +142,53 @@ mod tests {
|
||||
// ── Low → 2¢ all sizes ────────────────────────────────────────────────────
|
||||
|
||||
#[test]
|
||||
fn low_square_one() { assert_eq!(cost_text(Some(CommonQuality::Low), Some(CommonAspectRatio::Square), 1), 2); }
|
||||
fn low_square_one() { assert_eq!(cost_text(Some(RouterQuality::Low), Some(RouterAspectRatio::Square), 1), 2); }
|
||||
|
||||
#[test]
|
||||
fn low_wide_one() { assert_eq!(cost_text(Some(CommonQuality::Low), Some(CommonAspectRatio::WideSixteenByNine), 1), 2); }
|
||||
fn low_wide_one() { assert_eq!(cost_text(Some(RouterQuality::Low), Some(RouterAspectRatio::WideSixteenByNine), 1), 2); }
|
||||
|
||||
#[test]
|
||||
fn low_tall_one() { assert_eq!(cost_text(Some(CommonQuality::Low), Some(CommonAspectRatio::TallNineBySixteen), 1), 2); }
|
||||
fn low_tall_one() { assert_eq!(cost_text(Some(RouterQuality::Low), Some(RouterAspectRatio::TallNineBySixteen), 1), 2); }
|
||||
|
||||
#[test]
|
||||
fn low_four_images() { assert_eq!(cost_text(Some(CommonQuality::Low), None, 4), 8); }
|
||||
fn low_four_images() { assert_eq!(cost_text(Some(RouterQuality::Low), None, 4), 8); }
|
||||
|
||||
// ── Medium ────────────────────────────────────────────────────────────────
|
||||
|
||||
#[test]
|
||||
fn medium_square_one() { assert_eq!(cost_text(Some(CommonQuality::Medium), Some(CommonAspectRatio::Square), 1), 5); }
|
||||
fn medium_square_one() { assert_eq!(cost_text(Some(RouterQuality::Medium), Some(RouterAspectRatio::Square), 1), 5); }
|
||||
|
||||
#[test]
|
||||
fn medium_wide_one() { assert_eq!(cost_text(Some(CommonQuality::Medium), Some(CommonAspectRatio::WideSixteenByNine), 1), 7); }
|
||||
fn medium_wide_one() { assert_eq!(cost_text(Some(RouterQuality::Medium), Some(RouterAspectRatio::WideSixteenByNine), 1), 7); }
|
||||
|
||||
#[test]
|
||||
fn medium_tall_one() { assert_eq!(cost_text(Some(CommonQuality::Medium), Some(CommonAspectRatio::TallNineBySixteen), 1), 7); }
|
||||
fn medium_tall_one() { assert_eq!(cost_text(Some(RouterQuality::Medium), Some(RouterAspectRatio::TallNineBySixteen), 1), 7); }
|
||||
|
||||
// ── High ──────────────────────────────────────────────────────────────────
|
||||
|
||||
#[test]
|
||||
fn high_square_one() { assert_eq!(cost_text(Some(CommonQuality::High), Some(CommonAspectRatio::Square), 1), 17); }
|
||||
fn high_square_one() { assert_eq!(cost_text(Some(RouterQuality::High), Some(RouterAspectRatio::Square), 1), 17); }
|
||||
|
||||
#[test]
|
||||
fn high_wide_one() { assert_eq!(cost_text(Some(CommonQuality::High), Some(CommonAspectRatio::WideSixteenByNine), 1), 25); }
|
||||
fn high_wide_one() { assert_eq!(cost_text(Some(RouterQuality::High), Some(RouterAspectRatio::WideSixteenByNine), 1), 25); }
|
||||
|
||||
#[test]
|
||||
fn high_wide_four() { assert_eq!(cost_text(Some(CommonQuality::High), Some(CommonAspectRatio::WideSixteenByNine), 4), 100); }
|
||||
fn high_wide_four() { assert_eq!(cost_text(Some(RouterQuality::High), Some(RouterAspectRatio::WideSixteenByNine), 4), 100); }
|
||||
|
||||
// ── Edit mode adds 2¢ per input image ─────────────────────────────────────
|
||||
|
||||
#[test]
|
||||
fn edit_one_input_adds_2c() {
|
||||
assert_eq!(cost_edit(Some(CommonQuality::High), Some(CommonAspectRatio::Square), 1, 1), 19);
|
||||
assert_eq!(cost_edit(Some(RouterQuality::High), Some(RouterAspectRatio::Square), 1, 1), 19);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn edit_three_inputs_adds_6c() {
|
||||
assert_eq!(cost_edit(Some(CommonQuality::High), Some(CommonAspectRatio::Square), 1, 3), 23);
|
||||
assert_eq!(cost_edit(Some(RouterQuality::High), Some(RouterAspectRatio::Square), 1, 3), 23);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn edit_five_inputs_adds_10c() {
|
||||
assert_eq!(cost_edit(Some(CommonQuality::Medium), Some(CommonAspectRatio::WideSixteenByNine), 2, 5), 24);
|
||||
assert_eq!(cost_edit(Some(RouterQuality::Medium), Some(RouterAspectRatio::WideSixteenByNine), 2, 5), 24);
|
||||
}
|
||||
}
|
||||
|
||||
+20
-20
@@ -94,17 +94,17 @@ fn size_bucket(aspect_ratio: Option<CommonAspectRatioEnum>) -> SizeBucket {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::api::common_aspect_ratio::CommonAspectRatio;
|
||||
use crate::api::common_image_model::CommonImageModel;
|
||||
use crate::api::common_quality::CommonQuality;
|
||||
use crate::api::provider::Provider;
|
||||
use crate::api::router_aspect_ratio::RouterAspectRatio;
|
||||
use crate::api::router_image_model::RouterImageModel;
|
||||
use crate::api::router_quality::RouterQuality;
|
||||
use crate::api::router_provider::RouterProvider;
|
||||
use crate::client::request_mismatch_mitigation_strategy::RequestMismatchMitigationStrategy;
|
||||
use crate::generate::generate_image::generate_image_request_builder::GenerateImageRequestBuilder;
|
||||
|
||||
fn cost_cents(quality: Option<CommonQuality>, aspect_ratio: Option<CommonAspectRatio>, batch: u16) -> u64 {
|
||||
fn cost_cents(quality: Option<RouterQuality>, aspect_ratio: Option<RouterAspectRatio>, batch: u16) -> u64 {
|
||||
let builder = GenerateImageRequestBuilder {
|
||||
model: CommonImageModel::GptImage1p5,
|
||||
provider: Provider::Artcraft,
|
||||
model: RouterImageModel::GptImage1p5,
|
||||
provider: RouterProvider::Artcraft,
|
||||
prompt: None,
|
||||
image_inputs: None,
|
||||
resolution: None,
|
||||
@@ -124,50 +124,50 @@ mod tests {
|
||||
// ── Default (None → High) ─────────────────────────────────────────────────
|
||||
|
||||
#[test]
|
||||
fn default_square_one() { assert_eq!(cost_cents(None, Some(CommonAspectRatio::Square), 1), 14); }
|
||||
fn default_square_one() { assert_eq!(cost_cents(None, Some(RouterAspectRatio::Square), 1), 14); }
|
||||
|
||||
#[test]
|
||||
fn default_unset_one() { assert_eq!(cost_cents(None, None, 1), 14); }
|
||||
|
||||
#[test]
|
||||
fn default_wide_one() { assert_eq!(cost_cents(None, Some(CommonAspectRatio::WideSixteenByNine), 1), 20); }
|
||||
fn default_wide_one() { assert_eq!(cost_cents(None, Some(RouterAspectRatio::WideSixteenByNine), 1), 20); }
|
||||
|
||||
#[test]
|
||||
fn default_tall_one() { assert_eq!(cost_cents(None, Some(CommonAspectRatio::TallNineBySixteen), 1), 20); }
|
||||
fn default_tall_one() { assert_eq!(cost_cents(None, Some(RouterAspectRatio::TallNineBySixteen), 1), 20); }
|
||||
|
||||
#[test]
|
||||
fn default_square_four() { assert_eq!(cost_cents(None, Some(CommonAspectRatio::Square), 4), 56); }
|
||||
fn default_square_four() { assert_eq!(cost_cents(None, Some(RouterAspectRatio::Square), 4), 56); }
|
||||
|
||||
// ── Low ───────────────────────────────────────────────────────────────────
|
||||
|
||||
#[test]
|
||||
fn low_square_one() { assert_eq!(cost_cents(Some(CommonQuality::Low), Some(CommonAspectRatio::Square), 1), 1); }
|
||||
fn low_square_one() { assert_eq!(cost_cents(Some(RouterQuality::Low), Some(RouterAspectRatio::Square), 1), 1); }
|
||||
|
||||
#[test]
|
||||
fn low_wide_one() { assert_eq!(cost_cents(Some(CommonQuality::Low), Some(CommonAspectRatio::WideSixteenByNine), 1), 2); }
|
||||
fn low_wide_one() { assert_eq!(cost_cents(Some(RouterQuality::Low), Some(RouterAspectRatio::WideSixteenByNine), 1), 2); }
|
||||
|
||||
#[test]
|
||||
fn low_tall_one() { assert_eq!(cost_cents(Some(CommonQuality::Low), Some(CommonAspectRatio::TallNineBySixteen), 1), 2); }
|
||||
fn low_tall_one() { assert_eq!(cost_cents(Some(RouterQuality::Low), Some(RouterAspectRatio::TallNineBySixteen), 1), 2); }
|
||||
|
||||
// ── Medium ────────────────────────────────────────────────────────────────
|
||||
|
||||
#[test]
|
||||
fn medium_square_one() { assert_eq!(cost_cents(Some(CommonQuality::Medium), Some(CommonAspectRatio::Square), 1), 4); }
|
||||
fn medium_square_one() { assert_eq!(cost_cents(Some(RouterQuality::Medium), Some(RouterAspectRatio::Square), 1), 4); }
|
||||
|
||||
#[test]
|
||||
fn medium_wide_one() { assert_eq!(cost_cents(Some(CommonQuality::Medium), Some(CommonAspectRatio::WideSixteenByNine), 1), 5); }
|
||||
fn medium_wide_one() { assert_eq!(cost_cents(Some(RouterQuality::Medium), Some(RouterAspectRatio::WideSixteenByNine), 1), 5); }
|
||||
|
||||
#[test]
|
||||
fn medium_tall_one() { assert_eq!(cost_cents(Some(CommonQuality::Medium), Some(CommonAspectRatio::TallNineBySixteen), 1), 6); }
|
||||
fn medium_tall_one() { assert_eq!(cost_cents(Some(RouterQuality::Medium), Some(RouterAspectRatio::TallNineBySixteen), 1), 6); }
|
||||
|
||||
#[test]
|
||||
fn medium_tall_four() { assert_eq!(cost_cents(Some(CommonQuality::Medium), Some(CommonAspectRatio::TallNineBySixteen), 4), 24); }
|
||||
fn medium_tall_four() { assert_eq!(cost_cents(Some(RouterQuality::Medium), Some(RouterAspectRatio::TallNineBySixteen), 4), 24); }
|
||||
|
||||
// ── High ──────────────────────────────────────────────────────────────────
|
||||
|
||||
#[test]
|
||||
fn high_square_one() { assert_eq!(cost_cents(Some(CommonQuality::High), Some(CommonAspectRatio::Square), 1), 14); }
|
||||
fn high_square_one() { assert_eq!(cost_cents(Some(RouterQuality::High), Some(RouterAspectRatio::Square), 1), 14); }
|
||||
|
||||
#[test]
|
||||
fn high_wide_four() { assert_eq!(cost_cents(Some(CommonQuality::High), Some(CommonAspectRatio::WideSixteenByNine), 4), 80); }
|
||||
fn high_wide_four() { assert_eq!(cost_cents(Some(RouterQuality::High), Some(RouterAspectRatio::WideSixteenByNine), 4), 80); }
|
||||
}
|
||||
|
||||
+26
-26
@@ -109,17 +109,17 @@ fn size_bucket(aspect_ratio: Option<CommonAspectRatioEnum>) -> SizeBucket {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::api::common_aspect_ratio::CommonAspectRatio;
|
||||
use crate::api::common_image_model::CommonImageModel;
|
||||
use crate::api::common_quality::CommonQuality;
|
||||
use crate::api::provider::Provider;
|
||||
use crate::api::router_aspect_ratio::RouterAspectRatio;
|
||||
use crate::api::router_image_model::RouterImageModel;
|
||||
use crate::api::router_quality::RouterQuality;
|
||||
use crate::api::router_provider::RouterProvider;
|
||||
use crate::client::request_mismatch_mitigation_strategy::RequestMismatchMitigationStrategy;
|
||||
use crate::generate::generate_image::generate_image_request_builder::GenerateImageRequestBuilder;
|
||||
|
||||
fn cost_cents(quality: Option<CommonQuality>, aspect_ratio: Option<CommonAspectRatio>, batch: u16) -> u64 {
|
||||
fn cost_cents(quality: Option<RouterQuality>, aspect_ratio: Option<RouterAspectRatio>, batch: u16) -> u64 {
|
||||
let builder = GenerateImageRequestBuilder {
|
||||
model: CommonImageModel::GptImage2,
|
||||
provider: Provider::Artcraft,
|
||||
model: RouterImageModel::GptImage2,
|
||||
provider: RouterProvider::Artcraft,
|
||||
prompt: None,
|
||||
image_inputs: None,
|
||||
resolution: None,
|
||||
@@ -139,63 +139,63 @@ mod tests {
|
||||
// ── Low (1¢ all sizes) ────────────────────────────────────────────────────
|
||||
|
||||
#[test]
|
||||
fn low_square() { assert_eq!(cost_cents(Some(CommonQuality::Low), Some(CommonAspectRatio::Square), 1), 1); }
|
||||
fn low_square() { assert_eq!(cost_cents(Some(RouterQuality::Low), Some(RouterAspectRatio::Square), 1), 1); }
|
||||
|
||||
#[test]
|
||||
fn low_square_hd() { assert_eq!(cost_cents(Some(CommonQuality::Low), Some(CommonAspectRatio::SquareHd), 1), 1); }
|
||||
fn low_square_hd() { assert_eq!(cost_cents(Some(RouterQuality::Low), Some(RouterAspectRatio::SquareHd), 1), 1); }
|
||||
|
||||
#[test]
|
||||
fn low_landscape_4x3() { assert_eq!(cost_cents(Some(CommonQuality::Low), Some(CommonAspectRatio::WideFourByThree), 1), 1); }
|
||||
fn low_landscape_4x3() { assert_eq!(cost_cents(Some(RouterQuality::Low), Some(RouterAspectRatio::WideFourByThree), 1), 1); }
|
||||
|
||||
#[test]
|
||||
fn low_four() { assert_eq!(cost_cents(Some(CommonQuality::Low), None, 4), 4); }
|
||||
fn low_four() { assert_eq!(cost_cents(Some(RouterQuality::Low), None, 4), 4); }
|
||||
|
||||
// ── Medium ────────────────────────────────────────────────────────────────
|
||||
|
||||
#[test]
|
||||
fn medium_square_is_6c() { assert_eq!(cost_cents(Some(CommonQuality::Medium), Some(CommonAspectRatio::Square), 1), 6); }
|
||||
fn medium_square_is_6c() { assert_eq!(cost_cents(Some(RouterQuality::Medium), Some(RouterAspectRatio::Square), 1), 6); }
|
||||
|
||||
#[test]
|
||||
fn medium_square_hd_is_6c() { assert_eq!(cost_cents(Some(CommonQuality::Medium), Some(CommonAspectRatio::SquareHd), 1), 6); }
|
||||
fn medium_square_hd_is_6c() { assert_eq!(cost_cents(Some(RouterQuality::Medium), Some(RouterAspectRatio::SquareHd), 1), 6); }
|
||||
|
||||
#[test]
|
||||
fn medium_auto_is_6c() { assert_eq!(cost_cents(Some(CommonQuality::Medium), None, 1), 6); }
|
||||
fn medium_auto_is_6c() { assert_eq!(cost_cents(Some(RouterQuality::Medium), None, 1), 6); }
|
||||
|
||||
#[test]
|
||||
fn medium_landscape_4x3_is_4c() { assert_eq!(cost_cents(Some(CommonQuality::Medium), Some(CommonAspectRatio::WideFourByThree), 1), 4); }
|
||||
fn medium_landscape_4x3_is_4c() { assert_eq!(cost_cents(Some(RouterQuality::Medium), Some(RouterAspectRatio::WideFourByThree), 1), 4); }
|
||||
|
||||
#[test]
|
||||
fn medium_portrait_4x3_is_4c() { assert_eq!(cost_cents(Some(CommonQuality::Medium), Some(CommonAspectRatio::TallThreeByFour), 1), 4); }
|
||||
fn medium_portrait_4x3_is_4c() { assert_eq!(cost_cents(Some(RouterQuality::Medium), Some(RouterAspectRatio::TallThreeByFour), 1), 4); }
|
||||
|
||||
#[test]
|
||||
fn medium_landscape_16x9_is_4c() { assert_eq!(cost_cents(Some(CommonQuality::Medium), Some(CommonAspectRatio::WideSixteenByNine), 1), 4); }
|
||||
fn medium_landscape_16x9_is_4c() { assert_eq!(cost_cents(Some(RouterQuality::Medium), Some(RouterAspectRatio::WideSixteenByNine), 1), 4); }
|
||||
|
||||
#[test]
|
||||
fn medium_portrait_16x9_is_4c() { assert_eq!(cost_cents(Some(CommonQuality::Medium), Some(CommonAspectRatio::TallNineBySixteen), 1), 4); }
|
||||
fn medium_portrait_16x9_is_4c() { assert_eq!(cost_cents(Some(RouterQuality::Medium), Some(RouterAspectRatio::TallNineBySixteen), 1), 4); }
|
||||
|
||||
#[test]
|
||||
fn medium_square_four_is_24c() { assert_eq!(cost_cents(Some(CommonQuality::Medium), Some(CommonAspectRatio::Square), 4), 24); }
|
||||
fn medium_square_four_is_24c() { assert_eq!(cost_cents(Some(RouterQuality::Medium), Some(RouterAspectRatio::Square), 4), 24); }
|
||||
|
||||
// ── High ──────────────────────────────────────────────────────────────────
|
||||
|
||||
#[test]
|
||||
fn high_square_is_22c() { assert_eq!(cost_cents(Some(CommonQuality::High), Some(CommonAspectRatio::Square), 1), 22); }
|
||||
fn high_square_is_22c() { assert_eq!(cost_cents(Some(RouterQuality::High), Some(RouterAspectRatio::Square), 1), 22); }
|
||||
|
||||
#[test]
|
||||
fn high_square_hd_is_23c() { assert_eq!(cost_cents(Some(CommonQuality::High), Some(CommonAspectRatio::SquareHd), 1), 23); }
|
||||
fn high_square_hd_is_23c() { assert_eq!(cost_cents(Some(RouterQuality::High), Some(RouterAspectRatio::SquareHd), 1), 23); }
|
||||
|
||||
#[test]
|
||||
fn high_auto_is_23c() { assert_eq!(cost_cents(Some(CommonQuality::High), None, 1), 23); }
|
||||
fn high_auto_is_23c() { assert_eq!(cost_cents(Some(RouterQuality::High), None, 1), 23); }
|
||||
|
||||
#[test]
|
||||
fn high_landscape_4x3_is_15c() { assert_eq!(cost_cents(Some(CommonQuality::High), Some(CommonAspectRatio::WideFourByThree), 1), 15); }
|
||||
fn high_landscape_4x3_is_15c() { assert_eq!(cost_cents(Some(RouterQuality::High), Some(RouterAspectRatio::WideFourByThree), 1), 15); }
|
||||
|
||||
#[test]
|
||||
fn high_landscape_16x9_is_16c() { assert_eq!(cost_cents(Some(CommonQuality::High), Some(CommonAspectRatio::WideSixteenByNine), 1), 16); }
|
||||
fn high_landscape_16x9_is_16c() { assert_eq!(cost_cents(Some(RouterQuality::High), Some(RouterAspectRatio::WideSixteenByNine), 1), 16); }
|
||||
|
||||
#[test]
|
||||
fn high_square_four_is_88c() { assert_eq!(cost_cents(Some(CommonQuality::High), Some(CommonAspectRatio::Square), 4), 88); }
|
||||
fn high_square_four_is_88c() { assert_eq!(cost_cents(Some(RouterQuality::High), Some(RouterAspectRatio::Square), 4), 88); }
|
||||
|
||||
#[test]
|
||||
fn high_square_hd_four_is_92c() { assert_eq!(cost_cents(Some(CommonQuality::High), Some(CommonAspectRatio::SquareHd), 4), 92); }
|
||||
fn high_square_hd_four_is_92c() { assert_eq!(cost_cents(Some(RouterQuality::High), Some(RouterAspectRatio::SquareHd), 4), 92); }
|
||||
}
|
||||
|
||||
+4
-4
@@ -31,15 +31,15 @@ impl ArtcraftNanoBananaCostState {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::api::common_image_model::CommonImageModel;
|
||||
use crate::api::provider::Provider;
|
||||
use crate::api::router_image_model::RouterImageModel;
|
||||
use crate::api::router_provider::RouterProvider;
|
||||
use crate::client::request_mismatch_mitigation_strategy::RequestMismatchMitigationStrategy;
|
||||
use crate::generate::generate_image::generate_image_request_builder::GenerateImageRequestBuilder;
|
||||
|
||||
fn cost_cents(image_batch_count: u16) -> u64 {
|
||||
let builder = GenerateImageRequestBuilder {
|
||||
model: CommonImageModel::NanoBanana,
|
||||
provider: Provider::Artcraft,
|
||||
model: RouterImageModel::NanoBanana,
|
||||
provider: RouterProvider::Artcraft,
|
||||
prompt: None,
|
||||
image_inputs: None,
|
||||
resolution: None,
|
||||
|
||||
+14
-14
@@ -53,16 +53,16 @@ fn cost_per_image_in_cents(resolution: Option<CommonResolutionEnum>) -> u64 {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::api::common_image_model::CommonImageModel;
|
||||
use crate::api::common_resolution::CommonResolution;
|
||||
use crate::api::provider::Provider;
|
||||
use crate::api::router_image_model::RouterImageModel;
|
||||
use crate::api::router_resolution::RouterResolution;
|
||||
use crate::api::router_provider::RouterProvider;
|
||||
use crate::client::request_mismatch_mitigation_strategy::RequestMismatchMitigationStrategy;
|
||||
use crate::generate::generate_image::generate_image_request_builder::GenerateImageRequestBuilder;
|
||||
|
||||
fn cost_cents(resolution: Option<CommonResolution>, image_batch_count: u16) -> u64 {
|
||||
fn cost_cents(resolution: Option<RouterResolution>, image_batch_count: u16) -> u64 {
|
||||
let builder = GenerateImageRequestBuilder {
|
||||
model: CommonImageModel::NanoBanana2,
|
||||
provider: Provider::Artcraft,
|
||||
model: RouterImageModel::NanoBanana2,
|
||||
provider: RouterProvider::Artcraft,
|
||||
prompt: None,
|
||||
image_inputs: None,
|
||||
resolution,
|
||||
@@ -88,36 +88,36 @@ mod tests {
|
||||
fn default_resolution_four_images_is_32c() { assert_eq!(cost_cents(None, 4), 32); }
|
||||
|
||||
#[test]
|
||||
fn one_k_one_image_is_8c() { assert_eq!(cost_cents(Some(CommonResolution::OneK), 1), 8); }
|
||||
fn one_k_one_image_is_8c() { assert_eq!(cost_cents(Some(RouterResolution::OneK), 1), 8); }
|
||||
|
||||
// ── 0.5K (6¢) ──────────────────────────────────────────────────────────────
|
||||
|
||||
#[test]
|
||||
fn half_k_one_image_is_6c() { assert_eq!(cost_cents(Some(CommonResolution::HalfK), 1), 6); }
|
||||
fn half_k_one_image_is_6c() { assert_eq!(cost_cents(Some(RouterResolution::HalfK), 1), 6); }
|
||||
|
||||
#[test]
|
||||
fn half_k_four_images_is_24c() { assert_eq!(cost_cents(Some(CommonResolution::HalfK), 4), 24); }
|
||||
fn half_k_four_images_is_24c() { assert_eq!(cost_cents(Some(RouterResolution::HalfK), 4), 24); }
|
||||
|
||||
// ── 2K (12¢) ───────────────────────────────────────────────────────────────
|
||||
|
||||
#[test]
|
||||
fn two_k_one_image_is_12c() { assert_eq!(cost_cents(Some(CommonResolution::TwoK), 1), 12); }
|
||||
fn two_k_one_image_is_12c() { assert_eq!(cost_cents(Some(RouterResolution::TwoK), 1), 12); }
|
||||
|
||||
#[test]
|
||||
fn two_k_four_images_is_48c() { assert_eq!(cost_cents(Some(CommonResolution::TwoK), 4), 48); }
|
||||
fn two_k_four_images_is_48c() { assert_eq!(cost_cents(Some(RouterResolution::TwoK), 4), 48); }
|
||||
|
||||
// ── 3K falls back to 2K pricing ────────────────────────────────────────────
|
||||
|
||||
#[test]
|
||||
fn three_k_one_image_falls_back_to_two_k_pricing() {
|
||||
assert_eq!(cost_cents(Some(CommonResolution::ThreeK), 1), 12);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::ThreeK), 1), 12);
|
||||
}
|
||||
|
||||
// ── 4K (16¢) ───────────────────────────────────────────────────────────────
|
||||
|
||||
#[test]
|
||||
fn four_k_one_image_is_16c() { assert_eq!(cost_cents(Some(CommonResolution::FourK), 1), 16); }
|
||||
fn four_k_one_image_is_16c() { assert_eq!(cost_cents(Some(RouterResolution::FourK), 1), 16); }
|
||||
|
||||
#[test]
|
||||
fn four_k_four_images_is_64c() { assert_eq!(cost_cents(Some(CommonResolution::FourK), 4), 64); }
|
||||
fn four_k_four_images_is_64c() { assert_eq!(cost_cents(Some(RouterResolution::FourK), 4), 64); }
|
||||
}
|
||||
|
||||
+16
-16
@@ -42,16 +42,16 @@ impl ArtcraftNanoBananaProCostState {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::api::common_image_model::CommonImageModel;
|
||||
use crate::api::common_resolution::CommonResolution;
|
||||
use crate::api::provider::Provider;
|
||||
use crate::api::router_image_model::RouterImageModel;
|
||||
use crate::api::router_resolution::RouterResolution;
|
||||
use crate::api::router_provider::RouterProvider;
|
||||
use crate::client::request_mismatch_mitigation_strategy::RequestMismatchMitigationStrategy;
|
||||
use crate::generate::generate_image::generate_image_request_builder::GenerateImageRequestBuilder;
|
||||
|
||||
fn cost_cents(resolution: Option<CommonResolution>, image_batch_count: u16) -> u64 {
|
||||
fn cost_cents(resolution: Option<RouterResolution>, image_batch_count: u16) -> u64 {
|
||||
let builder = GenerateImageRequestBuilder {
|
||||
model: CommonImageModel::NanoBananaPro,
|
||||
provider: Provider::Artcraft,
|
||||
model: RouterImageModel::NanoBananaPro,
|
||||
provider: RouterProvider::Artcraft,
|
||||
prompt: None,
|
||||
image_inputs: None,
|
||||
resolution,
|
||||
@@ -74,36 +74,36 @@ mod tests {
|
||||
fn default_resolution_one_image_is_15c() { assert_eq!(cost_cents(None, 1), 15); }
|
||||
|
||||
#[test]
|
||||
fn one_k_one_image_is_15c() { assert_eq!(cost_cents(Some(CommonResolution::OneK), 1), 15); }
|
||||
fn one_k_one_image_is_15c() { assert_eq!(cost_cents(Some(RouterResolution::OneK), 1), 15); }
|
||||
|
||||
#[test]
|
||||
fn two_k_one_image_is_15c() { assert_eq!(cost_cents(Some(CommonResolution::TwoK), 1), 15); }
|
||||
fn two_k_one_image_is_15c() { assert_eq!(cost_cents(Some(RouterResolution::TwoK), 1), 15); }
|
||||
|
||||
#[test]
|
||||
fn one_k_two_images_is_30c() { assert_eq!(cost_cents(Some(CommonResolution::OneK), 2), 30); }
|
||||
fn one_k_two_images_is_30c() { assert_eq!(cost_cents(Some(RouterResolution::OneK), 2), 30); }
|
||||
|
||||
#[test]
|
||||
fn one_k_four_images_is_60c() { assert_eq!(cost_cents(Some(CommonResolution::OneK), 4), 60); }
|
||||
fn one_k_four_images_is_60c() { assert_eq!(cost_cents(Some(RouterResolution::OneK), 4), 60); }
|
||||
|
||||
// ── 4K → 30¢/image ────────────────────────────────────────────────────────
|
||||
|
||||
#[test]
|
||||
fn four_k_one_image_is_30c() { assert_eq!(cost_cents(Some(CommonResolution::FourK), 1), 30); }
|
||||
fn four_k_one_image_is_30c() { assert_eq!(cost_cents(Some(RouterResolution::FourK), 1), 30); }
|
||||
|
||||
#[test]
|
||||
fn four_k_two_images_is_60c() { assert_eq!(cost_cents(Some(CommonResolution::FourK), 2), 60); }
|
||||
fn four_k_two_images_is_60c() { assert_eq!(cost_cents(Some(RouterResolution::FourK), 2), 60); }
|
||||
|
||||
#[test]
|
||||
fn four_k_four_images_is_120c() { assert_eq!(cost_cents(Some(CommonResolution::FourK), 4), 120); }
|
||||
fn four_k_four_images_is_120c() { assert_eq!(cost_cents(Some(RouterResolution::FourK), 4), 120); }
|
||||
|
||||
// ── 3K and legacy resolutions fall back to 15¢ ─────────────────────────────
|
||||
|
||||
#[test]
|
||||
fn three_k_falls_back_to_15c() { assert_eq!(cost_cents(Some(CommonResolution::ThreeK), 1), 15); }
|
||||
fn three_k_falls_back_to_15c() { assert_eq!(cost_cents(Some(RouterResolution::ThreeK), 1), 15); }
|
||||
|
||||
#[test]
|
||||
fn half_k_falls_back_to_15c() { assert_eq!(cost_cents(Some(CommonResolution::HalfK), 1), 15); }
|
||||
fn half_k_falls_back_to_15c() { assert_eq!(cost_cents(Some(RouterResolution::HalfK), 1), 15); }
|
||||
|
||||
#[test]
|
||||
fn ten_eighty_p_falls_back_to_15c() { assert_eq!(cost_cents(Some(CommonResolution::TenEightyP), 1), 15); }
|
||||
fn ten_eighty_p_falls_back_to_15c() { assert_eq!(cost_cents(Some(RouterResolution::TenEightyP), 1), 15); }
|
||||
}
|
||||
|
||||
+4
-4
@@ -31,17 +31,17 @@ impl ArtcraftQwenEdit2511AnglesCostState {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::api::common_image_model::CommonImageModel;
|
||||
use crate::api::router_image_model::RouterImageModel;
|
||||
use crate::api::image_list_ref::ImageListRef;
|
||||
use crate::api::provider::Provider;
|
||||
use crate::api::router_provider::RouterProvider;
|
||||
use crate::client::request_mismatch_mitigation_strategy::RequestMismatchMitigationStrategy;
|
||||
use crate::generate::generate_image::generate_image_request_builder::GenerateImageRequestBuilder;
|
||||
use tokens::tokens::media_files::MediaFileToken;
|
||||
|
||||
fn cost_cents(image_batch_count: u16) -> u64 {
|
||||
let builder = GenerateImageRequestBuilder {
|
||||
model: CommonImageModel::QwenEdit2511Angles,
|
||||
provider: Provider::Artcraft,
|
||||
model: RouterImageModel::QwenEdit2511Angles,
|
||||
provider: RouterProvider::Artcraft,
|
||||
prompt: None,
|
||||
image_inputs: Some(ImageListRef::MediaFileTokens(vec![MediaFileToken::new_from_str("mf_test")])),
|
||||
resolution: None,
|
||||
|
||||
+4
-4
@@ -31,15 +31,15 @@ impl ArtcraftSeedream4CostState {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::api::common_image_model::CommonImageModel;
|
||||
use crate::api::provider::Provider;
|
||||
use crate::api::router_image_model::RouterImageModel;
|
||||
use crate::api::router_provider::RouterProvider;
|
||||
use crate::client::request_mismatch_mitigation_strategy::RequestMismatchMitigationStrategy;
|
||||
use crate::generate::generate_image::generate_image_request_builder::GenerateImageRequestBuilder;
|
||||
|
||||
fn cost_cents(image_batch_count: u16) -> u64 {
|
||||
let builder = GenerateImageRequestBuilder {
|
||||
model: CommonImageModel::Seedream4,
|
||||
provider: Provider::Artcraft,
|
||||
model: RouterImageModel::Seedream4,
|
||||
provider: RouterProvider::Artcraft,
|
||||
prompt: None,
|
||||
image_inputs: None,
|
||||
resolution: None,
|
||||
|
||||
+4
-4
@@ -31,15 +31,15 @@ impl ArtcraftSeedream4p5CostState {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::api::common_image_model::CommonImageModel;
|
||||
use crate::api::provider::Provider;
|
||||
use crate::api::router_image_model::RouterImageModel;
|
||||
use crate::api::router_provider::RouterProvider;
|
||||
use crate::client::request_mismatch_mitigation_strategy::RequestMismatchMitigationStrategy;
|
||||
use crate::generate::generate_image::generate_image_request_builder::GenerateImageRequestBuilder;
|
||||
|
||||
fn cost_cents(image_batch_count: u16) -> u64 {
|
||||
let builder = GenerateImageRequestBuilder {
|
||||
model: CommonImageModel::Seedream4p5,
|
||||
provider: Provider::Artcraft,
|
||||
model: RouterImageModel::Seedream4p5,
|
||||
provider: RouterProvider::Artcraft,
|
||||
prompt: None,
|
||||
image_inputs: None,
|
||||
resolution: None,
|
||||
|
||||
+4
-4
@@ -31,15 +31,15 @@ impl ArtcraftSeedream5LiteCostState {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::api::common_image_model::CommonImageModel;
|
||||
use crate::api::provider::Provider;
|
||||
use crate::api::router_image_model::RouterImageModel;
|
||||
use crate::api::router_provider::RouterProvider;
|
||||
use crate::client::request_mismatch_mitigation_strategy::RequestMismatchMitigationStrategy;
|
||||
use crate::generate::generate_image::generate_image_request_builder::GenerateImageRequestBuilder;
|
||||
|
||||
fn cost_cents(image_batch_count: u16) -> u64 {
|
||||
let builder = GenerateImageRequestBuilder {
|
||||
model: CommonImageModel::Seedream5Lite,
|
||||
provider: Provider::Artcraft,
|
||||
model: RouterImageModel::Seedream5Lite,
|
||||
provider: RouterProvider::Artcraft,
|
||||
prompt: None,
|
||||
image_inputs: None,
|
||||
resolution: None,
|
||||
|
||||
+24
-24
@@ -5,7 +5,7 @@ use fal_client::requests::api::image::text::flux_1_dev_text_to_image::api::{
|
||||
Flux1DevTextToImageAspectRatio, Flux1DevTextToImageNumImages, Flux1DevTextToImageRequest,
|
||||
};
|
||||
|
||||
use crate::api::common_aspect_ratio::CommonAspectRatio;
|
||||
use crate::api::router_aspect_ratio::RouterAspectRatio;
|
||||
use crate::api::image_list_ref::ImageListRef;
|
||||
use crate::client::request_mismatch_mitigation_strategy::RequestMismatchMitigationStrategy;
|
||||
use crate::errors::artcraft_router_error::ArtcraftRouterError;
|
||||
@@ -101,20 +101,20 @@ fn to_edit_num_images(n: PlannedNumImages) -> Flux1DevEditImageNumImages {
|
||||
// ── Aspect ratio ──
|
||||
|
||||
fn plan_aspect_ratio(
|
||||
aspect_ratio: Option<CommonAspectRatio>,
|
||||
aspect_ratio: Option<RouterAspectRatio>,
|
||||
) -> Flux1DevTextToImageAspectRatio {
|
||||
use Flux1DevTextToImageAspectRatio as T;
|
||||
match aspect_ratio {
|
||||
None | Some(CommonAspectRatio::Auto) | Some(CommonAspectRatio::Auto2k)
|
||||
| Some(CommonAspectRatio::Auto3k) | Some(CommonAspectRatio::Auto4k) => T::SquareHd,
|
||||
Some(CommonAspectRatio::Square) => T::Square,
|
||||
Some(CommonAspectRatio::SquareHd) => T::SquareHd,
|
||||
Some(CommonAspectRatio::WideFourByThree) | Some(CommonAspectRatio::WideFiveByFour)
|
||||
| Some(CommonAspectRatio::WideThreeByTwo) | Some(CommonAspectRatio::Wide) => T::LandscapeFourByThree,
|
||||
Some(CommonAspectRatio::WideSixteenByNine) | Some(CommonAspectRatio::WideTwentyOneByNine) => T::LandscapeSixteenByNine,
|
||||
Some(CommonAspectRatio::TallThreeByFour) | Some(CommonAspectRatio::TallFourByFive)
|
||||
| Some(CommonAspectRatio::TallTwoByThree) | Some(CommonAspectRatio::Tall) => T::PortraitThreeByFour,
|
||||
Some(CommonAspectRatio::TallNineBySixteen) | Some(CommonAspectRatio::TallNineByTwentyOne) => T::PortraitNineBySixteen,
|
||||
None | Some(RouterAspectRatio::Auto) | Some(RouterAspectRatio::Auto2k)
|
||||
| Some(RouterAspectRatio::Auto3k) | Some(RouterAspectRatio::Auto4k) => T::SquareHd,
|
||||
Some(RouterAspectRatio::Square) => T::Square,
|
||||
Some(RouterAspectRatio::SquareHd) => T::SquareHd,
|
||||
Some(RouterAspectRatio::WideFourByThree) | Some(RouterAspectRatio::WideFiveByFour)
|
||||
| Some(RouterAspectRatio::WideThreeByTwo) | Some(RouterAspectRatio::Wide) => T::LandscapeFourByThree,
|
||||
Some(RouterAspectRatio::WideSixteenByNine) | Some(RouterAspectRatio::WideTwentyOneByNine) => T::LandscapeSixteenByNine,
|
||||
Some(RouterAspectRatio::TallThreeByFour) | Some(RouterAspectRatio::TallFourByFive)
|
||||
| Some(RouterAspectRatio::TallTwoByThree) | Some(RouterAspectRatio::Tall) => T::PortraitThreeByFour,
|
||||
Some(RouterAspectRatio::TallNineBySixteen) | Some(RouterAspectRatio::TallNineByTwentyOne) => T::PortraitNineBySixteen,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,13 +144,13 @@ fn resolve_single_image_url(
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::api::common_image_model::CommonImageModel;
|
||||
use crate::api::provider::Provider;
|
||||
use crate::api::router_image_model::RouterImageModel;
|
||||
use crate::api::router_provider::RouterProvider;
|
||||
|
||||
fn base_builder() -> GenerateImageRequestBuilder {
|
||||
GenerateImageRequestBuilder {
|
||||
model: CommonImageModel::Flux1Dev,
|
||||
provider: Provider::Fal,
|
||||
model: RouterImageModel::Flux1Dev,
|
||||
provider: RouterProvider::Fal,
|
||||
prompt: Some("a cat in space".to_string()),
|
||||
image_inputs: None,
|
||||
resolution: None,
|
||||
@@ -330,7 +330,7 @@ mod tests {
|
||||
#[test]
|
||||
fn auto_yields_square_hd() {
|
||||
let builder = GenerateImageRequestBuilder {
|
||||
aspect_ratio: Some(CommonAspectRatio::Auto),
|
||||
aspect_ratio: Some(RouterAspectRatio::Auto),
|
||||
..base_builder()
|
||||
};
|
||||
let req = unwrap_t2i(build_fal_flux_1_dev(builder));
|
||||
@@ -340,7 +340,7 @@ mod tests {
|
||||
#[test]
|
||||
fn square() {
|
||||
let builder = GenerateImageRequestBuilder {
|
||||
aspect_ratio: Some(CommonAspectRatio::Square),
|
||||
aspect_ratio: Some(RouterAspectRatio::Square),
|
||||
..base_builder()
|
||||
};
|
||||
let req = unwrap_t2i(build_fal_flux_1_dev(builder));
|
||||
@@ -350,7 +350,7 @@ mod tests {
|
||||
#[test]
|
||||
fn square_hd() {
|
||||
let builder = GenerateImageRequestBuilder {
|
||||
aspect_ratio: Some(CommonAspectRatio::SquareHd),
|
||||
aspect_ratio: Some(RouterAspectRatio::SquareHd),
|
||||
..base_builder()
|
||||
};
|
||||
let req = unwrap_t2i(build_fal_flux_1_dev(builder));
|
||||
@@ -360,7 +360,7 @@ mod tests {
|
||||
#[test]
|
||||
fn wide_four_by_three() {
|
||||
let builder = GenerateImageRequestBuilder {
|
||||
aspect_ratio: Some(CommonAspectRatio::WideFourByThree),
|
||||
aspect_ratio: Some(RouterAspectRatio::WideFourByThree),
|
||||
..base_builder()
|
||||
};
|
||||
let req = unwrap_t2i(build_fal_flux_1_dev(builder));
|
||||
@@ -370,7 +370,7 @@ mod tests {
|
||||
#[test]
|
||||
fn wide_sixteen_by_nine() {
|
||||
let builder = GenerateImageRequestBuilder {
|
||||
aspect_ratio: Some(CommonAspectRatio::WideSixteenByNine),
|
||||
aspect_ratio: Some(RouterAspectRatio::WideSixteenByNine),
|
||||
..base_builder()
|
||||
};
|
||||
let req = unwrap_t2i(build_fal_flux_1_dev(builder));
|
||||
@@ -380,7 +380,7 @@ mod tests {
|
||||
#[test]
|
||||
fn wide_twenty_one_by_nine_maps_to_sixteen_by_nine() {
|
||||
let builder = GenerateImageRequestBuilder {
|
||||
aspect_ratio: Some(CommonAspectRatio::WideTwentyOneByNine),
|
||||
aspect_ratio: Some(RouterAspectRatio::WideTwentyOneByNine),
|
||||
..base_builder()
|
||||
};
|
||||
let req = unwrap_t2i(build_fal_flux_1_dev(builder));
|
||||
@@ -390,7 +390,7 @@ mod tests {
|
||||
#[test]
|
||||
fn tall_three_by_four() {
|
||||
let builder = GenerateImageRequestBuilder {
|
||||
aspect_ratio: Some(CommonAspectRatio::TallThreeByFour),
|
||||
aspect_ratio: Some(RouterAspectRatio::TallThreeByFour),
|
||||
..base_builder()
|
||||
};
|
||||
let req = unwrap_t2i(build_fal_flux_1_dev(builder));
|
||||
@@ -400,7 +400,7 @@ mod tests {
|
||||
#[test]
|
||||
fn tall_nine_by_sixteen() {
|
||||
let builder = GenerateImageRequestBuilder {
|
||||
aspect_ratio: Some(CommonAspectRatio::TallNineBySixteen),
|
||||
aspect_ratio: Some(RouterAspectRatio::TallNineBySixteen),
|
||||
..base_builder()
|
||||
};
|
||||
let req = unwrap_t2i(build_fal_flux_1_dev(builder));
|
||||
|
||||
+33
-33
@@ -6,7 +6,7 @@ use fal_client::requests::api::image::text::flux_1_schnell_text_to_image::api::{
|
||||
Flux1SchnellTextToImageRequest,
|
||||
};
|
||||
|
||||
use crate::api::common_aspect_ratio::CommonAspectRatio;
|
||||
use crate::api::router_aspect_ratio::RouterAspectRatio;
|
||||
use crate::api::image_list_ref::ImageListRef;
|
||||
use crate::client::request_mismatch_mitigation_strategy::RequestMismatchMitigationStrategy;
|
||||
use crate::errors::artcraft_router_error::ArtcraftRouterError;
|
||||
@@ -104,38 +104,38 @@ fn to_edit_num_images(n: PlannedNumImages) -> Flux1SchnellEditImageNumImages {
|
||||
// ── Aspect ratio ──
|
||||
|
||||
fn plan_aspect_ratio(
|
||||
aspect_ratio: Option<CommonAspectRatio>,
|
||||
aspect_ratio: Option<RouterAspectRatio>,
|
||||
) -> Flux1SchnellTextToImageAspectRatio {
|
||||
use Flux1SchnellTextToImageAspectRatio as T;
|
||||
match aspect_ratio {
|
||||
None | Some(CommonAspectRatio::Auto) | Some(CommonAspectRatio::Auto2k)
|
||||
| Some(CommonAspectRatio::Auto3k) | Some(CommonAspectRatio::Auto4k) => T::SquareHd,
|
||||
Some(CommonAspectRatio::Square) => T::Square,
|
||||
Some(CommonAspectRatio::SquareHd) => T::SquareHd,
|
||||
Some(CommonAspectRatio::WideFourByThree) | Some(CommonAspectRatio::WideFiveByFour)
|
||||
| Some(CommonAspectRatio::WideThreeByTwo) | Some(CommonAspectRatio::Wide) => T::LandscapeFourByThree,
|
||||
Some(CommonAspectRatio::WideSixteenByNine) | Some(CommonAspectRatio::WideTwentyOneByNine) => T::LandscapeSixteenByNine,
|
||||
Some(CommonAspectRatio::TallThreeByFour) | Some(CommonAspectRatio::TallFourByFive)
|
||||
| Some(CommonAspectRatio::TallTwoByThree) | Some(CommonAspectRatio::Tall) => T::PortraitThreeByFour,
|
||||
Some(CommonAspectRatio::TallNineBySixteen) | Some(CommonAspectRatio::TallNineByTwentyOne) => T::PortraitNineBySixteen,
|
||||
None | Some(RouterAspectRatio::Auto) | Some(RouterAspectRatio::Auto2k)
|
||||
| Some(RouterAspectRatio::Auto3k) | Some(RouterAspectRatio::Auto4k) => T::SquareHd,
|
||||
Some(RouterAspectRatio::Square) => T::Square,
|
||||
Some(RouterAspectRatio::SquareHd) => T::SquareHd,
|
||||
Some(RouterAspectRatio::WideFourByThree) | Some(RouterAspectRatio::WideFiveByFour)
|
||||
| Some(RouterAspectRatio::WideThreeByTwo) | Some(RouterAspectRatio::Wide) => T::LandscapeFourByThree,
|
||||
Some(RouterAspectRatio::WideSixteenByNine) | Some(RouterAspectRatio::WideTwentyOneByNine) => T::LandscapeSixteenByNine,
|
||||
Some(RouterAspectRatio::TallThreeByFour) | Some(RouterAspectRatio::TallFourByFive)
|
||||
| Some(RouterAspectRatio::TallTwoByThree) | Some(RouterAspectRatio::Tall) => T::PortraitThreeByFour,
|
||||
Some(RouterAspectRatio::TallNineBySixteen) | Some(RouterAspectRatio::TallNineByTwentyOne) => T::PortraitNineBySixteen,
|
||||
}
|
||||
}
|
||||
|
||||
fn plan_edit_image_size(
|
||||
aspect_ratio: Option<CommonAspectRatio>,
|
||||
aspect_ratio: Option<RouterAspectRatio>,
|
||||
) -> Option<Flux1SchnellEditImageSize> {
|
||||
use Flux1SchnellEditImageSize as S;
|
||||
aspect_ratio.and_then(|ar| match ar {
|
||||
CommonAspectRatio::Auto | CommonAspectRatio::Auto2k
|
||||
| CommonAspectRatio::Auto3k | CommonAspectRatio::Auto4k => None,
|
||||
CommonAspectRatio::Square => Some(S::Square),
|
||||
CommonAspectRatio::SquareHd => Some(S::SquareHd),
|
||||
CommonAspectRatio::WideFourByThree | CommonAspectRatio::WideFiveByFour
|
||||
| CommonAspectRatio::WideThreeByTwo | CommonAspectRatio::Wide => Some(S::LandscapeFourByThree),
|
||||
CommonAspectRatio::WideSixteenByNine | CommonAspectRatio::WideTwentyOneByNine => Some(S::LandscapeSixteenByNine),
|
||||
CommonAspectRatio::TallThreeByFour | CommonAspectRatio::TallFourByFive
|
||||
| CommonAspectRatio::TallTwoByThree | CommonAspectRatio::Tall => Some(S::PortraitThreeByFour),
|
||||
CommonAspectRatio::TallNineBySixteen | CommonAspectRatio::TallNineByTwentyOne => Some(S::PortraitNineBySixteen),
|
||||
RouterAspectRatio::Auto | RouterAspectRatio::Auto2k
|
||||
| RouterAspectRatio::Auto3k | RouterAspectRatio::Auto4k => None,
|
||||
RouterAspectRatio::Square => Some(S::Square),
|
||||
RouterAspectRatio::SquareHd => Some(S::SquareHd),
|
||||
RouterAspectRatio::WideFourByThree | RouterAspectRatio::WideFiveByFour
|
||||
| RouterAspectRatio::WideThreeByTwo | RouterAspectRatio::Wide => Some(S::LandscapeFourByThree),
|
||||
RouterAspectRatio::WideSixteenByNine | RouterAspectRatio::WideTwentyOneByNine => Some(S::LandscapeSixteenByNine),
|
||||
RouterAspectRatio::TallThreeByFour | RouterAspectRatio::TallFourByFive
|
||||
| RouterAspectRatio::TallTwoByThree | RouterAspectRatio::Tall => Some(S::PortraitThreeByFour),
|
||||
RouterAspectRatio::TallNineBySixteen | RouterAspectRatio::TallNineByTwentyOne => Some(S::PortraitNineBySixteen),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -165,13 +165,13 @@ fn resolve_single_image_url(
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::api::common_image_model::CommonImageModel;
|
||||
use crate::api::provider::Provider;
|
||||
use crate::api::router_image_model::RouterImageModel;
|
||||
use crate::api::router_provider::RouterProvider;
|
||||
|
||||
fn base_builder() -> GenerateImageRequestBuilder {
|
||||
GenerateImageRequestBuilder {
|
||||
model: CommonImageModel::Flux1Schnell,
|
||||
provider: Provider::Fal,
|
||||
model: RouterImageModel::Flux1Schnell,
|
||||
provider: RouterProvider::Fal,
|
||||
prompt: Some("a cat in space".to_string()),
|
||||
image_inputs: None,
|
||||
resolution: None,
|
||||
@@ -351,7 +351,7 @@ mod tests {
|
||||
#[test]
|
||||
fn square() {
|
||||
let builder = GenerateImageRequestBuilder {
|
||||
aspect_ratio: Some(CommonAspectRatio::Square),
|
||||
aspect_ratio: Some(RouterAspectRatio::Square),
|
||||
..base_builder()
|
||||
};
|
||||
let req = unwrap_t2i(build_fal_flux_1_schnell(builder));
|
||||
@@ -361,7 +361,7 @@ mod tests {
|
||||
#[test]
|
||||
fn wide_sixteen_by_nine() {
|
||||
let builder = GenerateImageRequestBuilder {
|
||||
aspect_ratio: Some(CommonAspectRatio::WideSixteenByNine),
|
||||
aspect_ratio: Some(RouterAspectRatio::WideSixteenByNine),
|
||||
..base_builder()
|
||||
};
|
||||
let req = unwrap_t2i(build_fal_flux_1_schnell(builder));
|
||||
@@ -371,7 +371,7 @@ mod tests {
|
||||
#[test]
|
||||
fn tall_nine_by_sixteen() {
|
||||
let builder = GenerateImageRequestBuilder {
|
||||
aspect_ratio: Some(CommonAspectRatio::TallNineBySixteen),
|
||||
aspect_ratio: Some(RouterAspectRatio::TallNineBySixteen),
|
||||
..base_builder()
|
||||
};
|
||||
let req = unwrap_t2i(build_fal_flux_1_schnell(builder));
|
||||
@@ -381,7 +381,7 @@ mod tests {
|
||||
#[test]
|
||||
fn edit_auto_yields_none() {
|
||||
let builder = GenerateImageRequestBuilder {
|
||||
aspect_ratio: Some(CommonAspectRatio::Auto),
|
||||
aspect_ratio: Some(RouterAspectRatio::Auto),
|
||||
image_inputs: Some(ImageListRef::Urls(vec!["https://example.com/img.jpg".to_string()])),
|
||||
..base_builder()
|
||||
};
|
||||
@@ -392,7 +392,7 @@ mod tests {
|
||||
#[test]
|
||||
fn edit_square() {
|
||||
let builder = GenerateImageRequestBuilder {
|
||||
aspect_ratio: Some(CommonAspectRatio::Square),
|
||||
aspect_ratio: Some(RouterAspectRatio::Square),
|
||||
image_inputs: Some(ImageListRef::Urls(vec!["https://example.com/img.jpg".to_string()])),
|
||||
..base_builder()
|
||||
};
|
||||
@@ -403,7 +403,7 @@ mod tests {
|
||||
#[test]
|
||||
fn edit_landscape() {
|
||||
let builder = GenerateImageRequestBuilder {
|
||||
aspect_ratio: Some(CommonAspectRatio::WideSixteenByNine),
|
||||
aspect_ratio: Some(RouterAspectRatio::WideSixteenByNine),
|
||||
image_inputs: Some(ImageListRef::Urls(vec!["https://example.com/img.jpg".to_string()])),
|
||||
..base_builder()
|
||||
};
|
||||
|
||||
+16
-16
@@ -3,7 +3,7 @@ use fal_client::requests::webhook::image::angle::enqueue_flux_2_lora_edit_image_
|
||||
EnqueueFlux2LoraEditImageAngleRequest,
|
||||
};
|
||||
|
||||
use crate::api::common_aspect_ratio::CommonAspectRatio;
|
||||
use crate::api::router_aspect_ratio::RouterAspectRatio;
|
||||
use crate::api::image_list_ref::ImageListRef;
|
||||
use crate::client::request_mismatch_mitigation_strategy::RequestMismatchMitigationStrategy;
|
||||
use crate::errors::artcraft_router_error::ArtcraftRouterError;
|
||||
@@ -79,26 +79,26 @@ fn plan_num_images(
|
||||
}
|
||||
|
||||
fn plan_image_size(
|
||||
aspect_ratio: Option<CommonAspectRatio>,
|
||||
aspect_ratio: Option<RouterAspectRatio>,
|
||||
strategy: RequestMismatchMitigationStrategy,
|
||||
) -> Result<Option<EnqueueFlux2LoraAngleImageSize>, ArtcraftRouterError> {
|
||||
use EnqueueFlux2LoraAngleImageSize as S;
|
||||
match aspect_ratio {
|
||||
None => Ok(None),
|
||||
|
||||
Some(CommonAspectRatio::Auto)
|
||||
| Some(CommonAspectRatio::Auto2k)
|
||||
| Some(CommonAspectRatio::Auto3k)
|
||||
| Some(CommonAspectRatio::Auto4k) => Ok(Some(S::SquareHd)),
|
||||
Some(RouterAspectRatio::Auto)
|
||||
| Some(RouterAspectRatio::Auto2k)
|
||||
| Some(RouterAspectRatio::Auto3k)
|
||||
| Some(RouterAspectRatio::Auto4k) => Ok(Some(S::SquareHd)),
|
||||
|
||||
Some(CommonAspectRatio::Square) => Ok(Some(S::Square)),
|
||||
Some(CommonAspectRatio::SquareHd) => Ok(Some(S::SquareHd)),
|
||||
Some(RouterAspectRatio::Square) => Ok(Some(S::Square)),
|
||||
Some(RouterAspectRatio::SquareHd) => Ok(Some(S::SquareHd)),
|
||||
|
||||
Some(CommonAspectRatio::Wide) | Some(CommonAspectRatio::WideSixteenByNine) => Ok(Some(S::LandscapeSixteenNine)),
|
||||
Some(CommonAspectRatio::WideFourByThree) => Ok(Some(S::LandscapeFourThree)),
|
||||
Some(RouterAspectRatio::Wide) | Some(RouterAspectRatio::WideSixteenByNine) => Ok(Some(S::LandscapeSixteenNine)),
|
||||
Some(RouterAspectRatio::WideFourByThree) => Ok(Some(S::LandscapeFourThree)),
|
||||
|
||||
Some(CommonAspectRatio::Tall) | Some(CommonAspectRatio::TallNineBySixteen) => Ok(Some(S::PortraitSixteenNine)),
|
||||
Some(CommonAspectRatio::TallThreeByFour) => Ok(Some(S::PortraitFourThree)),
|
||||
Some(RouterAspectRatio::Tall) | Some(RouterAspectRatio::TallNineBySixteen) => Ok(Some(S::PortraitSixteenNine)),
|
||||
Some(RouterAspectRatio::TallThreeByFour) => Ok(Some(S::PortraitFourThree)),
|
||||
|
||||
Some(unsupported) => match strategy {
|
||||
RequestMismatchMitigationStrategy::ErrorOut => {
|
||||
@@ -115,13 +115,13 @@ fn plan_image_size(
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::api::common_image_model::CommonImageModel;
|
||||
use crate::api::provider::Provider;
|
||||
use crate::api::router_image_model::RouterImageModel;
|
||||
use crate::api::router_provider::RouterProvider;
|
||||
|
||||
fn base() -> GenerateImageRequestBuilder {
|
||||
GenerateImageRequestBuilder {
|
||||
model: CommonImageModel::Flux2LoraAngles,
|
||||
provider: Provider::Fal,
|
||||
model: RouterImageModel::Flux2LoraAngles,
|
||||
provider: RouterProvider::Fal,
|
||||
prompt: None,
|
||||
image_inputs: Some(ImageListRef::Urls(vec!["https://example.com/x.jpg".to_string()])),
|
||||
resolution: None,
|
||||
|
||||
+27
-27
@@ -2,7 +2,7 @@ use fal_client::requests::webhook::image::text::enqueue_flux_pro_11_text_to_imag
|
||||
FluxPro11AspectRatio, FluxPro11NumImages, FluxPro11Request,
|
||||
};
|
||||
|
||||
use crate::api::common_aspect_ratio::CommonAspectRatio;
|
||||
use crate::api::router_aspect_ratio::RouterAspectRatio;
|
||||
use crate::client::request_mismatch_mitigation_strategy::RequestMismatchMitigationStrategy;
|
||||
use crate::errors::artcraft_router_error::ArtcraftRouterError;
|
||||
use crate::errors::client_error::ClientError;
|
||||
@@ -40,30 +40,30 @@ pub fn build_fal_flux_pro_1p1(
|
||||
}
|
||||
|
||||
fn plan_aspect_ratio(
|
||||
aspect_ratio: Option<CommonAspectRatio>,
|
||||
aspect_ratio: Option<RouterAspectRatio>,
|
||||
strategy: RequestMismatchMitigationStrategy,
|
||||
) -> Result<FluxPro11AspectRatio, ArtcraftRouterError> {
|
||||
use FluxPro11AspectRatio as Ar;
|
||||
match aspect_ratio {
|
||||
None => Ok(Ar::Square),
|
||||
|
||||
Some(CommonAspectRatio::Auto)
|
||||
| Some(CommonAspectRatio::Auto2k)
|
||||
| Some(CommonAspectRatio::Auto4k) => Ok(Ar::Square),
|
||||
Some(RouterAspectRatio::Auto)
|
||||
| Some(RouterAspectRatio::Auto2k)
|
||||
| Some(RouterAspectRatio::Auto4k) => Ok(Ar::Square),
|
||||
|
||||
Some(CommonAspectRatio::Square) => Ok(Ar::Square),
|
||||
Some(CommonAspectRatio::SquareHd) => Ok(Ar::SquareHd),
|
||||
Some(CommonAspectRatio::WideFourByThree) => Ok(Ar::LandscapeFourByThree),
|
||||
Some(CommonAspectRatio::WideSixteenByNine) | Some(CommonAspectRatio::Wide) => Ok(Ar::LandscapeSixteenByNine),
|
||||
Some(CommonAspectRatio::TallThreeByFour) => Ok(Ar::PortraitThreeByFour),
|
||||
Some(CommonAspectRatio::TallNineBySixteen) | Some(CommonAspectRatio::Tall) => Ok(Ar::PortraitNineBySixteen),
|
||||
Some(RouterAspectRatio::Square) => Ok(Ar::Square),
|
||||
Some(RouterAspectRatio::SquareHd) => Ok(Ar::SquareHd),
|
||||
Some(RouterAspectRatio::WideFourByThree) => Ok(Ar::LandscapeFourByThree),
|
||||
Some(RouterAspectRatio::WideSixteenByNine) | Some(RouterAspectRatio::Wide) => Ok(Ar::LandscapeSixteenByNine),
|
||||
Some(RouterAspectRatio::TallThreeByFour) => Ok(Ar::PortraitThreeByFour),
|
||||
Some(RouterAspectRatio::TallNineBySixteen) | Some(RouterAspectRatio::Tall) => Ok(Ar::PortraitNineBySixteen),
|
||||
|
||||
Some(CommonAspectRatio::WideFiveByFour) => Ok(Ar::LandscapeFourByThree),
|
||||
Some(CommonAspectRatio::WideThreeByTwo) => Ok(Ar::LandscapeFourByThree),
|
||||
Some(CommonAspectRatio::WideTwentyOneByNine) => Ok(Ar::LandscapeSixteenByNine),
|
||||
Some(CommonAspectRatio::TallFourByFive) => Ok(Ar::PortraitThreeByFour),
|
||||
Some(CommonAspectRatio::TallTwoByThree) => Ok(Ar::PortraitThreeByFour),
|
||||
Some(CommonAspectRatio::TallNineByTwentyOne) => Ok(Ar::PortraitNineBySixteen),
|
||||
Some(RouterAspectRatio::WideFiveByFour) => Ok(Ar::LandscapeFourByThree),
|
||||
Some(RouterAspectRatio::WideThreeByTwo) => Ok(Ar::LandscapeFourByThree),
|
||||
Some(RouterAspectRatio::WideTwentyOneByNine) => Ok(Ar::LandscapeSixteenByNine),
|
||||
Some(RouterAspectRatio::TallFourByFive) => Ok(Ar::PortraitThreeByFour),
|
||||
Some(RouterAspectRatio::TallTwoByThree) => Ok(Ar::PortraitThreeByFour),
|
||||
Some(RouterAspectRatio::TallNineByTwentyOne) => Ok(Ar::PortraitNineBySixteen),
|
||||
|
||||
Some(unsupported) => match strategy {
|
||||
RequestMismatchMitigationStrategy::ErrorOut => {
|
||||
@@ -103,14 +103,14 @@ fn plan_num_images(
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::api::common_image_model::CommonImageModel;
|
||||
use crate::api::router_image_model::RouterImageModel;
|
||||
use crate::api::image_list_ref::ImageListRef;
|
||||
use crate::api::provider::Provider;
|
||||
use crate::api::router_provider::RouterProvider;
|
||||
|
||||
fn base_builder() -> GenerateImageRequestBuilder {
|
||||
GenerateImageRequestBuilder {
|
||||
model: CommonImageModel::FluxPro11,
|
||||
provider: Provider::Fal,
|
||||
model: RouterImageModel::FluxPro11,
|
||||
provider: RouterProvider::Fal,
|
||||
prompt: Some("a cat in space".to_string()),
|
||||
image_inputs: None,
|
||||
resolution: None,
|
||||
@@ -186,7 +186,7 @@ mod tests {
|
||||
#[test]
|
||||
fn auto_maps_to_square() {
|
||||
let builder = GenerateImageRequestBuilder {
|
||||
aspect_ratio: Some(CommonAspectRatio::Auto),
|
||||
aspect_ratio: Some(RouterAspectRatio::Auto),
|
||||
..base_builder()
|
||||
};
|
||||
let req = unwrap_request(build_fal_flux_pro_1p1(builder));
|
||||
@@ -196,7 +196,7 @@ mod tests {
|
||||
#[test]
|
||||
fn square_hd() {
|
||||
let builder = GenerateImageRequestBuilder {
|
||||
aspect_ratio: Some(CommonAspectRatio::SquareHd),
|
||||
aspect_ratio: Some(RouterAspectRatio::SquareHd),
|
||||
..base_builder()
|
||||
};
|
||||
let req = unwrap_request(build_fal_flux_pro_1p1(builder));
|
||||
@@ -206,7 +206,7 @@ mod tests {
|
||||
#[test]
|
||||
fn wide_sixteen_by_nine() {
|
||||
let builder = GenerateImageRequestBuilder {
|
||||
aspect_ratio: Some(CommonAspectRatio::WideSixteenByNine),
|
||||
aspect_ratio: Some(RouterAspectRatio::WideSixteenByNine),
|
||||
..base_builder()
|
||||
};
|
||||
let req = unwrap_request(build_fal_flux_pro_1p1(builder));
|
||||
@@ -216,7 +216,7 @@ mod tests {
|
||||
#[test]
|
||||
fn tall_nine_by_sixteen() {
|
||||
let builder = GenerateImageRequestBuilder {
|
||||
aspect_ratio: Some(CommonAspectRatio::TallNineBySixteen),
|
||||
aspect_ratio: Some(RouterAspectRatio::TallNineBySixteen),
|
||||
..base_builder()
|
||||
};
|
||||
let req = unwrap_request(build_fal_flux_pro_1p1(builder));
|
||||
@@ -226,7 +226,7 @@ mod tests {
|
||||
#[test]
|
||||
fn wide_twenty_one_by_nine_collapses_to_sixteen_by_nine() {
|
||||
let builder = GenerateImageRequestBuilder {
|
||||
aspect_ratio: Some(CommonAspectRatio::WideTwentyOneByNine),
|
||||
aspect_ratio: Some(RouterAspectRatio::WideTwentyOneByNine),
|
||||
..base_builder()
|
||||
};
|
||||
let req = unwrap_request(build_fal_flux_pro_1p1(builder));
|
||||
@@ -236,7 +236,7 @@ mod tests {
|
||||
#[test]
|
||||
fn tall_four_by_five_collapses_to_three_by_four() {
|
||||
let builder = GenerateImageRequestBuilder {
|
||||
aspect_ratio: Some(CommonAspectRatio::TallFourByFive),
|
||||
aspect_ratio: Some(RouterAspectRatio::TallFourByFive),
|
||||
..base_builder()
|
||||
};
|
||||
let req = unwrap_request(build_fal_flux_pro_1p1(builder));
|
||||
|
||||
+25
-25
@@ -2,7 +2,7 @@ use fal_client::requests::webhook::image::text::enqueue_flux_pro_11_ultra_text_t
|
||||
FluxPro11UltraAspectRatio, FluxPro11UltraNumImages, FluxPro11UltraRequest,
|
||||
};
|
||||
|
||||
use crate::api::common_aspect_ratio::CommonAspectRatio;
|
||||
use crate::api::router_aspect_ratio::RouterAspectRatio;
|
||||
use crate::client::request_mismatch_mitigation_strategy::RequestMismatchMitigationStrategy;
|
||||
use crate::errors::artcraft_router_error::ArtcraftRouterError;
|
||||
use crate::errors::client_error::ClientError;
|
||||
@@ -41,29 +41,29 @@ pub fn build_fal_flux_pro_1p1_ultra(
|
||||
}
|
||||
|
||||
fn plan_aspect_ratio(
|
||||
aspect_ratio: Option<CommonAspectRatio>,
|
||||
aspect_ratio: Option<RouterAspectRatio>,
|
||||
strategy: RequestMismatchMitigationStrategy,
|
||||
) -> Result<FluxPro11UltraAspectRatio, ArtcraftRouterError> {
|
||||
use FluxPro11UltraAspectRatio as Ar;
|
||||
match aspect_ratio {
|
||||
None => Ok(Ar::Square),
|
||||
|
||||
Some(CommonAspectRatio::Auto)
|
||||
| Some(CommonAspectRatio::Auto2k)
|
||||
| Some(CommonAspectRatio::Auto4k) => Ok(Ar::Square),
|
||||
Some(RouterAspectRatio::Auto)
|
||||
| Some(RouterAspectRatio::Auto2k)
|
||||
| Some(RouterAspectRatio::Auto4k) => Ok(Ar::Square),
|
||||
|
||||
Some(CommonAspectRatio::Square) | Some(CommonAspectRatio::SquareHd) => Ok(Ar::Square),
|
||||
Some(CommonAspectRatio::WideFourByThree) => Ok(Ar::LandscapeFourByThree),
|
||||
Some(CommonAspectRatio::WideThreeByTwo) => Ok(Ar::LandscapeThreeByTwo),
|
||||
Some(CommonAspectRatio::WideSixteenByNine) | Some(CommonAspectRatio::Wide) => Ok(Ar::LandscapeSixteenByNine),
|
||||
Some(CommonAspectRatio::WideTwentyOneByNine) => Ok(Ar::LandscapeTwentyOneByNine),
|
||||
Some(CommonAspectRatio::TallThreeByFour) => Ok(Ar::PortraitThreeByFour),
|
||||
Some(CommonAspectRatio::TallTwoByThree) => Ok(Ar::PortraitTwoByThree),
|
||||
Some(CommonAspectRatio::TallNineBySixteen) | Some(CommonAspectRatio::Tall) => Ok(Ar::PortraitNineBySixteen),
|
||||
Some(CommonAspectRatio::TallNineByTwentyOne) => Ok(Ar::PortraitNineByTwentyOne),
|
||||
Some(RouterAspectRatio::Square) | Some(RouterAspectRatio::SquareHd) => Ok(Ar::Square),
|
||||
Some(RouterAspectRatio::WideFourByThree) => Ok(Ar::LandscapeFourByThree),
|
||||
Some(RouterAspectRatio::WideThreeByTwo) => Ok(Ar::LandscapeThreeByTwo),
|
||||
Some(RouterAspectRatio::WideSixteenByNine) | Some(RouterAspectRatio::Wide) => Ok(Ar::LandscapeSixteenByNine),
|
||||
Some(RouterAspectRatio::WideTwentyOneByNine) => Ok(Ar::LandscapeTwentyOneByNine),
|
||||
Some(RouterAspectRatio::TallThreeByFour) => Ok(Ar::PortraitThreeByFour),
|
||||
Some(RouterAspectRatio::TallTwoByThree) => Ok(Ar::PortraitTwoByThree),
|
||||
Some(RouterAspectRatio::TallNineBySixteen) | Some(RouterAspectRatio::Tall) => Ok(Ar::PortraitNineBySixteen),
|
||||
Some(RouterAspectRatio::TallNineByTwentyOne) => Ok(Ar::PortraitNineByTwentyOne),
|
||||
|
||||
Some(CommonAspectRatio::WideFiveByFour) => Ok(Ar::LandscapeFourByThree),
|
||||
Some(CommonAspectRatio::TallFourByFive) => Ok(Ar::PortraitThreeByFour),
|
||||
Some(RouterAspectRatio::WideFiveByFour) => Ok(Ar::LandscapeFourByThree),
|
||||
Some(RouterAspectRatio::TallFourByFive) => Ok(Ar::PortraitThreeByFour),
|
||||
|
||||
Some(unsupported) => match strategy {
|
||||
RequestMismatchMitigationStrategy::ErrorOut => {
|
||||
@@ -103,14 +103,14 @@ fn plan_num_images(
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::api::common_image_model::CommonImageModel;
|
||||
use crate::api::router_image_model::RouterImageModel;
|
||||
use crate::api::image_list_ref::ImageListRef;
|
||||
use crate::api::provider::Provider;
|
||||
use crate::api::router_provider::RouterProvider;
|
||||
|
||||
fn base_builder() -> GenerateImageRequestBuilder {
|
||||
GenerateImageRequestBuilder {
|
||||
model: CommonImageModel::FluxPro11Ultra,
|
||||
provider: Provider::Fal,
|
||||
model: RouterImageModel::FluxPro11Ultra,
|
||||
provider: RouterProvider::Fal,
|
||||
prompt: Some("a cat in space".to_string()),
|
||||
image_inputs: None,
|
||||
resolution: None,
|
||||
@@ -186,7 +186,7 @@ mod tests {
|
||||
#[test]
|
||||
fn wide_sixteen_by_nine() {
|
||||
let builder = GenerateImageRequestBuilder {
|
||||
aspect_ratio: Some(CommonAspectRatio::WideSixteenByNine),
|
||||
aspect_ratio: Some(RouterAspectRatio::WideSixteenByNine),
|
||||
..base_builder()
|
||||
};
|
||||
let req = unwrap_request(build_fal_flux_pro_1p1_ultra(builder));
|
||||
@@ -196,7 +196,7 @@ mod tests {
|
||||
#[test]
|
||||
fn wide_three_by_two_has_direct_mapping() {
|
||||
let builder = GenerateImageRequestBuilder {
|
||||
aspect_ratio: Some(CommonAspectRatio::WideThreeByTwo),
|
||||
aspect_ratio: Some(RouterAspectRatio::WideThreeByTwo),
|
||||
..base_builder()
|
||||
};
|
||||
let req = unwrap_request(build_fal_flux_pro_1p1_ultra(builder));
|
||||
@@ -206,7 +206,7 @@ mod tests {
|
||||
#[test]
|
||||
fn tall_two_by_three_has_direct_mapping() {
|
||||
let builder = GenerateImageRequestBuilder {
|
||||
aspect_ratio: Some(CommonAspectRatio::TallTwoByThree),
|
||||
aspect_ratio: Some(RouterAspectRatio::TallTwoByThree),
|
||||
..base_builder()
|
||||
};
|
||||
let req = unwrap_request(build_fal_flux_pro_1p1_ultra(builder));
|
||||
@@ -216,7 +216,7 @@ mod tests {
|
||||
#[test]
|
||||
fn wide_twenty_one_by_nine_has_direct_mapping() {
|
||||
let builder = GenerateImageRequestBuilder {
|
||||
aspect_ratio: Some(CommonAspectRatio::WideTwentyOneByNine),
|
||||
aspect_ratio: Some(RouterAspectRatio::WideTwentyOneByNine),
|
||||
..base_builder()
|
||||
};
|
||||
let req = unwrap_request(build_fal_flux_pro_1p1_ultra(builder));
|
||||
@@ -226,7 +226,7 @@ mod tests {
|
||||
#[test]
|
||||
fn square_hd_collapses_to_square() {
|
||||
let builder = GenerateImageRequestBuilder {
|
||||
aspect_ratio: Some(CommonAspectRatio::SquareHd),
|
||||
aspect_ratio: Some(RouterAspectRatio::SquareHd),
|
||||
..base_builder()
|
||||
};
|
||||
let req = unwrap_request(build_fal_flux_pro_1p1_ultra(builder));
|
||||
|
||||
+49
-49
@@ -7,8 +7,8 @@ use fal_client::requests::api::image::text::gpt_image_1_text_to_image::api::{
|
||||
GptImage1TextToImageRequest, GptImage1TextToImageSize,
|
||||
};
|
||||
|
||||
use crate::api::common_aspect_ratio::CommonAspectRatio;
|
||||
use crate::api::common_quality::CommonQuality;
|
||||
use crate::api::router_aspect_ratio::RouterAspectRatio;
|
||||
use crate::api::router_quality::RouterQuality;
|
||||
use crate::api::image_list_ref::ImageListRef;
|
||||
use crate::client::request_mismatch_mitigation_strategy::RequestMismatchMitigationStrategy;
|
||||
use crate::errors::artcraft_router_error::ArtcraftRouterError;
|
||||
@@ -100,36 +100,36 @@ fn plan_num_images(
|
||||
}
|
||||
}
|
||||
|
||||
fn plan_quality(quality: Option<CommonQuality>) -> PlannedQuality {
|
||||
fn plan_quality(quality: Option<RouterQuality>) -> PlannedQuality {
|
||||
match quality {
|
||||
Some(CommonQuality::Low) => PlannedQuality::Low,
|
||||
Some(CommonQuality::Medium) => PlannedQuality::Medium,
|
||||
Some(CommonQuality::High) | None => PlannedQuality::High,
|
||||
Some(RouterQuality::Low) => PlannedQuality::Low,
|
||||
Some(RouterQuality::Medium) => PlannedQuality::Medium,
|
||||
Some(RouterQuality::High) | None => PlannedQuality::High,
|
||||
}
|
||||
}
|
||||
|
||||
fn plan_image_size(aspect_ratio: Option<CommonAspectRatio>) -> Option<PlannedImageSize> {
|
||||
fn plan_image_size(aspect_ratio: Option<RouterAspectRatio>) -> Option<PlannedImageSize> {
|
||||
match aspect_ratio {
|
||||
None
|
||||
| Some(CommonAspectRatio::Auto)
|
||||
| Some(CommonAspectRatio::Auto2k)
|
||||
| Some(CommonAspectRatio::Auto3k)
|
||||
| Some(CommonAspectRatio::Auto4k) => None,
|
||||
Some(CommonAspectRatio::Square) | Some(CommonAspectRatio::SquareHd) => {
|
||||
| Some(RouterAspectRatio::Auto)
|
||||
| Some(RouterAspectRatio::Auto2k)
|
||||
| Some(RouterAspectRatio::Auto3k)
|
||||
| Some(RouterAspectRatio::Auto4k) => None,
|
||||
Some(RouterAspectRatio::Square) | Some(RouterAspectRatio::SquareHd) => {
|
||||
Some(PlannedImageSize::Square)
|
||||
}
|
||||
Some(CommonAspectRatio::WideThreeByTwo)
|
||||
| Some(CommonAspectRatio::WideFourByThree)
|
||||
| Some(CommonAspectRatio::WideFiveByFour)
|
||||
| Some(CommonAspectRatio::WideSixteenByNine)
|
||||
| Some(CommonAspectRatio::WideTwentyOneByNine)
|
||||
| Some(CommonAspectRatio::Wide) => Some(PlannedImageSize::Horizontal),
|
||||
Some(CommonAspectRatio::TallTwoByThree)
|
||||
| Some(CommonAspectRatio::TallThreeByFour)
|
||||
| Some(CommonAspectRatio::TallFourByFive)
|
||||
| Some(CommonAspectRatio::TallNineBySixteen)
|
||||
| Some(CommonAspectRatio::TallNineByTwentyOne)
|
||||
| Some(CommonAspectRatio::Tall) => Some(PlannedImageSize::Vertical),
|
||||
Some(RouterAspectRatio::WideThreeByTwo)
|
||||
| Some(RouterAspectRatio::WideFourByThree)
|
||||
| Some(RouterAspectRatio::WideFiveByFour)
|
||||
| Some(RouterAspectRatio::WideSixteenByNine)
|
||||
| Some(RouterAspectRatio::WideTwentyOneByNine)
|
||||
| Some(RouterAspectRatio::Wide) => Some(PlannedImageSize::Horizontal),
|
||||
Some(RouterAspectRatio::TallTwoByThree)
|
||||
| Some(RouterAspectRatio::TallThreeByFour)
|
||||
| Some(RouterAspectRatio::TallFourByFive)
|
||||
| Some(RouterAspectRatio::TallNineBySixteen)
|
||||
| Some(RouterAspectRatio::TallNineByTwentyOne)
|
||||
| Some(RouterAspectRatio::Tall) => Some(PlannedImageSize::Vertical),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -200,13 +200,13 @@ mod tests {
|
||||
use super::*;
|
||||
use std::fmt::Debug;
|
||||
|
||||
use crate::api::common_image_model::CommonImageModel;
|
||||
use crate::api::provider::Provider;
|
||||
use crate::api::router_image_model::RouterImageModel;
|
||||
use crate::api::router_provider::RouterProvider;
|
||||
|
||||
fn base_builder() -> GenerateImageRequestBuilder {
|
||||
GenerateImageRequestBuilder {
|
||||
model: CommonImageModel::GptImage1,
|
||||
provider: Provider::Fal,
|
||||
model: RouterImageModel::GptImage1,
|
||||
provider: RouterProvider::Fal,
|
||||
prompt: Some("a cat in space".to_string()),
|
||||
image_inputs: None,
|
||||
resolution: None,
|
||||
@@ -334,9 +334,9 @@ mod tests {
|
||||
fn quality_maps_exhaustively_for_text_and_edit() {
|
||||
let cases = [
|
||||
(None, "Some(High)"),
|
||||
(Some(CommonQuality::Low), "Some(Low)"),
|
||||
(Some(CommonQuality::Medium), "Some(Medium)"),
|
||||
(Some(CommonQuality::High), "Some(High)"),
|
||||
(Some(RouterQuality::Low), "Some(Low)"),
|
||||
(Some(RouterQuality::Medium), "Some(Medium)"),
|
||||
(Some(RouterQuality::High), "Some(High)"),
|
||||
];
|
||||
|
||||
for (quality, expected) in cases {
|
||||
@@ -361,24 +361,24 @@ mod tests {
|
||||
fn aspect_ratio_maps_exhaustively_for_text_and_edit() {
|
||||
let cases = [
|
||||
(None, "None"),
|
||||
(Some(CommonAspectRatio::Auto), "None"),
|
||||
(Some(CommonAspectRatio::Auto2k), "None"),
|
||||
(Some(CommonAspectRatio::Auto3k), "None"),
|
||||
(Some(CommonAspectRatio::Auto4k), "None"),
|
||||
(Some(CommonAspectRatio::Square), "Some(Square)"),
|
||||
(Some(CommonAspectRatio::SquareHd), "Some(Square)"),
|
||||
(Some(CommonAspectRatio::WideThreeByTwo), "Some(Horizontal)"),
|
||||
(Some(CommonAspectRatio::WideFourByThree), "Some(Horizontal)"),
|
||||
(Some(CommonAspectRatio::WideFiveByFour), "Some(Horizontal)"),
|
||||
(Some(CommonAspectRatio::WideSixteenByNine), "Some(Horizontal)"),
|
||||
(Some(CommonAspectRatio::WideTwentyOneByNine), "Some(Horizontal)"),
|
||||
(Some(CommonAspectRatio::Wide), "Some(Horizontal)"),
|
||||
(Some(CommonAspectRatio::TallTwoByThree), "Some(Vertical)"),
|
||||
(Some(CommonAspectRatio::TallThreeByFour), "Some(Vertical)"),
|
||||
(Some(CommonAspectRatio::TallFourByFive), "Some(Vertical)"),
|
||||
(Some(CommonAspectRatio::TallNineBySixteen), "Some(Vertical)"),
|
||||
(Some(CommonAspectRatio::TallNineByTwentyOne), "Some(Vertical)"),
|
||||
(Some(CommonAspectRatio::Tall), "Some(Vertical)"),
|
||||
(Some(RouterAspectRatio::Auto), "None"),
|
||||
(Some(RouterAspectRatio::Auto2k), "None"),
|
||||
(Some(RouterAspectRatio::Auto3k), "None"),
|
||||
(Some(RouterAspectRatio::Auto4k), "None"),
|
||||
(Some(RouterAspectRatio::Square), "Some(Square)"),
|
||||
(Some(RouterAspectRatio::SquareHd), "Some(Square)"),
|
||||
(Some(RouterAspectRatio::WideThreeByTwo), "Some(Horizontal)"),
|
||||
(Some(RouterAspectRatio::WideFourByThree), "Some(Horizontal)"),
|
||||
(Some(RouterAspectRatio::WideFiveByFour), "Some(Horizontal)"),
|
||||
(Some(RouterAspectRatio::WideSixteenByNine), "Some(Horizontal)"),
|
||||
(Some(RouterAspectRatio::WideTwentyOneByNine), "Some(Horizontal)"),
|
||||
(Some(RouterAspectRatio::Wide), "Some(Horizontal)"),
|
||||
(Some(RouterAspectRatio::TallTwoByThree), "Some(Vertical)"),
|
||||
(Some(RouterAspectRatio::TallThreeByFour), "Some(Vertical)"),
|
||||
(Some(RouterAspectRatio::TallFourByFive), "Some(Vertical)"),
|
||||
(Some(RouterAspectRatio::TallNineBySixteen), "Some(Vertical)"),
|
||||
(Some(RouterAspectRatio::TallNineByTwentyOne), "Some(Vertical)"),
|
||||
(Some(RouterAspectRatio::Tall), "Some(Vertical)"),
|
||||
];
|
||||
|
||||
for (aspect_ratio, expected) in cases {
|
||||
|
||||
+49
-49
@@ -7,8 +7,8 @@ use fal_client::requests::api::image::text::gpt_image_1p5_text_to_image::api::{
|
||||
GptImage1p5TextToImageRequest, GptImage1p5TextToImageSize,
|
||||
};
|
||||
|
||||
use crate::api::common_aspect_ratio::CommonAspectRatio;
|
||||
use crate::api::common_quality::CommonQuality;
|
||||
use crate::api::router_aspect_ratio::RouterAspectRatio;
|
||||
use crate::api::router_quality::RouterQuality;
|
||||
use crate::api::image_list_ref::ImageListRef;
|
||||
use crate::client::request_mismatch_mitigation_strategy::RequestMismatchMitigationStrategy;
|
||||
use crate::errors::artcraft_router_error::ArtcraftRouterError;
|
||||
@@ -100,36 +100,36 @@ fn plan_num_images(
|
||||
}
|
||||
}
|
||||
|
||||
fn plan_quality(quality: Option<CommonQuality>) -> PlannedQuality {
|
||||
fn plan_quality(quality: Option<RouterQuality>) -> PlannedQuality {
|
||||
match quality {
|
||||
Some(CommonQuality::Low) => PlannedQuality::Low,
|
||||
Some(CommonQuality::Medium) => PlannedQuality::Medium,
|
||||
Some(CommonQuality::High) | None => PlannedQuality::High,
|
||||
Some(RouterQuality::Low) => PlannedQuality::Low,
|
||||
Some(RouterQuality::Medium) => PlannedQuality::Medium,
|
||||
Some(RouterQuality::High) | None => PlannedQuality::High,
|
||||
}
|
||||
}
|
||||
|
||||
fn plan_image_size(aspect_ratio: Option<CommonAspectRatio>) -> Option<PlannedImageSize> {
|
||||
fn plan_image_size(aspect_ratio: Option<RouterAspectRatio>) -> Option<PlannedImageSize> {
|
||||
match aspect_ratio {
|
||||
None
|
||||
| Some(CommonAspectRatio::Auto)
|
||||
| Some(CommonAspectRatio::Auto2k)
|
||||
| Some(CommonAspectRatio::Auto3k)
|
||||
| Some(CommonAspectRatio::Auto4k) => None,
|
||||
Some(CommonAspectRatio::Square) | Some(CommonAspectRatio::SquareHd) => {
|
||||
| Some(RouterAspectRatio::Auto)
|
||||
| Some(RouterAspectRatio::Auto2k)
|
||||
| Some(RouterAspectRatio::Auto3k)
|
||||
| Some(RouterAspectRatio::Auto4k) => None,
|
||||
Some(RouterAspectRatio::Square) | Some(RouterAspectRatio::SquareHd) => {
|
||||
Some(PlannedImageSize::Square)
|
||||
}
|
||||
Some(CommonAspectRatio::WideThreeByTwo)
|
||||
| Some(CommonAspectRatio::WideFourByThree)
|
||||
| Some(CommonAspectRatio::WideFiveByFour)
|
||||
| Some(CommonAspectRatio::WideSixteenByNine)
|
||||
| Some(CommonAspectRatio::WideTwentyOneByNine)
|
||||
| Some(CommonAspectRatio::Wide) => Some(PlannedImageSize::Wide),
|
||||
Some(CommonAspectRatio::TallTwoByThree)
|
||||
| Some(CommonAspectRatio::TallThreeByFour)
|
||||
| Some(CommonAspectRatio::TallFourByFive)
|
||||
| Some(CommonAspectRatio::TallNineBySixteen)
|
||||
| Some(CommonAspectRatio::TallNineByTwentyOne)
|
||||
| Some(CommonAspectRatio::Tall) => Some(PlannedImageSize::Tall),
|
||||
Some(RouterAspectRatio::WideThreeByTwo)
|
||||
| Some(RouterAspectRatio::WideFourByThree)
|
||||
| Some(RouterAspectRatio::WideFiveByFour)
|
||||
| Some(RouterAspectRatio::WideSixteenByNine)
|
||||
| Some(RouterAspectRatio::WideTwentyOneByNine)
|
||||
| Some(RouterAspectRatio::Wide) => Some(PlannedImageSize::Wide),
|
||||
Some(RouterAspectRatio::TallTwoByThree)
|
||||
| Some(RouterAspectRatio::TallThreeByFour)
|
||||
| Some(RouterAspectRatio::TallFourByFive)
|
||||
| Some(RouterAspectRatio::TallNineBySixteen)
|
||||
| Some(RouterAspectRatio::TallNineByTwentyOne)
|
||||
| Some(RouterAspectRatio::Tall) => Some(PlannedImageSize::Tall),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -200,13 +200,13 @@ mod tests {
|
||||
use super::*;
|
||||
use std::fmt::Debug;
|
||||
|
||||
use crate::api::common_image_model::CommonImageModel;
|
||||
use crate::api::provider::Provider;
|
||||
use crate::api::router_image_model::RouterImageModel;
|
||||
use crate::api::router_provider::RouterProvider;
|
||||
|
||||
fn base_builder() -> GenerateImageRequestBuilder {
|
||||
GenerateImageRequestBuilder {
|
||||
model: CommonImageModel::GptImage1p5,
|
||||
provider: Provider::Fal,
|
||||
model: RouterImageModel::GptImage1p5,
|
||||
provider: RouterProvider::Fal,
|
||||
prompt: Some("a cat in space".to_string()),
|
||||
image_inputs: None,
|
||||
resolution: None,
|
||||
@@ -334,9 +334,9 @@ mod tests {
|
||||
fn quality_maps_exhaustively_for_text_and_edit() {
|
||||
let cases = [
|
||||
(None, "Some(High)"),
|
||||
(Some(CommonQuality::Low), "Some(Low)"),
|
||||
(Some(CommonQuality::Medium), "Some(Medium)"),
|
||||
(Some(CommonQuality::High), "Some(High)"),
|
||||
(Some(RouterQuality::Low), "Some(Low)"),
|
||||
(Some(RouterQuality::Medium), "Some(Medium)"),
|
||||
(Some(RouterQuality::High), "Some(High)"),
|
||||
];
|
||||
|
||||
for (quality, expected) in cases {
|
||||
@@ -361,24 +361,24 @@ mod tests {
|
||||
fn aspect_ratio_maps_exhaustively_for_text_and_edit() {
|
||||
let cases = [
|
||||
(None, "None"),
|
||||
(Some(CommonAspectRatio::Auto), "None"),
|
||||
(Some(CommonAspectRatio::Auto2k), "None"),
|
||||
(Some(CommonAspectRatio::Auto3k), "None"),
|
||||
(Some(CommonAspectRatio::Auto4k), "None"),
|
||||
(Some(CommonAspectRatio::Square), "Some(Square)"),
|
||||
(Some(CommonAspectRatio::SquareHd), "Some(Square)"),
|
||||
(Some(CommonAspectRatio::WideThreeByTwo), "Some(Wide)"),
|
||||
(Some(CommonAspectRatio::WideFourByThree), "Some(Wide)"),
|
||||
(Some(CommonAspectRatio::WideFiveByFour), "Some(Wide)"),
|
||||
(Some(CommonAspectRatio::WideSixteenByNine), "Some(Wide)"),
|
||||
(Some(CommonAspectRatio::WideTwentyOneByNine), "Some(Wide)"),
|
||||
(Some(CommonAspectRatio::Wide), "Some(Wide)"),
|
||||
(Some(CommonAspectRatio::TallTwoByThree), "Some(Tall)"),
|
||||
(Some(CommonAspectRatio::TallThreeByFour), "Some(Tall)"),
|
||||
(Some(CommonAspectRatio::TallFourByFive), "Some(Tall)"),
|
||||
(Some(CommonAspectRatio::TallNineBySixteen), "Some(Tall)"),
|
||||
(Some(CommonAspectRatio::TallNineByTwentyOne), "Some(Tall)"),
|
||||
(Some(CommonAspectRatio::Tall), "Some(Tall)"),
|
||||
(Some(RouterAspectRatio::Auto), "None"),
|
||||
(Some(RouterAspectRatio::Auto2k), "None"),
|
||||
(Some(RouterAspectRatio::Auto3k), "None"),
|
||||
(Some(RouterAspectRatio::Auto4k), "None"),
|
||||
(Some(RouterAspectRatio::Square), "Some(Square)"),
|
||||
(Some(RouterAspectRatio::SquareHd), "Some(Square)"),
|
||||
(Some(RouterAspectRatio::WideThreeByTwo), "Some(Wide)"),
|
||||
(Some(RouterAspectRatio::WideFourByThree), "Some(Wide)"),
|
||||
(Some(RouterAspectRatio::WideFiveByFour), "Some(Wide)"),
|
||||
(Some(RouterAspectRatio::WideSixteenByNine), "Some(Wide)"),
|
||||
(Some(RouterAspectRatio::WideTwentyOneByNine), "Some(Wide)"),
|
||||
(Some(RouterAspectRatio::Wide), "Some(Wide)"),
|
||||
(Some(RouterAspectRatio::TallTwoByThree), "Some(Tall)"),
|
||||
(Some(RouterAspectRatio::TallThreeByFour), "Some(Tall)"),
|
||||
(Some(RouterAspectRatio::TallFourByFive), "Some(Tall)"),
|
||||
(Some(RouterAspectRatio::TallNineBySixteen), "Some(Tall)"),
|
||||
(Some(RouterAspectRatio::TallNineByTwentyOne), "Some(Tall)"),
|
||||
(Some(RouterAspectRatio::Tall), "Some(Tall)"),
|
||||
];
|
||||
|
||||
for (aspect_ratio, expected) in cases {
|
||||
|
||||
+67
-67
@@ -8,9 +8,9 @@ use fal_client::requests::api::image::text::gpt_image_2_text_to_image::api::{
|
||||
GptImage2TextToImageRequest, GptImage2TextToImageSize,
|
||||
};
|
||||
|
||||
use crate::api::common_aspect_ratio::CommonAspectRatio;
|
||||
use crate::api::common_quality::CommonQuality;
|
||||
use crate::api::common_resolution::CommonResolution;
|
||||
use crate::api::router_aspect_ratio::RouterAspectRatio;
|
||||
use crate::api::router_quality::RouterQuality;
|
||||
use crate::api::router_resolution::RouterResolution;
|
||||
use crate::api::image_list_ref::ImageListRef;
|
||||
use crate::client::request_mismatch_mitigation_strategy::RequestMismatchMitigationStrategy;
|
||||
use crate::errors::artcraft_router_error::ArtcraftRouterError;
|
||||
@@ -106,47 +106,47 @@ fn plan_num_images(
|
||||
}
|
||||
}
|
||||
|
||||
fn plan_quality(quality: Option<CommonQuality>) -> PlannedQuality {
|
||||
fn plan_quality(quality: Option<RouterQuality>) -> PlannedQuality {
|
||||
match quality {
|
||||
Some(CommonQuality::Low) => PlannedQuality::Low,
|
||||
Some(CommonQuality::Medium) => PlannedQuality::Medium,
|
||||
Some(CommonQuality::High) | None => PlannedQuality::High,
|
||||
Some(RouterQuality::Low) => PlannedQuality::Low,
|
||||
Some(RouterQuality::Medium) => PlannedQuality::Medium,
|
||||
Some(RouterQuality::High) | None => PlannedQuality::High,
|
||||
}
|
||||
}
|
||||
|
||||
fn plan_resolution(resolution: Option<CommonResolution>) -> Option<GptImage2Resolution> {
|
||||
fn plan_resolution(resolution: Option<RouterResolution>) -> Option<GptImage2Resolution> {
|
||||
resolution.map(|r| match r {
|
||||
CommonResolution::HalfK
|
||||
| CommonResolution::FourEightyP
|
||||
| CommonResolution::SevenTwentyP
|
||||
| CommonResolution::OneK => GptImage2Resolution::OneK,
|
||||
CommonResolution::TenEightyP | CommonResolution::TwoK => GptImage2Resolution::TwoK,
|
||||
CommonResolution::ThreeK => GptImage2Resolution::ThreeK,
|
||||
CommonResolution::FourK => GptImage2Resolution::FourK,
|
||||
RouterResolution::HalfK
|
||||
| RouterResolution::FourEightyP
|
||||
| RouterResolution::SevenTwentyP
|
||||
| RouterResolution::OneK => GptImage2Resolution::OneK,
|
||||
RouterResolution::TenEightyP | RouterResolution::TwoK => GptImage2Resolution::TwoK,
|
||||
RouterResolution::ThreeK => GptImage2Resolution::ThreeK,
|
||||
RouterResolution::FourK => GptImage2Resolution::FourK,
|
||||
})
|
||||
}
|
||||
|
||||
fn plan_image_size(aspect_ratio: Option<CommonAspectRatio>) -> Option<PlannedImageSize> {
|
||||
fn plan_image_size(aspect_ratio: Option<RouterAspectRatio>) -> Option<PlannedImageSize> {
|
||||
match aspect_ratio {
|
||||
None => None,
|
||||
Some(CommonAspectRatio::Auto)
|
||||
| Some(CommonAspectRatio::Auto2k)
|
||||
| Some(CommonAspectRatio::Auto3k)
|
||||
| Some(CommonAspectRatio::Auto4k) => Some(PlannedImageSize::Auto),
|
||||
Some(CommonAspectRatio::Square) => Some(PlannedImageSize::Square),
|
||||
Some(CommonAspectRatio::SquareHd) => Some(PlannedImageSize::SquareHd),
|
||||
Some(CommonAspectRatio::WideFourByThree)
|
||||
| Some(CommonAspectRatio::WideFiveByFour) => Some(PlannedImageSize::Landscape4x3),
|
||||
Some(CommonAspectRatio::WideThreeByTwo)
|
||||
| Some(CommonAspectRatio::WideSixteenByNine)
|
||||
| Some(CommonAspectRatio::WideTwentyOneByNine)
|
||||
| Some(CommonAspectRatio::Wide) => Some(PlannedImageSize::Landscape16x9),
|
||||
Some(CommonAspectRatio::TallThreeByFour)
|
||||
| Some(CommonAspectRatio::TallFourByFive) => Some(PlannedImageSize::Portrait4x3),
|
||||
Some(CommonAspectRatio::TallTwoByThree)
|
||||
| Some(CommonAspectRatio::TallNineBySixteen)
|
||||
| Some(CommonAspectRatio::TallNineByTwentyOne)
|
||||
| Some(CommonAspectRatio::Tall) => Some(PlannedImageSize::Portrait16x9),
|
||||
Some(RouterAspectRatio::Auto)
|
||||
| Some(RouterAspectRatio::Auto2k)
|
||||
| Some(RouterAspectRatio::Auto3k)
|
||||
| Some(RouterAspectRatio::Auto4k) => Some(PlannedImageSize::Auto),
|
||||
Some(RouterAspectRatio::Square) => Some(PlannedImageSize::Square),
|
||||
Some(RouterAspectRatio::SquareHd) => Some(PlannedImageSize::SquareHd),
|
||||
Some(RouterAspectRatio::WideFourByThree)
|
||||
| Some(RouterAspectRatio::WideFiveByFour) => Some(PlannedImageSize::Landscape4x3),
|
||||
Some(RouterAspectRatio::WideThreeByTwo)
|
||||
| Some(RouterAspectRatio::WideSixteenByNine)
|
||||
| Some(RouterAspectRatio::WideTwentyOneByNine)
|
||||
| Some(RouterAspectRatio::Wide) => Some(PlannedImageSize::Landscape16x9),
|
||||
Some(RouterAspectRatio::TallThreeByFour)
|
||||
| Some(RouterAspectRatio::TallFourByFive) => Some(PlannedImageSize::Portrait4x3),
|
||||
Some(RouterAspectRatio::TallTwoByThree)
|
||||
| Some(RouterAspectRatio::TallNineBySixteen)
|
||||
| Some(RouterAspectRatio::TallNineByTwentyOne)
|
||||
| Some(RouterAspectRatio::Tall) => Some(PlannedImageSize::Portrait16x9),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -225,13 +225,13 @@ mod tests {
|
||||
use super::*;
|
||||
use std::fmt::Debug;
|
||||
|
||||
use crate::api::common_image_model::CommonImageModel;
|
||||
use crate::api::provider::Provider;
|
||||
use crate::api::router_image_model::RouterImageModel;
|
||||
use crate::api::router_provider::RouterProvider;
|
||||
|
||||
fn base_builder() -> GenerateImageRequestBuilder {
|
||||
GenerateImageRequestBuilder {
|
||||
model: CommonImageModel::GptImage2,
|
||||
provider: Provider::Fal,
|
||||
model: RouterImageModel::GptImage2,
|
||||
provider: RouterProvider::Fal,
|
||||
prompt: Some("a cat in space".to_string()),
|
||||
image_inputs: None,
|
||||
resolution: None,
|
||||
@@ -359,9 +359,9 @@ mod tests {
|
||||
fn quality_maps_exhaustively_for_text_and_edit() {
|
||||
let cases = [
|
||||
(None, "Some(High)"),
|
||||
(Some(CommonQuality::Low), "Some(Low)"),
|
||||
(Some(CommonQuality::Medium), "Some(Medium)"),
|
||||
(Some(CommonQuality::High), "Some(High)"),
|
||||
(Some(RouterQuality::Low), "Some(Low)"),
|
||||
(Some(RouterQuality::Medium), "Some(Medium)"),
|
||||
(Some(RouterQuality::High), "Some(High)"),
|
||||
];
|
||||
|
||||
for (quality, expected) in cases {
|
||||
@@ -386,14 +386,14 @@ mod tests {
|
||||
fn resolution_maps_exhaustively_for_text_and_edit() {
|
||||
let cases = [
|
||||
(None, "None"),
|
||||
(Some(CommonResolution::HalfK), "Some(OneK)"),
|
||||
(Some(CommonResolution::FourEightyP), "Some(OneK)"),
|
||||
(Some(CommonResolution::SevenTwentyP), "Some(OneK)"),
|
||||
(Some(CommonResolution::OneK), "Some(OneK)"),
|
||||
(Some(CommonResolution::TenEightyP), "Some(TwoK)"),
|
||||
(Some(CommonResolution::TwoK), "Some(TwoK)"),
|
||||
(Some(CommonResolution::ThreeK), "Some(ThreeK)"),
|
||||
(Some(CommonResolution::FourK), "Some(FourK)"),
|
||||
(Some(RouterResolution::HalfK), "Some(OneK)"),
|
||||
(Some(RouterResolution::FourEightyP), "Some(OneK)"),
|
||||
(Some(RouterResolution::SevenTwentyP), "Some(OneK)"),
|
||||
(Some(RouterResolution::OneK), "Some(OneK)"),
|
||||
(Some(RouterResolution::TenEightyP), "Some(TwoK)"),
|
||||
(Some(RouterResolution::TwoK), "Some(TwoK)"),
|
||||
(Some(RouterResolution::ThreeK), "Some(ThreeK)"),
|
||||
(Some(RouterResolution::FourK), "Some(FourK)"),
|
||||
];
|
||||
|
||||
for (resolution, expected) in cases {
|
||||
@@ -418,24 +418,24 @@ mod tests {
|
||||
fn aspect_ratio_maps_exhaustively_for_text_and_edit() {
|
||||
let cases = [
|
||||
(None, "None", "None"),
|
||||
(Some(CommonAspectRatio::Auto), "None", "Some(Auto)"),
|
||||
(Some(CommonAspectRatio::Auto2k), "None", "Some(Auto)"),
|
||||
(Some(CommonAspectRatio::Auto3k), "None", "Some(Auto)"),
|
||||
(Some(CommonAspectRatio::Auto4k), "None", "Some(Auto)"),
|
||||
(Some(CommonAspectRatio::Square), "Some(Square)", "Some(Square)"),
|
||||
(Some(CommonAspectRatio::SquareHd), "Some(SquareHd)", "Some(SquareHd)"),
|
||||
(Some(CommonAspectRatio::WideThreeByTwo), "Some(Landscape16x9)", "Some(Landscape16x9)"),
|
||||
(Some(CommonAspectRatio::WideFourByThree), "Some(Landscape4x3)", "Some(Landscape4x3)"),
|
||||
(Some(CommonAspectRatio::WideFiveByFour), "Some(Landscape4x3)", "Some(Landscape4x3)"),
|
||||
(Some(CommonAspectRatio::WideSixteenByNine), "Some(Landscape16x9)", "Some(Landscape16x9)"),
|
||||
(Some(CommonAspectRatio::WideTwentyOneByNine), "Some(Landscape16x9)", "Some(Landscape16x9)"),
|
||||
(Some(CommonAspectRatio::Wide), "Some(Landscape16x9)", "Some(Landscape16x9)"),
|
||||
(Some(CommonAspectRatio::TallTwoByThree), "Some(Portrait16x9)", "Some(Portrait16x9)"),
|
||||
(Some(CommonAspectRatio::TallThreeByFour), "Some(Portrait4x3)", "Some(Portrait4x3)"),
|
||||
(Some(CommonAspectRatio::TallFourByFive), "Some(Portrait4x3)", "Some(Portrait4x3)"),
|
||||
(Some(CommonAspectRatio::TallNineBySixteen), "Some(Portrait16x9)", "Some(Portrait16x9)"),
|
||||
(Some(CommonAspectRatio::TallNineByTwentyOne), "Some(Portrait16x9)", "Some(Portrait16x9)"),
|
||||
(Some(CommonAspectRatio::Tall), "Some(Portrait16x9)", "Some(Portrait16x9)"),
|
||||
(Some(RouterAspectRatio::Auto), "None", "Some(Auto)"),
|
||||
(Some(RouterAspectRatio::Auto2k), "None", "Some(Auto)"),
|
||||
(Some(RouterAspectRatio::Auto3k), "None", "Some(Auto)"),
|
||||
(Some(RouterAspectRatio::Auto4k), "None", "Some(Auto)"),
|
||||
(Some(RouterAspectRatio::Square), "Some(Square)", "Some(Square)"),
|
||||
(Some(RouterAspectRatio::SquareHd), "Some(SquareHd)", "Some(SquareHd)"),
|
||||
(Some(RouterAspectRatio::WideThreeByTwo), "Some(Landscape16x9)", "Some(Landscape16x9)"),
|
||||
(Some(RouterAspectRatio::WideFourByThree), "Some(Landscape4x3)", "Some(Landscape4x3)"),
|
||||
(Some(RouterAspectRatio::WideFiveByFour), "Some(Landscape4x3)", "Some(Landscape4x3)"),
|
||||
(Some(RouterAspectRatio::WideSixteenByNine), "Some(Landscape16x9)", "Some(Landscape16x9)"),
|
||||
(Some(RouterAspectRatio::WideTwentyOneByNine), "Some(Landscape16x9)", "Some(Landscape16x9)"),
|
||||
(Some(RouterAspectRatio::Wide), "Some(Landscape16x9)", "Some(Landscape16x9)"),
|
||||
(Some(RouterAspectRatio::TallTwoByThree), "Some(Portrait16x9)", "Some(Portrait16x9)"),
|
||||
(Some(RouterAspectRatio::TallThreeByFour), "Some(Portrait4x3)", "Some(Portrait4x3)"),
|
||||
(Some(RouterAspectRatio::TallFourByFive), "Some(Portrait4x3)", "Some(Portrait4x3)"),
|
||||
(Some(RouterAspectRatio::TallNineBySixteen), "Some(Portrait16x9)", "Some(Portrait16x9)"),
|
||||
(Some(RouterAspectRatio::TallNineByTwentyOne), "Some(Portrait16x9)", "Some(Portrait16x9)"),
|
||||
(Some(RouterAspectRatio::Tall), "Some(Portrait16x9)", "Some(Portrait16x9)"),
|
||||
];
|
||||
|
||||
for (aspect_ratio, expected_t2i, _) in cases {
|
||||
|
||||
+36
-36
@@ -6,7 +6,7 @@ use fal_client::requests::webhook::image::text::enqueue_gemini_25_flash_text_to_
|
||||
Gemini25FlashTextToImageRequest,
|
||||
};
|
||||
|
||||
use crate::api::common_aspect_ratio::CommonAspectRatio;
|
||||
use crate::api::router_aspect_ratio::RouterAspectRatio;
|
||||
use crate::api::image_list_ref::ImageListRef;
|
||||
use crate::client::request_mismatch_mitigation_strategy::RequestMismatchMitigationStrategy;
|
||||
use crate::errors::artcraft_router_error::ArtcraftRouterError;
|
||||
@@ -103,27 +103,27 @@ fn to_edit_num_images(n: PlannedNumImages) -> Gemini25FlashEditNumImages {
|
||||
// 1:1, 5:4, 4:3, 3:2, 16:9, 21:9, 4:5, 3:4, 2:3, 9:16
|
||||
// (no Auto for text-to-image)
|
||||
fn plan_t2i_aspect_ratio(
|
||||
aspect_ratio: Option<CommonAspectRatio>,
|
||||
aspect_ratio: Option<RouterAspectRatio>,
|
||||
strategy: RequestMismatchMitigationStrategy,
|
||||
) -> Result<Option<Gemini25FlashTextToImageAspectRatio>, ArtcraftRouterError> {
|
||||
use Gemini25FlashTextToImageAspectRatio as T;
|
||||
match aspect_ratio {
|
||||
None => Ok(None),
|
||||
|
||||
Some(CommonAspectRatio::Auto)
|
||||
| Some(CommonAspectRatio::Auto2k)
|
||||
| Some(CommonAspectRatio::Auto4k) => Ok(Some(T::OneByOne)),
|
||||
Some(RouterAspectRatio::Auto)
|
||||
| Some(RouterAspectRatio::Auto2k)
|
||||
| Some(RouterAspectRatio::Auto4k) => Ok(Some(T::OneByOne)),
|
||||
|
||||
Some(CommonAspectRatio::Square) | Some(CommonAspectRatio::SquareHd) => Ok(Some(T::OneByOne)),
|
||||
Some(CommonAspectRatio::WideFiveByFour) => Ok(Some(T::FiveByFour)),
|
||||
Some(CommonAspectRatio::WideFourByThree) => Ok(Some(T::FourByThree)),
|
||||
Some(CommonAspectRatio::WideThreeByTwo) => Ok(Some(T::ThreeByTwo)),
|
||||
Some(CommonAspectRatio::WideSixteenByNine) | Some(CommonAspectRatio::Wide) => Ok(Some(T::SixteenByNine)),
|
||||
Some(CommonAspectRatio::WideTwentyOneByNine) => Ok(Some(T::TwentyOneByNine)),
|
||||
Some(CommonAspectRatio::TallFourByFive) => Ok(Some(T::FourByFive)),
|
||||
Some(CommonAspectRatio::TallThreeByFour) => Ok(Some(T::ThreeByFour)),
|
||||
Some(CommonAspectRatio::TallTwoByThree) => Ok(Some(T::TwoByThree)),
|
||||
Some(CommonAspectRatio::TallNineBySixteen) | Some(CommonAspectRatio::Tall) => Ok(Some(T::NineBySixteen)),
|
||||
Some(RouterAspectRatio::Square) | Some(RouterAspectRatio::SquareHd) => Ok(Some(T::OneByOne)),
|
||||
Some(RouterAspectRatio::WideFiveByFour) => Ok(Some(T::FiveByFour)),
|
||||
Some(RouterAspectRatio::WideFourByThree) => Ok(Some(T::FourByThree)),
|
||||
Some(RouterAspectRatio::WideThreeByTwo) => Ok(Some(T::ThreeByTwo)),
|
||||
Some(RouterAspectRatio::WideSixteenByNine) | Some(RouterAspectRatio::Wide) => Ok(Some(T::SixteenByNine)),
|
||||
Some(RouterAspectRatio::WideTwentyOneByNine) => Ok(Some(T::TwentyOneByNine)),
|
||||
Some(RouterAspectRatio::TallFourByFive) => Ok(Some(T::FourByFive)),
|
||||
Some(RouterAspectRatio::TallThreeByFour) => Ok(Some(T::ThreeByFour)),
|
||||
Some(RouterAspectRatio::TallTwoByThree) => Ok(Some(T::TwoByThree)),
|
||||
Some(RouterAspectRatio::TallNineBySixteen) | Some(RouterAspectRatio::Tall) => Ok(Some(T::NineBySixteen)),
|
||||
|
||||
Some(unsupported) => match strategy {
|
||||
RequestMismatchMitigationStrategy::ErrorOut => {
|
||||
@@ -139,27 +139,27 @@ fn plan_t2i_aspect_ratio(
|
||||
|
||||
// Gemini 2.5 Flash image-edit supported aspect ratios: same as t2i plus Auto
|
||||
fn plan_edit_aspect_ratio(
|
||||
aspect_ratio: Option<CommonAspectRatio>,
|
||||
aspect_ratio: Option<RouterAspectRatio>,
|
||||
strategy: RequestMismatchMitigationStrategy,
|
||||
) -> Result<Option<Gemini25FlashEditAspectRatio>, ArtcraftRouterError> {
|
||||
use Gemini25FlashEditAspectRatio as E;
|
||||
match aspect_ratio {
|
||||
None => Ok(None),
|
||||
|
||||
Some(CommonAspectRatio::Auto)
|
||||
| Some(CommonAspectRatio::Auto2k)
|
||||
| Some(CommonAspectRatio::Auto4k) => Ok(Some(E::Auto)),
|
||||
Some(RouterAspectRatio::Auto)
|
||||
| Some(RouterAspectRatio::Auto2k)
|
||||
| Some(RouterAspectRatio::Auto4k) => Ok(Some(E::Auto)),
|
||||
|
||||
Some(CommonAspectRatio::Square) | Some(CommonAspectRatio::SquareHd) => Ok(Some(E::OneByOne)),
|
||||
Some(CommonAspectRatio::WideFiveByFour) => Ok(Some(E::FiveByFour)),
|
||||
Some(CommonAspectRatio::WideFourByThree) => Ok(Some(E::FourByThree)),
|
||||
Some(CommonAspectRatio::WideThreeByTwo) => Ok(Some(E::ThreeByTwo)),
|
||||
Some(CommonAspectRatio::WideSixteenByNine) | Some(CommonAspectRatio::Wide) => Ok(Some(E::SixteenByNine)),
|
||||
Some(CommonAspectRatio::WideTwentyOneByNine) => Ok(Some(E::TwentyOneByNine)),
|
||||
Some(CommonAspectRatio::TallFourByFive) => Ok(Some(E::FourByFive)),
|
||||
Some(CommonAspectRatio::TallThreeByFour) => Ok(Some(E::ThreeByFour)),
|
||||
Some(CommonAspectRatio::TallTwoByThree) => Ok(Some(E::TwoByThree)),
|
||||
Some(CommonAspectRatio::TallNineBySixteen) | Some(CommonAspectRatio::Tall) => Ok(Some(E::NineBySixteen)),
|
||||
Some(RouterAspectRatio::Square) | Some(RouterAspectRatio::SquareHd) => Ok(Some(E::OneByOne)),
|
||||
Some(RouterAspectRatio::WideFiveByFour) => Ok(Some(E::FiveByFour)),
|
||||
Some(RouterAspectRatio::WideFourByThree) => Ok(Some(E::FourByThree)),
|
||||
Some(RouterAspectRatio::WideThreeByTwo) => Ok(Some(E::ThreeByTwo)),
|
||||
Some(RouterAspectRatio::WideSixteenByNine) | Some(RouterAspectRatio::Wide) => Ok(Some(E::SixteenByNine)),
|
||||
Some(RouterAspectRatio::WideTwentyOneByNine) => Ok(Some(E::TwentyOneByNine)),
|
||||
Some(RouterAspectRatio::TallFourByFive) => Ok(Some(E::FourByFive)),
|
||||
Some(RouterAspectRatio::TallThreeByFour) => Ok(Some(E::ThreeByFour)),
|
||||
Some(RouterAspectRatio::TallTwoByThree) => Ok(Some(E::TwoByThree)),
|
||||
Some(RouterAspectRatio::TallNineBySixteen) | Some(RouterAspectRatio::Tall) => Ok(Some(E::NineBySixteen)),
|
||||
|
||||
Some(unsupported) => match strategy {
|
||||
RequestMismatchMitigationStrategy::ErrorOut => {
|
||||
@@ -190,13 +190,13 @@ fn resolve_image_list_ref(
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::api::common_image_model::CommonImageModel;
|
||||
use crate::api::provider::Provider;
|
||||
use crate::api::router_image_model::RouterImageModel;
|
||||
use crate::api::router_provider::RouterProvider;
|
||||
|
||||
fn base_builder() -> GenerateImageRequestBuilder {
|
||||
GenerateImageRequestBuilder {
|
||||
model: CommonImageModel::NanoBanana,
|
||||
provider: Provider::Fal,
|
||||
model: RouterImageModel::NanoBanana,
|
||||
provider: RouterProvider::Fal,
|
||||
prompt: Some("a cat in space".to_string()),
|
||||
image_inputs: None,
|
||||
resolution: None,
|
||||
@@ -301,7 +301,7 @@ mod tests {
|
||||
#[test]
|
||||
fn t2i_auto_falls_back_to_one_by_one() {
|
||||
let builder = GenerateImageRequestBuilder {
|
||||
aspect_ratio: Some(CommonAspectRatio::Auto),
|
||||
aspect_ratio: Some(RouterAspectRatio::Auto),
|
||||
..base_builder()
|
||||
};
|
||||
let req = unwrap_t2i(build_fal_nano_banana(builder));
|
||||
@@ -311,7 +311,7 @@ mod tests {
|
||||
#[test]
|
||||
fn t2i_wide_sixteen_by_nine() {
|
||||
let builder = GenerateImageRequestBuilder {
|
||||
aspect_ratio: Some(CommonAspectRatio::WideSixteenByNine),
|
||||
aspect_ratio: Some(RouterAspectRatio::WideSixteenByNine),
|
||||
..base_builder()
|
||||
};
|
||||
let req = unwrap_t2i(build_fal_nano_banana(builder));
|
||||
@@ -322,7 +322,7 @@ mod tests {
|
||||
fn edit_auto_is_preserved() {
|
||||
let builder = GenerateImageRequestBuilder {
|
||||
image_inputs: Some(ImageListRef::Urls(vec!["https://example.com/img.jpg".to_string()])),
|
||||
aspect_ratio: Some(CommonAspectRatio::Auto),
|
||||
aspect_ratio: Some(RouterAspectRatio::Auto),
|
||||
..base_builder()
|
||||
};
|
||||
let req = unwrap_edit(build_fal_nano_banana(builder));
|
||||
|
||||
+53
-53
@@ -7,8 +7,8 @@ use fal_client::requests::api::image::text::nano_banana_2_text_to_image::api::{
|
||||
NanoBanana2TextToImageRequest, NanoBanana2TextToImageResolution,
|
||||
};
|
||||
|
||||
use crate::api::common_aspect_ratio::CommonAspectRatio;
|
||||
use crate::api::common_resolution::CommonResolution;
|
||||
use crate::api::router_aspect_ratio::RouterAspectRatio;
|
||||
use crate::api::router_resolution::RouterResolution;
|
||||
use crate::api::image_list_ref::ImageListRef;
|
||||
use crate::client::request_mismatch_mitigation_strategy::RequestMismatchMitigationStrategy;
|
||||
use crate::errors::artcraft_router_error::ArtcraftRouterError;
|
||||
@@ -117,15 +117,15 @@ enum PlannedResolution {
|
||||
FourK,
|
||||
}
|
||||
|
||||
fn plan_resolution(resolution: Option<CommonResolution>) -> Option<PlannedResolution> {
|
||||
fn plan_resolution(resolution: Option<RouterResolution>) -> Option<PlannedResolution> {
|
||||
resolution.map(|r| match r {
|
||||
CommonResolution::HalfK | CommonResolution::FourEightyP => PlannedResolution::HalfK,
|
||||
CommonResolution::OneK | CommonResolution::SevenTwentyP | CommonResolution::TenEightyP => PlannedResolution::OneK,
|
||||
CommonResolution::TwoK => PlannedResolution::TwoK,
|
||||
RouterResolution::HalfK | RouterResolution::FourEightyP => PlannedResolution::HalfK,
|
||||
RouterResolution::OneK | RouterResolution::SevenTwentyP | RouterResolution::TenEightyP => PlannedResolution::OneK,
|
||||
RouterResolution::TwoK => PlannedResolution::TwoK,
|
||||
// 3K isn't natively supported on Fal nano_banana_2; v1 downgrades to 2K
|
||||
// pricing (and TwoK resolution). Match v1 here so cost+behavior agree.
|
||||
CommonResolution::ThreeK => PlannedResolution::TwoK,
|
||||
CommonResolution::FourK => PlannedResolution::FourK,
|
||||
RouterResolution::ThreeK => PlannedResolution::TwoK,
|
||||
RouterResolution::FourK => PlannedResolution::FourK,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -150,44 +150,44 @@ fn to_edit_resolution(r: PlannedResolution) -> NanoBanana2EditImageResolution {
|
||||
// ── Aspect ratio ──
|
||||
|
||||
fn plan_t2i_aspect_ratio(
|
||||
aspect_ratio: Option<CommonAspectRatio>,
|
||||
aspect_ratio: Option<RouterAspectRatio>,
|
||||
) -> Option<NanoBanana2TextToImageAspectRatio> {
|
||||
use NanoBanana2TextToImageAspectRatio as T;
|
||||
aspect_ratio.map(|ar| match ar {
|
||||
CommonAspectRatio::Auto | CommonAspectRatio::Auto2k
|
||||
| CommonAspectRatio::Auto3k | CommonAspectRatio::Auto4k => T::Auto,
|
||||
CommonAspectRatio::Square | CommonAspectRatio::SquareHd => T::OneByOne,
|
||||
CommonAspectRatio::WideFiveByFour => T::FiveByFour,
|
||||
CommonAspectRatio::WideFourByThree => T::FourByThree,
|
||||
CommonAspectRatio::WideThreeByTwo | CommonAspectRatio::Wide => T::ThreeByTwo,
|
||||
CommonAspectRatio::WideSixteenByNine => T::SixteenByNine,
|
||||
CommonAspectRatio::WideTwentyOneByNine => T::TwentyOneByNine,
|
||||
CommonAspectRatio::TallFourByFive => T::FourByFive,
|
||||
CommonAspectRatio::TallThreeByFour => T::ThreeByFour,
|
||||
CommonAspectRatio::TallTwoByThree | CommonAspectRatio::Tall => T::TwoByThree,
|
||||
CommonAspectRatio::TallNineBySixteen => T::NineBySixteen,
|
||||
CommonAspectRatio::TallNineByTwentyOne => T::NineBySixteen, // nearest match
|
||||
RouterAspectRatio::Auto | RouterAspectRatio::Auto2k
|
||||
| RouterAspectRatio::Auto3k | RouterAspectRatio::Auto4k => T::Auto,
|
||||
RouterAspectRatio::Square | RouterAspectRatio::SquareHd => T::OneByOne,
|
||||
RouterAspectRatio::WideFiveByFour => T::FiveByFour,
|
||||
RouterAspectRatio::WideFourByThree => T::FourByThree,
|
||||
RouterAspectRatio::WideThreeByTwo | RouterAspectRatio::Wide => T::ThreeByTwo,
|
||||
RouterAspectRatio::WideSixteenByNine => T::SixteenByNine,
|
||||
RouterAspectRatio::WideTwentyOneByNine => T::TwentyOneByNine,
|
||||
RouterAspectRatio::TallFourByFive => T::FourByFive,
|
||||
RouterAspectRatio::TallThreeByFour => T::ThreeByFour,
|
||||
RouterAspectRatio::TallTwoByThree | RouterAspectRatio::Tall => T::TwoByThree,
|
||||
RouterAspectRatio::TallNineBySixteen => T::NineBySixteen,
|
||||
RouterAspectRatio::TallNineByTwentyOne => T::NineBySixteen, // nearest match
|
||||
})
|
||||
}
|
||||
|
||||
fn plan_edit_aspect_ratio(
|
||||
aspect_ratio: Option<CommonAspectRatio>,
|
||||
aspect_ratio: Option<RouterAspectRatio>,
|
||||
) -> Option<NanoBanana2EditImageAspectRatio> {
|
||||
use NanoBanana2EditImageAspectRatio as E;
|
||||
aspect_ratio.map(|ar| match ar {
|
||||
CommonAspectRatio::Auto | CommonAspectRatio::Auto2k
|
||||
| CommonAspectRatio::Auto3k | CommonAspectRatio::Auto4k => E::Auto,
|
||||
CommonAspectRatio::Square | CommonAspectRatio::SquareHd => E::OneByOne,
|
||||
CommonAspectRatio::WideFiveByFour => E::FiveByFour,
|
||||
CommonAspectRatio::WideFourByThree => E::FourByThree,
|
||||
CommonAspectRatio::WideThreeByTwo | CommonAspectRatio::Wide => E::ThreeByTwo,
|
||||
CommonAspectRatio::WideSixteenByNine => E::SixteenByNine,
|
||||
CommonAspectRatio::WideTwentyOneByNine => E::TwentyOneByNine,
|
||||
CommonAspectRatio::TallFourByFive => E::FourByFive,
|
||||
CommonAspectRatio::TallThreeByFour => E::ThreeByFour,
|
||||
CommonAspectRatio::TallTwoByThree | CommonAspectRatio::Tall => E::TwoByThree,
|
||||
CommonAspectRatio::TallNineBySixteen => E::NineBySixteen,
|
||||
CommonAspectRatio::TallNineByTwentyOne => E::NineBySixteen, // nearest match
|
||||
RouterAspectRatio::Auto | RouterAspectRatio::Auto2k
|
||||
| RouterAspectRatio::Auto3k | RouterAspectRatio::Auto4k => E::Auto,
|
||||
RouterAspectRatio::Square | RouterAspectRatio::SquareHd => E::OneByOne,
|
||||
RouterAspectRatio::WideFiveByFour => E::FiveByFour,
|
||||
RouterAspectRatio::WideFourByThree => E::FourByThree,
|
||||
RouterAspectRatio::WideThreeByTwo | RouterAspectRatio::Wide => E::ThreeByTwo,
|
||||
RouterAspectRatio::WideSixteenByNine => E::SixteenByNine,
|
||||
RouterAspectRatio::WideTwentyOneByNine => E::TwentyOneByNine,
|
||||
RouterAspectRatio::TallFourByFive => E::FourByFive,
|
||||
RouterAspectRatio::TallThreeByFour => E::ThreeByFour,
|
||||
RouterAspectRatio::TallTwoByThree | RouterAspectRatio::Tall => E::TwoByThree,
|
||||
RouterAspectRatio::TallNineBySixteen => E::NineBySixteen,
|
||||
RouterAspectRatio::TallNineByTwentyOne => E::NineBySixteen, // nearest match
|
||||
})
|
||||
}
|
||||
|
||||
@@ -208,13 +208,13 @@ fn resolve_image_urls(
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::api::common_image_model::CommonImageModel;
|
||||
use crate::api::provider::Provider;
|
||||
use crate::api::router_image_model::RouterImageModel;
|
||||
use crate::api::router_provider::RouterProvider;
|
||||
|
||||
fn base_builder() -> GenerateImageRequestBuilder {
|
||||
GenerateImageRequestBuilder {
|
||||
model: CommonImageModel::NanoBanana2,
|
||||
provider: Provider::Fal,
|
||||
model: RouterImageModel::NanoBanana2,
|
||||
provider: RouterProvider::Fal,
|
||||
prompt: Some("a cat in space".to_string()),
|
||||
image_inputs: None,
|
||||
resolution: None,
|
||||
@@ -371,7 +371,7 @@ mod tests {
|
||||
#[test]
|
||||
fn half_k_maps_to_half_k() {
|
||||
let builder = GenerateImageRequestBuilder {
|
||||
resolution: Some(CommonResolution::HalfK),
|
||||
resolution: Some(RouterResolution::HalfK),
|
||||
..base_builder()
|
||||
};
|
||||
let req = unwrap_t2i(build_fal_nano_banana_2(builder));
|
||||
@@ -381,7 +381,7 @@ mod tests {
|
||||
#[test]
|
||||
fn four_eighty_p_maps_to_half_k() {
|
||||
let builder = GenerateImageRequestBuilder {
|
||||
resolution: Some(CommonResolution::FourEightyP),
|
||||
resolution: Some(RouterResolution::FourEightyP),
|
||||
..base_builder()
|
||||
};
|
||||
let req = unwrap_t2i(build_fal_nano_banana_2(builder));
|
||||
@@ -391,7 +391,7 @@ mod tests {
|
||||
#[test]
|
||||
fn one_k_maps_to_one_k() {
|
||||
let builder = GenerateImageRequestBuilder {
|
||||
resolution: Some(CommonResolution::OneK),
|
||||
resolution: Some(RouterResolution::OneK),
|
||||
..base_builder()
|
||||
};
|
||||
let req = unwrap_t2i(build_fal_nano_banana_2(builder));
|
||||
@@ -401,7 +401,7 @@ mod tests {
|
||||
#[test]
|
||||
fn two_k_maps_to_two_k() {
|
||||
let builder = GenerateImageRequestBuilder {
|
||||
resolution: Some(CommonResolution::TwoK),
|
||||
resolution: Some(RouterResolution::TwoK),
|
||||
..base_builder()
|
||||
};
|
||||
let req = unwrap_t2i(build_fal_nano_banana_2(builder));
|
||||
@@ -411,7 +411,7 @@ mod tests {
|
||||
#[test]
|
||||
fn four_k_maps_to_four_k() {
|
||||
let builder = GenerateImageRequestBuilder {
|
||||
resolution: Some(CommonResolution::FourK),
|
||||
resolution: Some(RouterResolution::FourK),
|
||||
..base_builder()
|
||||
};
|
||||
let req = unwrap_t2i(build_fal_nano_banana_2(builder));
|
||||
@@ -422,7 +422,7 @@ mod tests {
|
||||
fn three_k_rounds_down_to_two_k() {
|
||||
// Match v1's downgrade behavior: 3K → 2K (cheaper, no 3K native support).
|
||||
let builder = GenerateImageRequestBuilder {
|
||||
resolution: Some(CommonResolution::ThreeK),
|
||||
resolution: Some(RouterResolution::ThreeK),
|
||||
..base_builder()
|
||||
};
|
||||
let req = unwrap_t2i(build_fal_nano_banana_2(builder));
|
||||
@@ -433,7 +433,7 @@ mod tests {
|
||||
fn edit_mode_resolution() {
|
||||
let builder = GenerateImageRequestBuilder {
|
||||
image_inputs: Some(ImageListRef::Urls(vec!["https://example.com/img.jpg".to_string()])),
|
||||
resolution: Some(CommonResolution::HalfK),
|
||||
resolution: Some(RouterResolution::HalfK),
|
||||
..base_builder()
|
||||
};
|
||||
let req = unwrap_edit(build_fal_nano_banana_2(builder));
|
||||
@@ -455,7 +455,7 @@ mod tests {
|
||||
#[test]
|
||||
fn auto_maps_to_auto_t2i() {
|
||||
let builder = GenerateImageRequestBuilder {
|
||||
aspect_ratio: Some(CommonAspectRatio::Auto),
|
||||
aspect_ratio: Some(RouterAspectRatio::Auto),
|
||||
..base_builder()
|
||||
};
|
||||
let req = unwrap_t2i(build_fal_nano_banana_2(builder));
|
||||
@@ -465,7 +465,7 @@ mod tests {
|
||||
#[test]
|
||||
fn square_maps_to_one_by_one() {
|
||||
let builder = GenerateImageRequestBuilder {
|
||||
aspect_ratio: Some(CommonAspectRatio::Square),
|
||||
aspect_ratio: Some(RouterAspectRatio::Square),
|
||||
..base_builder()
|
||||
};
|
||||
let req = unwrap_t2i(build_fal_nano_banana_2(builder));
|
||||
@@ -475,7 +475,7 @@ mod tests {
|
||||
#[test]
|
||||
fn wide_sixteen_by_nine() {
|
||||
let builder = GenerateImageRequestBuilder {
|
||||
aspect_ratio: Some(CommonAspectRatio::WideSixteenByNine),
|
||||
aspect_ratio: Some(RouterAspectRatio::WideSixteenByNine),
|
||||
..base_builder()
|
||||
};
|
||||
let req = unwrap_t2i(build_fal_nano_banana_2(builder));
|
||||
@@ -485,7 +485,7 @@ mod tests {
|
||||
#[test]
|
||||
fn tall_nine_by_sixteen() {
|
||||
let builder = GenerateImageRequestBuilder {
|
||||
aspect_ratio: Some(CommonAspectRatio::TallNineBySixteen),
|
||||
aspect_ratio: Some(RouterAspectRatio::TallNineBySixteen),
|
||||
..base_builder()
|
||||
};
|
||||
let req = unwrap_t2i(build_fal_nano_banana_2(builder));
|
||||
@@ -495,7 +495,7 @@ mod tests {
|
||||
#[test]
|
||||
fn edit_auto() {
|
||||
let builder = GenerateImageRequestBuilder {
|
||||
aspect_ratio: Some(CommonAspectRatio::Auto),
|
||||
aspect_ratio: Some(RouterAspectRatio::Auto),
|
||||
image_inputs: Some(ImageListRef::Urls(vec!["https://example.com/img.jpg".to_string()])),
|
||||
..base_builder()
|
||||
};
|
||||
@@ -506,7 +506,7 @@ mod tests {
|
||||
#[test]
|
||||
fn edit_square() {
|
||||
let builder = GenerateImageRequestBuilder {
|
||||
aspect_ratio: Some(CommonAspectRatio::SquareHd),
|
||||
aspect_ratio: Some(RouterAspectRatio::SquareHd),
|
||||
image_inputs: Some(ImageListRef::Urls(vec!["https://example.com/img.jpg".to_string()])),
|
||||
..base_builder()
|
||||
};
|
||||
|
||||
+52
-52
@@ -7,8 +7,8 @@ use fal_client::requests::api::image::text::nano_banana_pro_text_to_image::api::
|
||||
NanoBananaProTextToImageRequest, NanoBananaProTextToImageResolution,
|
||||
};
|
||||
|
||||
use crate::api::common_aspect_ratio::CommonAspectRatio;
|
||||
use crate::api::common_resolution::CommonResolution;
|
||||
use crate::api::router_aspect_ratio::RouterAspectRatio;
|
||||
use crate::api::router_resolution::RouterResolution;
|
||||
use crate::api::image_list_ref::ImageListRef;
|
||||
use crate::client::request_mismatch_mitigation_strategy::RequestMismatchMitigationStrategy;
|
||||
use crate::errors::artcraft_router_error::ArtcraftRouterError;
|
||||
@@ -116,15 +116,15 @@ enum PlannedResolution {
|
||||
FourK,
|
||||
}
|
||||
|
||||
fn plan_resolution(resolution: Option<CommonResolution>) -> Option<PlannedResolution> {
|
||||
fn plan_resolution(resolution: Option<RouterResolution>) -> Option<PlannedResolution> {
|
||||
resolution.map(|r| match r {
|
||||
CommonResolution::HalfK | CommonResolution::FourEightyP | CommonResolution::SevenTwentyP
|
||||
| CommonResolution::OneK | CommonResolution::TenEightyP => PlannedResolution::OneK,
|
||||
CommonResolution::TwoK => PlannedResolution::TwoK,
|
||||
RouterResolution::HalfK | RouterResolution::FourEightyP | RouterResolution::SevenTwentyP
|
||||
| RouterResolution::OneK | RouterResolution::TenEightyP => PlannedResolution::OneK,
|
||||
RouterResolution::TwoK => PlannedResolution::TwoK,
|
||||
// 3K isn't natively supported on Fal nano_banana_pro; v1 downgrades to 2K
|
||||
// pricing (and TwoK resolution). Match v1 here so cost+behavior agree.
|
||||
CommonResolution::ThreeK => PlannedResolution::TwoK,
|
||||
CommonResolution::FourK => PlannedResolution::FourK,
|
||||
RouterResolution::ThreeK => PlannedResolution::TwoK,
|
||||
RouterResolution::FourK => PlannedResolution::FourK,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -147,44 +147,44 @@ fn to_edit_resolution(r: PlannedResolution) -> NanoBananaProEditImageResolution
|
||||
// ── Aspect ratio ──
|
||||
|
||||
fn plan_t2i_aspect_ratio(
|
||||
aspect_ratio: Option<CommonAspectRatio>,
|
||||
aspect_ratio: Option<RouterAspectRatio>,
|
||||
) -> Option<NanoBananaProTextToImageAspectRatio> {
|
||||
use NanoBananaProTextToImageAspectRatio as T;
|
||||
aspect_ratio.and_then(|ar| match ar {
|
||||
CommonAspectRatio::Square | CommonAspectRatio::SquareHd => Some(T::OneByOne),
|
||||
CommonAspectRatio::WideFiveByFour => Some(T::FiveByFour),
|
||||
CommonAspectRatio::WideFourByThree => Some(T::FourByThree),
|
||||
CommonAspectRatio::WideThreeByTwo | CommonAspectRatio::Wide => Some(T::ThreeByTwo),
|
||||
CommonAspectRatio::WideSixteenByNine => Some(T::SixteenByNine),
|
||||
CommonAspectRatio::WideTwentyOneByNine => Some(T::TwentyOneByNine),
|
||||
CommonAspectRatio::TallFourByFive => Some(T::FourByFive),
|
||||
CommonAspectRatio::TallThreeByFour => Some(T::ThreeByFour),
|
||||
CommonAspectRatio::TallTwoByThree | CommonAspectRatio::Tall => Some(T::TwoByThree),
|
||||
CommonAspectRatio::TallNineBySixteen => Some(T::NineBySixteen),
|
||||
CommonAspectRatio::TallNineByTwentyOne => Some(T::NineBySixteen), // nearest match
|
||||
CommonAspectRatio::Auto | CommonAspectRatio::Auto2k
|
||||
| CommonAspectRatio::Auto3k | CommonAspectRatio::Auto4k => None,
|
||||
RouterAspectRatio::Square | RouterAspectRatio::SquareHd => Some(T::OneByOne),
|
||||
RouterAspectRatio::WideFiveByFour => Some(T::FiveByFour),
|
||||
RouterAspectRatio::WideFourByThree => Some(T::FourByThree),
|
||||
RouterAspectRatio::WideThreeByTwo | RouterAspectRatio::Wide => Some(T::ThreeByTwo),
|
||||
RouterAspectRatio::WideSixteenByNine => Some(T::SixteenByNine),
|
||||
RouterAspectRatio::WideTwentyOneByNine => Some(T::TwentyOneByNine),
|
||||
RouterAspectRatio::TallFourByFive => Some(T::FourByFive),
|
||||
RouterAspectRatio::TallThreeByFour => Some(T::ThreeByFour),
|
||||
RouterAspectRatio::TallTwoByThree | RouterAspectRatio::Tall => Some(T::TwoByThree),
|
||||
RouterAspectRatio::TallNineBySixteen => Some(T::NineBySixteen),
|
||||
RouterAspectRatio::TallNineByTwentyOne => Some(T::NineBySixteen), // nearest match
|
||||
RouterAspectRatio::Auto | RouterAspectRatio::Auto2k
|
||||
| RouterAspectRatio::Auto3k | RouterAspectRatio::Auto4k => None,
|
||||
})
|
||||
}
|
||||
|
||||
fn plan_edit_aspect_ratio(
|
||||
aspect_ratio: Option<CommonAspectRatio>,
|
||||
aspect_ratio: Option<RouterAspectRatio>,
|
||||
) -> Option<NanoBananaProEditImageAspectRatio> {
|
||||
use NanoBananaProEditImageAspectRatio as E;
|
||||
aspect_ratio.map(|ar| match ar {
|
||||
CommonAspectRatio::Auto | CommonAspectRatio::Auto2k
|
||||
| CommonAspectRatio::Auto3k | CommonAspectRatio::Auto4k => E::Auto,
|
||||
CommonAspectRatio::Square | CommonAspectRatio::SquareHd => E::OneByOne,
|
||||
CommonAspectRatio::WideFiveByFour => E::FiveByFour,
|
||||
CommonAspectRatio::WideFourByThree => E::FourByThree,
|
||||
CommonAspectRatio::WideThreeByTwo | CommonAspectRatio::Wide => E::ThreeByTwo,
|
||||
CommonAspectRatio::WideSixteenByNine => E::SixteenByNine,
|
||||
CommonAspectRatio::WideTwentyOneByNine => E::TwentyOneByNine,
|
||||
CommonAspectRatio::TallFourByFive => E::FourByFive,
|
||||
CommonAspectRatio::TallThreeByFour => E::ThreeByFour,
|
||||
CommonAspectRatio::TallTwoByThree | CommonAspectRatio::Tall => E::TwoByThree,
|
||||
CommonAspectRatio::TallNineBySixteen => E::NineBySixteen,
|
||||
CommonAspectRatio::TallNineByTwentyOne => E::NineBySixteen, // nearest match
|
||||
RouterAspectRatio::Auto | RouterAspectRatio::Auto2k
|
||||
| RouterAspectRatio::Auto3k | RouterAspectRatio::Auto4k => E::Auto,
|
||||
RouterAspectRatio::Square | RouterAspectRatio::SquareHd => E::OneByOne,
|
||||
RouterAspectRatio::WideFiveByFour => E::FiveByFour,
|
||||
RouterAspectRatio::WideFourByThree => E::FourByThree,
|
||||
RouterAspectRatio::WideThreeByTwo | RouterAspectRatio::Wide => E::ThreeByTwo,
|
||||
RouterAspectRatio::WideSixteenByNine => E::SixteenByNine,
|
||||
RouterAspectRatio::WideTwentyOneByNine => E::TwentyOneByNine,
|
||||
RouterAspectRatio::TallFourByFive => E::FourByFive,
|
||||
RouterAspectRatio::TallThreeByFour => E::ThreeByFour,
|
||||
RouterAspectRatio::TallTwoByThree | RouterAspectRatio::Tall => E::TwoByThree,
|
||||
RouterAspectRatio::TallNineBySixteen => E::NineBySixteen,
|
||||
RouterAspectRatio::TallNineByTwentyOne => E::NineBySixteen, // nearest match
|
||||
})
|
||||
}
|
||||
|
||||
@@ -205,13 +205,13 @@ fn resolve_image_urls(
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::api::common_image_model::CommonImageModel;
|
||||
use crate::api::provider::Provider;
|
||||
use crate::api::router_image_model::RouterImageModel;
|
||||
use crate::api::router_provider::RouterProvider;
|
||||
|
||||
fn base_builder() -> GenerateImageRequestBuilder {
|
||||
GenerateImageRequestBuilder {
|
||||
model: CommonImageModel::NanoBananaPro,
|
||||
provider: Provider::Fal,
|
||||
model: RouterImageModel::NanoBananaPro,
|
||||
provider: RouterProvider::Fal,
|
||||
prompt: Some("a cat in space".to_string()),
|
||||
image_inputs: None,
|
||||
resolution: None,
|
||||
@@ -368,7 +368,7 @@ mod tests {
|
||||
#[test]
|
||||
fn one_k_maps_to_one_k() {
|
||||
let builder = GenerateImageRequestBuilder {
|
||||
resolution: Some(CommonResolution::OneK),
|
||||
resolution: Some(RouterResolution::OneK),
|
||||
..base_builder()
|
||||
};
|
||||
let req = unwrap_t2i(build_fal_nano_banana_pro(builder));
|
||||
@@ -378,7 +378,7 @@ mod tests {
|
||||
#[test]
|
||||
fn two_k_maps_to_two_k() {
|
||||
let builder = GenerateImageRequestBuilder {
|
||||
resolution: Some(CommonResolution::TwoK),
|
||||
resolution: Some(RouterResolution::TwoK),
|
||||
..base_builder()
|
||||
};
|
||||
let req = unwrap_t2i(build_fal_nano_banana_pro(builder));
|
||||
@@ -388,7 +388,7 @@ mod tests {
|
||||
#[test]
|
||||
fn four_k_maps_to_four_k() {
|
||||
let builder = GenerateImageRequestBuilder {
|
||||
resolution: Some(CommonResolution::FourK),
|
||||
resolution: Some(RouterResolution::FourK),
|
||||
..base_builder()
|
||||
};
|
||||
let req = unwrap_t2i(build_fal_nano_banana_pro(builder));
|
||||
@@ -399,7 +399,7 @@ mod tests {
|
||||
fn three_k_rounds_down_to_two_k() {
|
||||
// Match v1's downgrade behavior: 3K → 2K (cheaper, no 3K native support).
|
||||
let builder = GenerateImageRequestBuilder {
|
||||
resolution: Some(CommonResolution::ThreeK),
|
||||
resolution: Some(RouterResolution::ThreeK),
|
||||
..base_builder()
|
||||
};
|
||||
let req = unwrap_t2i(build_fal_nano_banana_pro(builder));
|
||||
@@ -409,7 +409,7 @@ mod tests {
|
||||
#[test]
|
||||
fn half_k_rounds_to_one_k() {
|
||||
let builder = GenerateImageRequestBuilder {
|
||||
resolution: Some(CommonResolution::HalfK),
|
||||
resolution: Some(RouterResolution::HalfK),
|
||||
..base_builder()
|
||||
};
|
||||
let req = unwrap_t2i(build_fal_nano_banana_pro(builder));
|
||||
@@ -420,7 +420,7 @@ mod tests {
|
||||
fn edit_mode_resolution() {
|
||||
let builder = GenerateImageRequestBuilder {
|
||||
image_inputs: Some(ImageListRef::Urls(vec!["https://example.com/img.jpg".to_string()])),
|
||||
resolution: Some(CommonResolution::FourK),
|
||||
resolution: Some(RouterResolution::FourK),
|
||||
..base_builder()
|
||||
};
|
||||
let req = unwrap_edit(build_fal_nano_banana_pro(builder));
|
||||
@@ -442,7 +442,7 @@ mod tests {
|
||||
#[test]
|
||||
fn square_maps_to_one_by_one() {
|
||||
let builder = GenerateImageRequestBuilder {
|
||||
aspect_ratio: Some(CommonAspectRatio::Square),
|
||||
aspect_ratio: Some(RouterAspectRatio::Square),
|
||||
..base_builder()
|
||||
};
|
||||
let req = unwrap_t2i(build_fal_nano_banana_pro(builder));
|
||||
@@ -452,7 +452,7 @@ mod tests {
|
||||
#[test]
|
||||
fn wide_sixteen_by_nine() {
|
||||
let builder = GenerateImageRequestBuilder {
|
||||
aspect_ratio: Some(CommonAspectRatio::WideSixteenByNine),
|
||||
aspect_ratio: Some(RouterAspectRatio::WideSixteenByNine),
|
||||
..base_builder()
|
||||
};
|
||||
let req = unwrap_t2i(build_fal_nano_banana_pro(builder));
|
||||
@@ -462,7 +462,7 @@ mod tests {
|
||||
#[test]
|
||||
fn tall_nine_by_sixteen() {
|
||||
let builder = GenerateImageRequestBuilder {
|
||||
aspect_ratio: Some(CommonAspectRatio::TallNineBySixteen),
|
||||
aspect_ratio: Some(RouterAspectRatio::TallNineBySixteen),
|
||||
..base_builder()
|
||||
};
|
||||
let req = unwrap_t2i(build_fal_nano_banana_pro(builder));
|
||||
@@ -472,7 +472,7 @@ mod tests {
|
||||
#[test]
|
||||
fn auto_yields_none_for_t2i() {
|
||||
let builder = GenerateImageRequestBuilder {
|
||||
aspect_ratio: Some(CommonAspectRatio::Auto),
|
||||
aspect_ratio: Some(RouterAspectRatio::Auto),
|
||||
..base_builder()
|
||||
};
|
||||
let req = unwrap_t2i(build_fal_nano_banana_pro(builder));
|
||||
@@ -482,7 +482,7 @@ mod tests {
|
||||
#[test]
|
||||
fn auto_yields_auto_for_edit() {
|
||||
let builder = GenerateImageRequestBuilder {
|
||||
aspect_ratio: Some(CommonAspectRatio::Auto),
|
||||
aspect_ratio: Some(RouterAspectRatio::Auto),
|
||||
image_inputs: Some(ImageListRef::Urls(vec!["https://example.com/img.jpg".to_string()])),
|
||||
..base_builder()
|
||||
};
|
||||
@@ -493,7 +493,7 @@ mod tests {
|
||||
#[test]
|
||||
fn edit_square() {
|
||||
let builder = GenerateImageRequestBuilder {
|
||||
aspect_ratio: Some(CommonAspectRatio::SquareHd),
|
||||
aspect_ratio: Some(RouterAspectRatio::SquareHd),
|
||||
image_inputs: Some(ImageListRef::Urls(vec!["https://example.com/img.jpg".to_string()])),
|
||||
..base_builder()
|
||||
};
|
||||
|
||||
+16
-16
@@ -3,7 +3,7 @@ use fal_client::requests::webhook::image::angle::enqueue_qwen_edit_2511_edit_ima
|
||||
EnqueueQwenEdit2511EditImageAngleRequest,
|
||||
};
|
||||
|
||||
use crate::api::common_aspect_ratio::CommonAspectRatio;
|
||||
use crate::api::router_aspect_ratio::RouterAspectRatio;
|
||||
use crate::api::image_list_ref::ImageListRef;
|
||||
use crate::client::request_mismatch_mitigation_strategy::RequestMismatchMitigationStrategy;
|
||||
use crate::errors::artcraft_router_error::ArtcraftRouterError;
|
||||
@@ -80,26 +80,26 @@ fn plan_num_images(
|
||||
}
|
||||
|
||||
fn plan_image_size(
|
||||
aspect_ratio: Option<CommonAspectRatio>,
|
||||
aspect_ratio: Option<RouterAspectRatio>,
|
||||
strategy: RequestMismatchMitigationStrategy,
|
||||
) -> Result<Option<EnqueueQwenEdit2511AngleImageSize>, ArtcraftRouterError> {
|
||||
use EnqueueQwenEdit2511AngleImageSize as S;
|
||||
match aspect_ratio {
|
||||
None => Ok(None),
|
||||
|
||||
Some(CommonAspectRatio::Auto)
|
||||
| Some(CommonAspectRatio::Auto2k)
|
||||
| Some(CommonAspectRatio::Auto3k)
|
||||
| Some(CommonAspectRatio::Auto4k) => Ok(Some(S::SquareHd)),
|
||||
Some(RouterAspectRatio::Auto)
|
||||
| Some(RouterAspectRatio::Auto2k)
|
||||
| Some(RouterAspectRatio::Auto3k)
|
||||
| Some(RouterAspectRatio::Auto4k) => Ok(Some(S::SquareHd)),
|
||||
|
||||
Some(CommonAspectRatio::Square) => Ok(Some(S::Square)),
|
||||
Some(CommonAspectRatio::SquareHd) => Ok(Some(S::SquareHd)),
|
||||
Some(RouterAspectRatio::Square) => Ok(Some(S::Square)),
|
||||
Some(RouterAspectRatio::SquareHd) => Ok(Some(S::SquareHd)),
|
||||
|
||||
Some(CommonAspectRatio::Wide) | Some(CommonAspectRatio::WideSixteenByNine) => Ok(Some(S::LandscapeSixteenNine)),
|
||||
Some(CommonAspectRatio::WideFourByThree) => Ok(Some(S::LandscapeFourThree)),
|
||||
Some(RouterAspectRatio::Wide) | Some(RouterAspectRatio::WideSixteenByNine) => Ok(Some(S::LandscapeSixteenNine)),
|
||||
Some(RouterAspectRatio::WideFourByThree) => Ok(Some(S::LandscapeFourThree)),
|
||||
|
||||
Some(CommonAspectRatio::Tall) | Some(CommonAspectRatio::TallNineBySixteen) => Ok(Some(S::PortraitSixteenNine)),
|
||||
Some(CommonAspectRatio::TallThreeByFour) => Ok(Some(S::PortraitFourThree)),
|
||||
Some(RouterAspectRatio::Tall) | Some(RouterAspectRatio::TallNineBySixteen) => Ok(Some(S::PortraitSixteenNine)),
|
||||
Some(RouterAspectRatio::TallThreeByFour) => Ok(Some(S::PortraitFourThree)),
|
||||
|
||||
Some(unsupported) => match strategy {
|
||||
RequestMismatchMitigationStrategy::ErrorOut => {
|
||||
@@ -116,13 +116,13 @@ fn plan_image_size(
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::api::common_image_model::CommonImageModel;
|
||||
use crate::api::provider::Provider;
|
||||
use crate::api::router_image_model::RouterImageModel;
|
||||
use crate::api::router_provider::RouterProvider;
|
||||
|
||||
fn base() -> GenerateImageRequestBuilder {
|
||||
GenerateImageRequestBuilder {
|
||||
model: CommonImageModel::QwenEdit2511Angles,
|
||||
provider: Provider::Fal,
|
||||
model: RouterImageModel::QwenEdit2511Angles,
|
||||
provider: RouterProvider::Fal,
|
||||
prompt: Some("test".to_string()),
|
||||
image_inputs: Some(ImageListRef::Urls(vec!["https://example.com/x.jpg".to_string()])),
|
||||
resolution: None,
|
||||
|
||||
+26
-26
@@ -7,7 +7,7 @@ use fal_client::requests::webhook::image::text::enqueue_bytedance_seedream_v4_te
|
||||
EnqueueBytedanceSeedreamV4TextToImageSize,
|
||||
};
|
||||
|
||||
use crate::api::common_aspect_ratio::CommonAspectRatio;
|
||||
use crate::api::router_aspect_ratio::RouterAspectRatio;
|
||||
use crate::api::image_list_ref::ImageListRef;
|
||||
use crate::client::request_mismatch_mitigation_strategy::RequestMismatchMitigationStrategy;
|
||||
use crate::errors::artcraft_router_error::ArtcraftRouterError;
|
||||
@@ -118,7 +118,7 @@ enum PlannedImageSize {
|
||||
}
|
||||
|
||||
fn plan_image_size(
|
||||
aspect_ratio: Option<CommonAspectRatio>,
|
||||
aspect_ratio: Option<RouterAspectRatio>,
|
||||
is_edit_mode: bool,
|
||||
strategy: RequestMismatchMitigationStrategy,
|
||||
) -> Result<Option<PlannedImageSize>, ArtcraftRouterError> {
|
||||
@@ -126,21 +126,21 @@ fn plan_image_size(
|
||||
match aspect_ratio {
|
||||
None => Ok(None),
|
||||
|
||||
Some(CommonAspectRatio::Auto) => {
|
||||
Some(RouterAspectRatio::Auto) => {
|
||||
if is_edit_mode { Ok(Some(S::Auto)) } else { Ok(Some(S::Square)) }
|
||||
}
|
||||
Some(CommonAspectRatio::Auto2k) | Some(CommonAspectRatio::Auto3k) => Ok(Some(S::Auto2k)),
|
||||
Some(CommonAspectRatio::Auto4k) => Ok(Some(S::Auto4k)),
|
||||
Some(RouterAspectRatio::Auto2k) | Some(RouterAspectRatio::Auto3k) => Ok(Some(S::Auto2k)),
|
||||
Some(RouterAspectRatio::Auto4k) => Ok(Some(S::Auto4k)),
|
||||
|
||||
Some(CommonAspectRatio::Square) => Ok(Some(S::Square)),
|
||||
Some(CommonAspectRatio::SquareHd) => Ok(Some(S::SquareHd)),
|
||||
Some(RouterAspectRatio::Square) => Ok(Some(S::Square)),
|
||||
Some(RouterAspectRatio::SquareHd) => Ok(Some(S::SquareHd)),
|
||||
|
||||
Some(CommonAspectRatio::Wide) | Some(CommonAspectRatio::WideSixteenByNine) => Ok(Some(S::LandscapeSixteenNine)),
|
||||
Some(CommonAspectRatio::WideFourByThree) => Ok(Some(S::LandscapeFourThree)),
|
||||
Some(RouterAspectRatio::Wide) | Some(RouterAspectRatio::WideSixteenByNine) => Ok(Some(S::LandscapeSixteenNine)),
|
||||
Some(RouterAspectRatio::WideFourByThree) => Ok(Some(S::LandscapeFourThree)),
|
||||
|
||||
Some(unsupported @ CommonAspectRatio::WideFiveByFour)
|
||||
| Some(unsupported @ CommonAspectRatio::WideThreeByTwo)
|
||||
| Some(unsupported @ CommonAspectRatio::WideTwentyOneByNine) => match strategy {
|
||||
Some(unsupported @ RouterAspectRatio::WideFiveByFour)
|
||||
| Some(unsupported @ RouterAspectRatio::WideThreeByTwo)
|
||||
| Some(unsupported @ RouterAspectRatio::WideTwentyOneByNine) => match strategy {
|
||||
RequestMismatchMitigationStrategy::ErrorOut => {
|
||||
Err(ArtcraftRouterError::Client(ClientError::ModelDoesNotSupportOption {
|
||||
field: "aspect_ratio",
|
||||
@@ -150,12 +150,12 @@ fn plan_image_size(
|
||||
_ => Ok(Some(S::LandscapeSixteenNine)),
|
||||
},
|
||||
|
||||
Some(CommonAspectRatio::Tall) | Some(CommonAspectRatio::TallNineBySixteen) => Ok(Some(S::PortraitSixteenNine)),
|
||||
Some(CommonAspectRatio::TallThreeByFour) => Ok(Some(S::PortraitFourThree)),
|
||||
Some(RouterAspectRatio::Tall) | Some(RouterAspectRatio::TallNineBySixteen) => Ok(Some(S::PortraitSixteenNine)),
|
||||
Some(RouterAspectRatio::TallThreeByFour) => Ok(Some(S::PortraitFourThree)),
|
||||
|
||||
Some(unsupported @ CommonAspectRatio::TallFourByFive)
|
||||
| Some(unsupported @ CommonAspectRatio::TallTwoByThree)
|
||||
| Some(unsupported @ CommonAspectRatio::TallNineByTwentyOne) => match strategy {
|
||||
Some(unsupported @ RouterAspectRatio::TallFourByFive)
|
||||
| Some(unsupported @ RouterAspectRatio::TallTwoByThree)
|
||||
| Some(unsupported @ RouterAspectRatio::TallNineByTwentyOne) => match strategy {
|
||||
RequestMismatchMitigationStrategy::ErrorOut => {
|
||||
Err(ArtcraftRouterError::Client(ClientError::ModelDoesNotSupportOption {
|
||||
field: "aspect_ratio",
|
||||
@@ -214,13 +214,13 @@ fn resolve_image_list_ref(
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::api::common_image_model::CommonImageModel;
|
||||
use crate::api::provider::Provider;
|
||||
use crate::api::router_image_model::RouterImageModel;
|
||||
use crate::api::router_provider::RouterProvider;
|
||||
|
||||
fn base_builder() -> GenerateImageRequestBuilder {
|
||||
GenerateImageRequestBuilder {
|
||||
model: CommonImageModel::Seedream4,
|
||||
provider: Provider::Fal,
|
||||
model: RouterImageModel::Seedream4,
|
||||
provider: RouterProvider::Fal,
|
||||
prompt: Some("a cat in space".to_string()),
|
||||
image_inputs: None,
|
||||
resolution: None,
|
||||
@@ -291,7 +291,7 @@ mod tests {
|
||||
#[test]
|
||||
fn t2i_auto_maps_to_square() {
|
||||
let builder = GenerateImageRequestBuilder {
|
||||
aspect_ratio: Some(CommonAspectRatio::Auto),
|
||||
aspect_ratio: Some(RouterAspectRatio::Auto),
|
||||
..base_builder()
|
||||
};
|
||||
let req = unwrap_t2i(build_fal_seedream_4(builder));
|
||||
@@ -302,7 +302,7 @@ mod tests {
|
||||
fn edit_auto_stays_auto() {
|
||||
let builder = GenerateImageRequestBuilder {
|
||||
image_inputs: Some(ImageListRef::Urls(vec!["https://example.com/img.jpg".to_string()])),
|
||||
aspect_ratio: Some(CommonAspectRatio::Auto),
|
||||
aspect_ratio: Some(RouterAspectRatio::Auto),
|
||||
..base_builder()
|
||||
};
|
||||
let req = unwrap_edit(build_fal_seedream_4(builder));
|
||||
@@ -312,7 +312,7 @@ mod tests {
|
||||
#[test]
|
||||
fn auto4k_maps_to_auto4k() {
|
||||
let builder = GenerateImageRequestBuilder {
|
||||
aspect_ratio: Some(CommonAspectRatio::Auto4k),
|
||||
aspect_ratio: Some(RouterAspectRatio::Auto4k),
|
||||
..base_builder()
|
||||
};
|
||||
let req = unwrap_t2i(build_fal_seedream_4(builder));
|
||||
@@ -322,7 +322,7 @@ mod tests {
|
||||
#[test]
|
||||
fn wide_21_9_errors_out() {
|
||||
let builder = GenerateImageRequestBuilder {
|
||||
aspect_ratio: Some(CommonAspectRatio::WideTwentyOneByNine),
|
||||
aspect_ratio: Some(RouterAspectRatio::WideTwentyOneByNine),
|
||||
..base_builder()
|
||||
};
|
||||
assert!(matches!(
|
||||
@@ -334,7 +334,7 @@ mod tests {
|
||||
#[test]
|
||||
fn wide_21_9_falls_back_with_upgrade() {
|
||||
let builder = GenerateImageRequestBuilder {
|
||||
aspect_ratio: Some(CommonAspectRatio::WideTwentyOneByNine),
|
||||
aspect_ratio: Some(RouterAspectRatio::WideTwentyOneByNine),
|
||||
request_mismatch_mitigation_strategy: RequestMismatchMitigationStrategy::PayMoreUpgrade,
|
||||
..base_builder()
|
||||
};
|
||||
|
||||
+22
-22
@@ -7,7 +7,7 @@ use fal_client::requests::webhook::image::text::enqueue_bytedance_seedream_v4p5_
|
||||
EnqueueBytedanceSeedreamV4p5TextToImageSize,
|
||||
};
|
||||
|
||||
use crate::api::common_aspect_ratio::CommonAspectRatio;
|
||||
use crate::api::router_aspect_ratio::RouterAspectRatio;
|
||||
use crate::api::image_list_ref::ImageListRef;
|
||||
use crate::client::request_mismatch_mitigation_strategy::RequestMismatchMitigationStrategy;
|
||||
use crate::errors::artcraft_router_error::ArtcraftRouterError;
|
||||
@@ -119,7 +119,7 @@ enum PlannedImageSize {
|
||||
}
|
||||
|
||||
fn plan_image_size(
|
||||
aspect_ratio: Option<CommonAspectRatio>,
|
||||
aspect_ratio: Option<RouterAspectRatio>,
|
||||
strategy: RequestMismatchMitigationStrategy,
|
||||
) -> Result<Option<PlannedImageSize>, ArtcraftRouterError> {
|
||||
use PlannedImageSize as S;
|
||||
@@ -127,18 +127,18 @@ fn plan_image_size(
|
||||
None => Ok(None),
|
||||
|
||||
// No bare Auto for v4.5 — fall back to Auto2k.
|
||||
Some(CommonAspectRatio::Auto) | Some(CommonAspectRatio::Auto2k) | Some(CommonAspectRatio::Auto3k) => Ok(Some(S::Auto2k)),
|
||||
Some(CommonAspectRatio::Auto4k) => Ok(Some(S::Auto4k)),
|
||||
Some(RouterAspectRatio::Auto) | Some(RouterAspectRatio::Auto2k) | Some(RouterAspectRatio::Auto3k) => Ok(Some(S::Auto2k)),
|
||||
Some(RouterAspectRatio::Auto4k) => Ok(Some(S::Auto4k)),
|
||||
|
||||
Some(CommonAspectRatio::Square) => Ok(Some(S::Square)),
|
||||
Some(CommonAspectRatio::SquareHd) => Ok(Some(S::SquareHd)),
|
||||
Some(RouterAspectRatio::Square) => Ok(Some(S::Square)),
|
||||
Some(RouterAspectRatio::SquareHd) => Ok(Some(S::SquareHd)),
|
||||
|
||||
Some(CommonAspectRatio::Wide) | Some(CommonAspectRatio::WideSixteenByNine) => Ok(Some(S::LandscapeSixteenNine)),
|
||||
Some(CommonAspectRatio::WideFourByThree) => Ok(Some(S::LandscapeFourThree)),
|
||||
Some(RouterAspectRatio::Wide) | Some(RouterAspectRatio::WideSixteenByNine) => Ok(Some(S::LandscapeSixteenNine)),
|
||||
Some(RouterAspectRatio::WideFourByThree) => Ok(Some(S::LandscapeFourThree)),
|
||||
|
||||
Some(unsupported @ CommonAspectRatio::WideFiveByFour)
|
||||
| Some(unsupported @ CommonAspectRatio::WideThreeByTwo)
|
||||
| Some(unsupported @ CommonAspectRatio::WideTwentyOneByNine) => match strategy {
|
||||
Some(unsupported @ RouterAspectRatio::WideFiveByFour)
|
||||
| Some(unsupported @ RouterAspectRatio::WideThreeByTwo)
|
||||
| Some(unsupported @ RouterAspectRatio::WideTwentyOneByNine) => match strategy {
|
||||
RequestMismatchMitigationStrategy::ErrorOut => {
|
||||
Err(ArtcraftRouterError::Client(ClientError::ModelDoesNotSupportOption {
|
||||
field: "aspect_ratio",
|
||||
@@ -148,12 +148,12 @@ fn plan_image_size(
|
||||
_ => Ok(Some(S::LandscapeSixteenNine)),
|
||||
},
|
||||
|
||||
Some(CommonAspectRatio::Tall) | Some(CommonAspectRatio::TallNineBySixteen) => Ok(Some(S::PortraitSixteenNine)),
|
||||
Some(CommonAspectRatio::TallThreeByFour) => Ok(Some(S::PortraitFourThree)),
|
||||
Some(RouterAspectRatio::Tall) | Some(RouterAspectRatio::TallNineBySixteen) => Ok(Some(S::PortraitSixteenNine)),
|
||||
Some(RouterAspectRatio::TallThreeByFour) => Ok(Some(S::PortraitFourThree)),
|
||||
|
||||
Some(unsupported @ CommonAspectRatio::TallFourByFive)
|
||||
| Some(unsupported @ CommonAspectRatio::TallTwoByThree)
|
||||
| Some(unsupported @ CommonAspectRatio::TallNineByTwentyOne) => match strategy {
|
||||
Some(unsupported @ RouterAspectRatio::TallFourByFive)
|
||||
| Some(unsupported @ RouterAspectRatio::TallTwoByThree)
|
||||
| Some(unsupported @ RouterAspectRatio::TallNineByTwentyOne) => match strategy {
|
||||
RequestMismatchMitigationStrategy::ErrorOut => {
|
||||
Err(ArtcraftRouterError::Client(ClientError::ModelDoesNotSupportOption {
|
||||
field: "aspect_ratio",
|
||||
@@ -210,13 +210,13 @@ fn resolve_image_list_ref(
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::api::common_image_model::CommonImageModel;
|
||||
use crate::api::provider::Provider;
|
||||
use crate::api::router_image_model::RouterImageModel;
|
||||
use crate::api::router_provider::RouterProvider;
|
||||
|
||||
fn base_builder() -> GenerateImageRequestBuilder {
|
||||
GenerateImageRequestBuilder {
|
||||
model: CommonImageModel::Seedream4p5,
|
||||
provider: Provider::Fal,
|
||||
model: RouterImageModel::Seedream4p5,
|
||||
provider: RouterProvider::Fal,
|
||||
prompt: Some("a cat in space".to_string()),
|
||||
image_inputs: None,
|
||||
resolution: None,
|
||||
@@ -243,7 +243,7 @@ mod tests {
|
||||
fn auto_falls_back_to_auto2k() {
|
||||
// Seedream 4.5 has no bare Auto — request with Auto should map to Auto2k.
|
||||
let builder = GenerateImageRequestBuilder {
|
||||
aspect_ratio: Some(CommonAspectRatio::Auto),
|
||||
aspect_ratio: Some(RouterAspectRatio::Auto),
|
||||
..base_builder()
|
||||
};
|
||||
let req = unwrap_t2i(build_fal_seedream_4p5(builder));
|
||||
@@ -253,7 +253,7 @@ mod tests {
|
||||
#[test]
|
||||
fn auto4k_stays_auto4k() {
|
||||
let builder = GenerateImageRequestBuilder {
|
||||
aspect_ratio: Some(CommonAspectRatio::Auto4k),
|
||||
aspect_ratio: Some(RouterAspectRatio::Auto4k),
|
||||
..base_builder()
|
||||
};
|
||||
let req = unwrap_t2i(build_fal_seedream_4p5(builder));
|
||||
|
||||
+29
-29
@@ -7,8 +7,8 @@ use fal_client::requests::webhook::image::text::enqueue_bytedance_seedream_v5_li
|
||||
EnqueueBytedanceSeedreamV5LiteTextToImageSize,
|
||||
};
|
||||
|
||||
use crate::api::common_aspect_ratio::CommonAspectRatio;
|
||||
use crate::api::common_resolution::CommonResolution;
|
||||
use crate::api::router_aspect_ratio::RouterAspectRatio;
|
||||
use crate::api::router_resolution::RouterResolution;
|
||||
use crate::api::image_list_ref::ImageListRef;
|
||||
use crate::client::request_mismatch_mitigation_strategy::RequestMismatchMitigationStrategy;
|
||||
use crate::errors::artcraft_router_error::ArtcraftRouterError;
|
||||
@@ -120,8 +120,8 @@ enum PlannedImageSize {
|
||||
}
|
||||
|
||||
fn plan_image_size(
|
||||
aspect_ratio: Option<CommonAspectRatio>,
|
||||
resolution: Option<CommonResolution>,
|
||||
aspect_ratio: Option<RouterAspectRatio>,
|
||||
resolution: Option<RouterResolution>,
|
||||
strategy: RequestMismatchMitigationStrategy,
|
||||
) -> Result<Option<PlannedImageSize>, ArtcraftRouterError> {
|
||||
use PlannedImageSize as S;
|
||||
@@ -129,25 +129,25 @@ fn plan_image_size(
|
||||
// No aspect_ratio: use resolution as a hint for Auto sizes.
|
||||
// Seedream v5 lite has no 4K — clamp to 3K.
|
||||
None => match resolution {
|
||||
Some(CommonResolution::TwoK) => Ok(Some(S::Auto2k)),
|
||||
Some(CommonResolution::ThreeK) | Some(CommonResolution::FourK) => Ok(Some(S::Auto3k)),
|
||||
Some(RouterResolution::TwoK) => Ok(Some(S::Auto2k)),
|
||||
Some(RouterResolution::ThreeK) | Some(RouterResolution::FourK) => Ok(Some(S::Auto3k)),
|
||||
_ => Ok(None),
|
||||
},
|
||||
|
||||
Some(CommonAspectRatio::Auto) | Some(CommonAspectRatio::Auto2k) => Ok(Some(S::Auto2k)),
|
||||
Some(CommonAspectRatio::Auto3k) => Ok(Some(S::Auto3k)),
|
||||
Some(RouterAspectRatio::Auto) | Some(RouterAspectRatio::Auto2k) => Ok(Some(S::Auto2k)),
|
||||
Some(RouterAspectRatio::Auto3k) => Ok(Some(S::Auto3k)),
|
||||
// No 4K — fall back to 3K.
|
||||
Some(CommonAspectRatio::Auto4k) => Ok(Some(S::Auto3k)),
|
||||
Some(RouterAspectRatio::Auto4k) => Ok(Some(S::Auto3k)),
|
||||
|
||||
Some(CommonAspectRatio::Square) => Ok(Some(S::Square)),
|
||||
Some(CommonAspectRatio::SquareHd) => Ok(Some(S::SquareHd)),
|
||||
Some(RouterAspectRatio::Square) => Ok(Some(S::Square)),
|
||||
Some(RouterAspectRatio::SquareHd) => Ok(Some(S::SquareHd)),
|
||||
|
||||
Some(CommonAspectRatio::Wide) | Some(CommonAspectRatio::WideSixteenByNine) => Ok(Some(S::LandscapeSixteenNine)),
|
||||
Some(CommonAspectRatio::WideFourByThree) => Ok(Some(S::LandscapeFourThree)),
|
||||
Some(RouterAspectRatio::Wide) | Some(RouterAspectRatio::WideSixteenByNine) => Ok(Some(S::LandscapeSixteenNine)),
|
||||
Some(RouterAspectRatio::WideFourByThree) => Ok(Some(S::LandscapeFourThree)),
|
||||
|
||||
Some(unsupported @ CommonAspectRatio::WideFiveByFour)
|
||||
| Some(unsupported @ CommonAspectRatio::WideThreeByTwo)
|
||||
| Some(unsupported @ CommonAspectRatio::WideTwentyOneByNine) => match strategy {
|
||||
Some(unsupported @ RouterAspectRatio::WideFiveByFour)
|
||||
| Some(unsupported @ RouterAspectRatio::WideThreeByTwo)
|
||||
| Some(unsupported @ RouterAspectRatio::WideTwentyOneByNine) => match strategy {
|
||||
RequestMismatchMitigationStrategy::ErrorOut => {
|
||||
Err(ArtcraftRouterError::Client(ClientError::ModelDoesNotSupportOption {
|
||||
field: "aspect_ratio",
|
||||
@@ -157,12 +157,12 @@ fn plan_image_size(
|
||||
_ => Ok(Some(S::LandscapeSixteenNine)),
|
||||
},
|
||||
|
||||
Some(CommonAspectRatio::Tall) | Some(CommonAspectRatio::TallNineBySixteen) => Ok(Some(S::PortraitSixteenNine)),
|
||||
Some(CommonAspectRatio::TallThreeByFour) => Ok(Some(S::PortraitFourThree)),
|
||||
Some(RouterAspectRatio::Tall) | Some(RouterAspectRatio::TallNineBySixteen) => Ok(Some(S::PortraitSixteenNine)),
|
||||
Some(RouterAspectRatio::TallThreeByFour) => Ok(Some(S::PortraitFourThree)),
|
||||
|
||||
Some(unsupported @ CommonAspectRatio::TallFourByFive)
|
||||
| Some(unsupported @ CommonAspectRatio::TallTwoByThree)
|
||||
| Some(unsupported @ CommonAspectRatio::TallNineByTwentyOne) => match strategy {
|
||||
Some(unsupported @ RouterAspectRatio::TallFourByFive)
|
||||
| Some(unsupported @ RouterAspectRatio::TallTwoByThree)
|
||||
| Some(unsupported @ RouterAspectRatio::TallNineByTwentyOne) => match strategy {
|
||||
RequestMismatchMitigationStrategy::ErrorOut => {
|
||||
Err(ArtcraftRouterError::Client(ClientError::ModelDoesNotSupportOption {
|
||||
field: "aspect_ratio",
|
||||
@@ -219,13 +219,13 @@ fn resolve_image_list_ref(
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::api::common_image_model::CommonImageModel;
|
||||
use crate::api::provider::Provider;
|
||||
use crate::api::router_image_model::RouterImageModel;
|
||||
use crate::api::router_provider::RouterProvider;
|
||||
|
||||
fn base_builder() -> GenerateImageRequestBuilder {
|
||||
GenerateImageRequestBuilder {
|
||||
model: CommonImageModel::Seedream5Lite,
|
||||
provider: Provider::Fal,
|
||||
model: RouterImageModel::Seedream5Lite,
|
||||
provider: RouterProvider::Fal,
|
||||
prompt: Some("a cat in space".to_string()),
|
||||
image_inputs: None,
|
||||
resolution: None,
|
||||
@@ -251,7 +251,7 @@ mod tests {
|
||||
#[test]
|
||||
fn auto_maps_to_auto2k() {
|
||||
let builder = GenerateImageRequestBuilder {
|
||||
aspect_ratio: Some(CommonAspectRatio::Auto),
|
||||
aspect_ratio: Some(RouterAspectRatio::Auto),
|
||||
..base_builder()
|
||||
};
|
||||
let req = unwrap_t2i(build_fal_seedream_5_lite(builder));
|
||||
@@ -262,7 +262,7 @@ mod tests {
|
||||
fn auto4k_falls_back_to_auto3k() {
|
||||
// Seedream 5 Lite has no 4K — clamp to 3K.
|
||||
let builder = GenerateImageRequestBuilder {
|
||||
aspect_ratio: Some(CommonAspectRatio::Auto4k),
|
||||
aspect_ratio: Some(RouterAspectRatio::Auto4k),
|
||||
..base_builder()
|
||||
};
|
||||
let req = unwrap_t2i(build_fal_seedream_5_lite(builder));
|
||||
@@ -278,7 +278,7 @@ mod tests {
|
||||
#[test]
|
||||
fn resolution_two_k_triggers_auto2k_when_no_aspect() {
|
||||
let builder = GenerateImageRequestBuilder {
|
||||
resolution: Some(CommonResolution::TwoK),
|
||||
resolution: Some(RouterResolution::TwoK),
|
||||
..base_builder()
|
||||
};
|
||||
let req = unwrap_t2i(build_fal_seedream_5_lite(builder));
|
||||
@@ -288,7 +288,7 @@ mod tests {
|
||||
#[test]
|
||||
fn resolution_four_k_clamps_to_auto3k() {
|
||||
let builder = GenerateImageRequestBuilder {
|
||||
resolution: Some(CommonResolution::FourK),
|
||||
resolution: Some(RouterResolution::FourK),
|
||||
..base_builder()
|
||||
};
|
||||
let req = unwrap_t2i(build_fal_seedream_5_lite(builder));
|
||||
|
||||
+4
-4
@@ -28,16 +28,16 @@ pub(crate) fn estimate_splat_cost_artcraft_marble_0p1_mini(
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::api::common_splat_model::CommonSplatModel;
|
||||
use crate::api::provider::Provider;
|
||||
use crate::api::router_splat_model::RouterSplatModel;
|
||||
use crate::api::router_provider::RouterProvider;
|
||||
use crate::generate::generate_splat::generate_splat_request::GenerateSplatRequest;
|
||||
|
||||
use tokens::tokens::media_files::MediaFileToken;
|
||||
|
||||
fn estimate_usd_cents(prompt: Option<&str>, image_tokens: Option<Vec<MediaFileToken>>) -> u64 {
|
||||
let request = GenerateSplatRequest {
|
||||
model: CommonSplatModel::Marble0p1Mini,
|
||||
provider: Provider::Artcraft,
|
||||
model: RouterSplatModel::Marble0p1Mini,
|
||||
provider: RouterProvider::Artcraft,
|
||||
prompt: prompt.map(|s| s.to_string()),
|
||||
reference_images: image_tokens.map(crate::api::image_list_ref::ImageListRef::MediaFileTokens),
|
||||
idempotency_token: None,
|
||||
|
||||
+4
-4
@@ -28,16 +28,16 @@ pub(crate) fn estimate_splat_cost_artcraft_marble_0p1_plus(
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::api::common_splat_model::CommonSplatModel;
|
||||
use crate::api::provider::Provider;
|
||||
use crate::api::router_splat_model::RouterSplatModel;
|
||||
use crate::api::router_provider::RouterProvider;
|
||||
use crate::generate::generate_splat::generate_splat_request::GenerateSplatRequest;
|
||||
|
||||
use tokens::tokens::media_files::MediaFileToken;
|
||||
|
||||
fn estimate_usd_cents(prompt: Option<&str>, image_tokens: Option<Vec<MediaFileToken>>) -> u64 {
|
||||
let request = GenerateSplatRequest {
|
||||
model: CommonSplatModel::Marble0p1Plus,
|
||||
provider: Provider::Artcraft,
|
||||
model: RouterSplatModel::Marble0p1Plus,
|
||||
provider: RouterProvider::Artcraft,
|
||||
prompt: prompt.map(|s| s.to_string()),
|
||||
reference_images: image_tokens.map(crate::api::image_list_ref::ImageListRef::MediaFileTokens),
|
||||
idempotency_token: None,
|
||||
|
||||
+7
-7
@@ -1,6 +1,6 @@
|
||||
use crate::api::common_splat_model::CommonSplatModel;
|
||||
use crate::api::router_splat_model::RouterSplatModel;
|
||||
use crate::api::image_list_ref::ImageListRef;
|
||||
use crate::api::provider::Provider;
|
||||
use crate::api::router_provider::RouterProvider;
|
||||
use crate::errors::artcraft_router_error::ArtcraftRouterError;
|
||||
use crate::generate::generate_splat::plan::artcraft::plan_generate_splat_artcraft_marble_0p1_mini::plan_generate_splat_artcraft_marble_0p1_mini;
|
||||
use crate::generate::generate_splat::plan::artcraft::plan_generate_splat_artcraft_marble_0p1_plus::plan_generate_splat_artcraft_marble_0p1_plus;
|
||||
@@ -8,10 +8,10 @@ use crate::generate::generate_splat::splat_generation_plan::SplatGenerationPlan;
|
||||
|
||||
pub struct GenerateSplatRequest {
|
||||
/// Which model to use.
|
||||
pub model: CommonSplatModel,
|
||||
pub model: RouterSplatModel,
|
||||
|
||||
/// Which provider to use.
|
||||
pub provider: Provider,
|
||||
pub provider: RouterProvider,
|
||||
|
||||
/// The prompt for splat generation (optional).
|
||||
pub prompt: Option<String>,
|
||||
@@ -28,15 +28,15 @@ impl GenerateSplatRequest {
|
||||
/// Read the splat generation request, construct a plan, then yield a means to execute it.
|
||||
pub fn build(&self) -> Result<SplatGenerationPlan, ArtcraftRouterError> {
|
||||
match self.provider {
|
||||
Provider::Artcraft => self.build_artcraft(),
|
||||
RouterProvider::Artcraft => self.build_artcraft(),
|
||||
_ => self.unsupported_provider(),
|
||||
}
|
||||
}
|
||||
|
||||
fn build_artcraft(&self) -> Result<SplatGenerationPlan, ArtcraftRouterError> {
|
||||
match self.model {
|
||||
CommonSplatModel::Marble0p1Mini => plan_generate_splat_artcraft_marble_0p1_mini(self),
|
||||
CommonSplatModel::Marble0p1Plus => plan_generate_splat_artcraft_marble_0p1_plus(self),
|
||||
RouterSplatModel::Marble0p1Mini => plan_generate_splat_artcraft_marble_0p1_mini(self),
|
||||
RouterSplatModel::Marble0p1Plus => plan_generate_splat_artcraft_marble_0p1_plus(self),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+59
-59
@@ -1,11 +1,11 @@
|
||||
use crate::api::audio_list_ref::AudioListRef;
|
||||
use crate::api::character_list_ref::CharacterListRef;
|
||||
use crate::api::common_aspect_ratio::CommonAspectRatio;
|
||||
use crate::api::common_resolution::CommonResolution;
|
||||
use crate::api::common_video_model::CommonVideoModel;
|
||||
use crate::api::router_aspect_ratio::RouterAspectRatio;
|
||||
use crate::api::router_resolution::RouterResolution;
|
||||
use crate::api::router_video_model::RouterVideoModel;
|
||||
use crate::api::image_list_ref::ImageListRef;
|
||||
use crate::api::image_ref::ImageRef;
|
||||
use crate::api::provider::Provider;
|
||||
use crate::api::router_provider::RouterProvider;
|
||||
use crate::api::video_list_ref::VideoListRef;
|
||||
use crate::client::request_mismatch_mitigation_strategy::RequestMismatchMitigationStrategy;
|
||||
use crate::errors::artcraft_router_error::ArtcraftRouterError;
|
||||
@@ -59,15 +59,15 @@ use crate::generate::generate_video_v2::providers::fal::veo_3p1_fast::build::bui
|
||||
use crate::generate::generate_video_v2::providers::kinovi::seedance_2p0_fast::build::build_kinovi_seedance_2p0_fast;
|
||||
use crate::generate::generate_video_v2::video_generation_draft_or_request::VideoGenerationDraftOrRequest;
|
||||
|
||||
/// Provider-agnostic video generation request. Distilled by `build2()` into a
|
||||
/// RouterProvider-agnostic video generation request. Distilled by `build2()` into a
|
||||
/// `VideoGenerationDraftOrRequest` for the selected (provider, model) pair.
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct GenerateVideoRequestBuilder {
|
||||
/// Which model to use.
|
||||
pub model: CommonVideoModel,
|
||||
pub model: RouterVideoModel,
|
||||
|
||||
/// Which provider to use.
|
||||
pub provider: Provider,
|
||||
pub provider: RouterProvider,
|
||||
|
||||
/// The prompt for the video generation
|
||||
pub prompt: Option<String>,
|
||||
@@ -94,10 +94,10 @@ pub struct GenerateVideoRequestBuilder {
|
||||
pub reference_character_tokens: Option<CharacterListRef>,
|
||||
|
||||
/// The resolution to use
|
||||
pub resolution: Option<CommonResolution>,
|
||||
pub resolution: Option<RouterResolution>,
|
||||
|
||||
/// The aspect ratio to use
|
||||
pub aspect_ratio: Option<CommonAspectRatio>,
|
||||
pub aspect_ratio: Option<RouterAspectRatio>,
|
||||
|
||||
/// How many seconds to generate.
|
||||
pub duration_seconds: Option<u16>,
|
||||
@@ -122,8 +122,8 @@ pub struct GenerateVideoRequestBuilder {
|
||||
impl Default for GenerateVideoRequestBuilder {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
model: CommonVideoModel::Seedance2p0,
|
||||
provider: Provider::Artcraft,
|
||||
model: RouterVideoModel::Seedance2p0,
|
||||
provider: RouterProvider::Artcraft,
|
||||
request_mismatch_mitigation_strategy: RequestMismatchMitigationStrategy::PayMoreUpgrade,
|
||||
prompt: None,
|
||||
negative_prompt: None,
|
||||
@@ -148,58 +148,58 @@ impl GenerateVideoRequestBuilder {
|
||||
pub fn build2(self) -> Result<VideoGenerationDraftOrRequest, ArtcraftRouterError> {
|
||||
match (self.provider, self.model) {
|
||||
// Artcraft
|
||||
(Provider::Artcraft, CommonVideoModel::GrokImagineVideo) => build_artcraft_grok_imagine_video(self),
|
||||
(Provider::Artcraft, CommonVideoModel::HappyHorse1p0) => build_artcraft_happy_horse_1p0(self),
|
||||
(Provider::Artcraft, CommonVideoModel::Kling16Pro) => build_artcraft_kling_1_6_pro(self),
|
||||
(Provider::Artcraft, CommonVideoModel::Kling21Master) => build_artcraft_kling_2_1_master(self),
|
||||
(Provider::Artcraft, CommonVideoModel::Kling21Pro) => build_artcraft_kling_2_1_pro(self),
|
||||
(Provider::Artcraft, CommonVideoModel::Kling2p5TurboPro) => build_artcraft_kling_2_5_turbo_pro(self),
|
||||
(Provider::Artcraft, CommonVideoModel::Kling2p6Pro) => build_artcraft_kling_2_6_pro(self),
|
||||
(Provider::Artcraft, CommonVideoModel::Kling3p0Pro) => build_artcraft_kling_3p0_pro(self),
|
||||
(Provider::Artcraft, CommonVideoModel::Kling3p0Standard) => build_artcraft_kling_3p0_standard(self),
|
||||
(Provider::Artcraft, CommonVideoModel::Seedance2p0) => build_artcraft_seedance_2p0(self),
|
||||
(Provider::Artcraft, CommonVideoModel::Seedance2p0Fast) => build_artcraft_seedance_2p0_fast(self),
|
||||
(Provider::Artcraft, CommonVideoModel::Seedance2p0Ultra) => build_artcraft_seedance_2p0_u(self),
|
||||
(Provider::Artcraft, CommonVideoModel::Seedance2p0UltraFast) => build_artcraft_seedance_2p0_u_fast(self),
|
||||
(Provider::Artcraft, CommonVideoModel::Seedance2p0BytePlus) => build_artcraft_seedance_2p0_bp(self),
|
||||
(Provider::Artcraft, CommonVideoModel::Seedance2p0BytePlusFast) => build_artcraft_seedance_2p0_bp_fast(self),
|
||||
(Provider::Artcraft, CommonVideoModel::PreviewModel) => build_artcraft_preview_model(self),
|
||||
(Provider::Artcraft, CommonVideoModel::PreviewModelFast) => build_artcraft_preview_model_fast(self),
|
||||
(Provider::Artcraft, CommonVideoModel::Seedance10Lite) => build_artcraft_seedance_1p0_lite(self),
|
||||
(Provider::Artcraft, CommonVideoModel::Seedance1p5Pro) => build_artcraft_seedance_1p5_pro(self),
|
||||
(Provider::Artcraft, CommonVideoModel::Sora2) => build_artcraft_sora_2(self),
|
||||
(Provider::Artcraft, CommonVideoModel::Sora2Pro) => build_artcraft_sora_2_pro(self),
|
||||
(Provider::Artcraft, CommonVideoModel::Veo2) => build_artcraft_veo_2(self),
|
||||
(Provider::Artcraft, CommonVideoModel::Veo3) => build_artcraft_veo_3(self),
|
||||
(Provider::Artcraft, CommonVideoModel::Veo3Fast) => build_artcraft_veo_3_fast(self),
|
||||
(Provider::Artcraft, CommonVideoModel::Veo3p1) => build_artcraft_veo_3p1(self),
|
||||
(Provider::Artcraft, CommonVideoModel::Veo3p1Fast) => build_artcraft_veo_3p1_fast(self),
|
||||
(RouterProvider::Artcraft, RouterVideoModel::GrokImagineVideo) => build_artcraft_grok_imagine_video(self),
|
||||
(RouterProvider::Artcraft, RouterVideoModel::HappyHorse1p0) => build_artcraft_happy_horse_1p0(self),
|
||||
(RouterProvider::Artcraft, RouterVideoModel::Kling16Pro) => build_artcraft_kling_1_6_pro(self),
|
||||
(RouterProvider::Artcraft, RouterVideoModel::Kling21Master) => build_artcraft_kling_2_1_master(self),
|
||||
(RouterProvider::Artcraft, RouterVideoModel::Kling21Pro) => build_artcraft_kling_2_1_pro(self),
|
||||
(RouterProvider::Artcraft, RouterVideoModel::Kling2p5TurboPro) => build_artcraft_kling_2_5_turbo_pro(self),
|
||||
(RouterProvider::Artcraft, RouterVideoModel::Kling2p6Pro) => build_artcraft_kling_2_6_pro(self),
|
||||
(RouterProvider::Artcraft, RouterVideoModel::Kling3p0Pro) => build_artcraft_kling_3p0_pro(self),
|
||||
(RouterProvider::Artcraft, RouterVideoModel::Kling3p0Standard) => build_artcraft_kling_3p0_standard(self),
|
||||
(RouterProvider::Artcraft, RouterVideoModel::Seedance2p0) => build_artcraft_seedance_2p0(self),
|
||||
(RouterProvider::Artcraft, RouterVideoModel::Seedance2p0Fast) => build_artcraft_seedance_2p0_fast(self),
|
||||
(RouterProvider::Artcraft, RouterVideoModel::Seedance2p0Ultra) => build_artcraft_seedance_2p0_u(self),
|
||||
(RouterProvider::Artcraft, RouterVideoModel::Seedance2p0UltraFast) => build_artcraft_seedance_2p0_u_fast(self),
|
||||
(RouterProvider::Artcraft, RouterVideoModel::Seedance2p0BytePlus) => build_artcraft_seedance_2p0_bp(self),
|
||||
(RouterProvider::Artcraft, RouterVideoModel::Seedance2p0BytePlusFast) => build_artcraft_seedance_2p0_bp_fast(self),
|
||||
(RouterProvider::Artcraft, RouterVideoModel::PreviewModel) => build_artcraft_preview_model(self),
|
||||
(RouterProvider::Artcraft, RouterVideoModel::PreviewModelFast) => build_artcraft_preview_model_fast(self),
|
||||
(RouterProvider::Artcraft, RouterVideoModel::Seedance10Lite) => build_artcraft_seedance_1p0_lite(self),
|
||||
(RouterProvider::Artcraft, RouterVideoModel::Seedance1p5Pro) => build_artcraft_seedance_1p5_pro(self),
|
||||
(RouterProvider::Artcraft, RouterVideoModel::Sora2) => build_artcraft_sora_2(self),
|
||||
(RouterProvider::Artcraft, RouterVideoModel::Sora2Pro) => build_artcraft_sora_2_pro(self),
|
||||
(RouterProvider::Artcraft, RouterVideoModel::Veo2) => build_artcraft_veo_2(self),
|
||||
(RouterProvider::Artcraft, RouterVideoModel::Veo3) => build_artcraft_veo_3(self),
|
||||
(RouterProvider::Artcraft, RouterVideoModel::Veo3Fast) => build_artcraft_veo_3_fast(self),
|
||||
(RouterProvider::Artcraft, RouterVideoModel::Veo3p1) => build_artcraft_veo_3p1(self),
|
||||
(RouterProvider::Artcraft, RouterVideoModel::Veo3p1Fast) => build_artcraft_veo_3p1_fast(self),
|
||||
// Fal
|
||||
(Provider::Fal, CommonVideoModel::Kling16Pro) => build_fal_kling_1_6_pro(self),
|
||||
(Provider::Fal, CommonVideoModel::Kling21Master) => build_fal_kling_2_1_master(self),
|
||||
(Provider::Fal, CommonVideoModel::Kling21Pro) => build_fal_kling_2_1_pro(self),
|
||||
(Provider::Fal, CommonVideoModel::Kling2p5TurboPro) => build_fal_kling_2_5_turbo_pro(self),
|
||||
(Provider::Fal, CommonVideoModel::Kling2p6Pro) => build_fal_kling_2_6_pro(self),
|
||||
(Provider::Fal, CommonVideoModel::Kling3p0Pro) => build_fal_kling_3p0_pro(self),
|
||||
(Provider::Fal, CommonVideoModel::Kling3p0Standard) => build_fal_kling_3p0_standard(self),
|
||||
(Provider::Fal, CommonVideoModel::Seedance10Lite) => build_fal_seedance_1p0_lite(self),
|
||||
(Provider::Fal, CommonVideoModel::Seedance1p5Pro) => build_fal_seedance_1p5_pro(self),
|
||||
(Provider::Fal, CommonVideoModel::Sora2) => build_fal_sora_2(self),
|
||||
(Provider::Fal, CommonVideoModel::Sora2Pro) => build_fal_sora_2_pro(self),
|
||||
(Provider::Fal, CommonVideoModel::Veo2) => build_fal_veo_2(self),
|
||||
(Provider::Fal, CommonVideoModel::Veo3) => build_fal_veo_3(self),
|
||||
(Provider::Fal, CommonVideoModel::Veo3Fast) => build_fal_veo_3_fast(self),
|
||||
(Provider::Fal, CommonVideoModel::Veo3p1) => build_fal_veo_3p1(self),
|
||||
(Provider::Fal, CommonVideoModel::Veo3p1Fast) => build_fal_veo_3p1_fast(self),
|
||||
(RouterProvider::Fal, RouterVideoModel::Kling16Pro) => build_fal_kling_1_6_pro(self),
|
||||
(RouterProvider::Fal, RouterVideoModel::Kling21Master) => build_fal_kling_2_1_master(self),
|
||||
(RouterProvider::Fal, RouterVideoModel::Kling21Pro) => build_fal_kling_2_1_pro(self),
|
||||
(RouterProvider::Fal, RouterVideoModel::Kling2p5TurboPro) => build_fal_kling_2_5_turbo_pro(self),
|
||||
(RouterProvider::Fal, RouterVideoModel::Kling2p6Pro) => build_fal_kling_2_6_pro(self),
|
||||
(RouterProvider::Fal, RouterVideoModel::Kling3p0Pro) => build_fal_kling_3p0_pro(self),
|
||||
(RouterProvider::Fal, RouterVideoModel::Kling3p0Standard) => build_fal_kling_3p0_standard(self),
|
||||
(RouterProvider::Fal, RouterVideoModel::Seedance10Lite) => build_fal_seedance_1p0_lite(self),
|
||||
(RouterProvider::Fal, RouterVideoModel::Seedance1p5Pro) => build_fal_seedance_1p5_pro(self),
|
||||
(RouterProvider::Fal, RouterVideoModel::Sora2) => build_fal_sora_2(self),
|
||||
(RouterProvider::Fal, RouterVideoModel::Sora2Pro) => build_fal_sora_2_pro(self),
|
||||
(RouterProvider::Fal, RouterVideoModel::Veo2) => build_fal_veo_2(self),
|
||||
(RouterProvider::Fal, RouterVideoModel::Veo3) => build_fal_veo_3(self),
|
||||
(RouterProvider::Fal, RouterVideoModel::Veo3Fast) => build_fal_veo_3_fast(self),
|
||||
(RouterProvider::Fal, RouterVideoModel::Veo3p1) => build_fal_veo_3p1(self),
|
||||
(RouterProvider::Fal, RouterVideoModel::Veo3p1Fast) => build_fal_veo_3p1_fast(self),
|
||||
// GmiCloud
|
||||
(Provider::GmiCloud, CommonVideoModel::Seedance2p0Ultra) => build_gmicloud_seedance_2p0_u(self),
|
||||
(Provider::GmiCloud, CommonVideoModel::Seedance2p0UltraFast) => build_gmicloud_seedance_2p0_u_fast(self),
|
||||
(RouterProvider::GmiCloud, RouterVideoModel::Seedance2p0Ultra) => build_gmicloud_seedance_2p0_u(self),
|
||||
(RouterProvider::GmiCloud, RouterVideoModel::Seedance2p0UltraFast) => build_gmicloud_seedance_2p0_u_fast(self),
|
||||
// Grok
|
||||
(Provider::GrokApi, CommonVideoModel::GrokImagineVideo) => build_grok_api_grok_imagine_video(self),
|
||||
(RouterProvider::GrokApi, RouterVideoModel::GrokImagineVideo) => build_grok_api_grok_imagine_video(self),
|
||||
// Kinovi
|
||||
(Provider::Seedance2Pro, CommonVideoModel::HappyHorse1p0) => build_kinovi_happy_horse_1p0(self),
|
||||
(Provider::Seedance2Pro, CommonVideoModel::Seedance2p0) => build_kinovi_seedance_2p0(self),
|
||||
(Provider::Seedance2Pro, CommonVideoModel::Seedance2p0Fast) => build_kinovi_seedance_2p0_fast(self),
|
||||
(RouterProvider::Seedance2Pro, RouterVideoModel::HappyHorse1p0) => build_kinovi_happy_horse_1p0(self),
|
||||
(RouterProvider::Seedance2Pro, RouterVideoModel::Seedance2p0) => build_kinovi_seedance_2p0(self),
|
||||
(RouterProvider::Seedance2Pro, RouterVideoModel::Seedance2p0Fast) => build_kinovi_seedance_2p0_fast(self),
|
||||
_ => self.unsupported_provider_and_model(),
|
||||
}
|
||||
}
|
||||
|
||||
+29
-29
@@ -3,8 +3,8 @@ use enums::common::generation::common_aspect_ratio::CommonAspectRatio as CommonA
|
||||
use enums::common::generation::common_resolution::CommonResolution as CommonResolutionEnum;
|
||||
use enums::common::generation::common_video_model::CommonVideoModel as CommonVideoModelEnum;
|
||||
|
||||
use crate::api::common_aspect_ratio::CommonAspectRatio;
|
||||
use crate::api::common_resolution::CommonResolution;
|
||||
use crate::api::router_aspect_ratio::RouterAspectRatio;
|
||||
use crate::api::router_resolution::RouterResolution;
|
||||
use crate::client::request_mismatch_mitigation_strategy::RequestMismatchMitigationStrategy;
|
||||
use crate::errors::artcraft_router_error::ArtcraftRouterError;
|
||||
use crate::errors::client_error::ClientError;
|
||||
@@ -82,38 +82,38 @@ pub fn build_artcraft_omni_video_request(
|
||||
// ── Plan helpers ──
|
||||
|
||||
fn plan_aspect_ratio(
|
||||
aspect_ratio: Option<CommonAspectRatio>,
|
||||
aspect_ratio: Option<RouterAspectRatio>,
|
||||
strategy: RequestMismatchMitigationStrategy,
|
||||
ultra_wide: UltraWideSupport,
|
||||
) -> Result<Option<CommonAspectRatioEnum>, ArtcraftRouterError> {
|
||||
match aspect_ratio {
|
||||
None
|
||||
| Some(CommonAspectRatio::Auto)
|
||||
| Some(CommonAspectRatio::Auto2k)
|
||||
| Some(CommonAspectRatio::Auto4k) => Ok(None),
|
||||
| Some(RouterAspectRatio::Auto)
|
||||
| Some(RouterAspectRatio::Auto2k)
|
||||
| Some(RouterAspectRatio::Auto4k) => Ok(None),
|
||||
|
||||
Some(CommonAspectRatio::WideSixteenByNine) | Some(CommonAspectRatio::Wide) => {
|
||||
Some(RouterAspectRatio::WideSixteenByNine) | Some(RouterAspectRatio::Wide) => {
|
||||
Ok(Some(CommonAspectRatioEnum::WideSixteenByNine))
|
||||
}
|
||||
Some(CommonAspectRatio::TallNineBySixteen) | Some(CommonAspectRatio::Tall) => {
|
||||
Some(RouterAspectRatio::TallNineBySixteen) | Some(RouterAspectRatio::Tall) => {
|
||||
Ok(Some(CommonAspectRatioEnum::TallNineBySixteen))
|
||||
}
|
||||
Some(CommonAspectRatio::Square) | Some(CommonAspectRatio::SquareHd) => {
|
||||
Some(RouterAspectRatio::Square) | Some(RouterAspectRatio::SquareHd) => {
|
||||
Ok(Some(CommonAspectRatioEnum::Square))
|
||||
}
|
||||
Some(CommonAspectRatio::WideFourByThree) => Ok(Some(CommonAspectRatioEnum::WideFourByThree)),
|
||||
Some(CommonAspectRatio::TallThreeByFour) => Ok(Some(CommonAspectRatioEnum::TallThreeByFour)),
|
||||
Some(RouterAspectRatio::WideFourByThree) => Ok(Some(CommonAspectRatioEnum::WideFourByThree)),
|
||||
Some(RouterAspectRatio::TallThreeByFour) => Ok(Some(CommonAspectRatioEnum::TallThreeByFour)),
|
||||
|
||||
Some(CommonAspectRatio::WideTwentyOneByNine) => match ultra_wide {
|
||||
Some(RouterAspectRatio::WideTwentyOneByNine) => match ultra_wide {
|
||||
UltraWideSupport::Supported => Ok(Some(CommonAspectRatioEnum::WideTwentyOneByNine)),
|
||||
UltraWideSupport::Unsupported => match strategy {
|
||||
RequestMismatchMitigationStrategy::ErrorOut => {
|
||||
Err(ArtcraftRouterError::Client(ClientError::ModelDoesNotSupportOption {
|
||||
field: "aspect_ratio",
|
||||
value: format!("{:?}", CommonAspectRatio::WideTwentyOneByNine),
|
||||
value: format!("{:?}", RouterAspectRatio::WideTwentyOneByNine),
|
||||
}))
|
||||
}
|
||||
_ => Ok(Some(nearest_aspect_ratio(CommonAspectRatio::WideTwentyOneByNine))),
|
||||
_ => Ok(Some(nearest_aspect_ratio(RouterAspectRatio::WideTwentyOneByNine))),
|
||||
},
|
||||
},
|
||||
|
||||
@@ -132,27 +132,27 @@ fn plan_aspect_ratio(
|
||||
}
|
||||
}
|
||||
|
||||
fn nearest_aspect_ratio(aspect_ratio: CommonAspectRatio) -> CommonAspectRatioEnum {
|
||||
fn nearest_aspect_ratio(aspect_ratio: RouterAspectRatio) -> CommonAspectRatioEnum {
|
||||
match aspect_ratio {
|
||||
CommonAspectRatio::WideFiveByFour => CommonAspectRatioEnum::WideFourByThree,
|
||||
CommonAspectRatio::WideThreeByTwo => CommonAspectRatioEnum::WideFourByThree,
|
||||
CommonAspectRatio::WideTwentyOneByNine => CommonAspectRatioEnum::WideSixteenByNine,
|
||||
CommonAspectRatio::TallFourByFive => CommonAspectRatioEnum::TallThreeByFour,
|
||||
CommonAspectRatio::TallTwoByThree => CommonAspectRatioEnum::TallThreeByFour,
|
||||
CommonAspectRatio::TallNineByTwentyOne => CommonAspectRatioEnum::TallNineBySixteen,
|
||||
RouterAspectRatio::WideFiveByFour => CommonAspectRatioEnum::WideFourByThree,
|
||||
RouterAspectRatio::WideThreeByTwo => CommonAspectRatioEnum::WideFourByThree,
|
||||
RouterAspectRatio::WideTwentyOneByNine => CommonAspectRatioEnum::WideSixteenByNine,
|
||||
RouterAspectRatio::TallFourByFive => CommonAspectRatioEnum::TallThreeByFour,
|
||||
RouterAspectRatio::TallTwoByThree => CommonAspectRatioEnum::TallThreeByFour,
|
||||
RouterAspectRatio::TallNineByTwentyOne => CommonAspectRatioEnum::TallNineBySixteen,
|
||||
_ => CommonAspectRatioEnum::Square,
|
||||
}
|
||||
}
|
||||
|
||||
fn plan_output_resolution(
|
||||
resolution: Option<CommonResolution>,
|
||||
resolution: Option<RouterResolution>,
|
||||
strategy: RequestMismatchMitigationStrategy,
|
||||
supported: SupportedResolutions,
|
||||
) -> Result<Option<CommonResolutionEnum>, ArtcraftRouterError> {
|
||||
match resolution {
|
||||
None => Ok(None),
|
||||
|
||||
Some(CommonResolution::FourEightyP) => match supported {
|
||||
Some(RouterResolution::FourEightyP) => match supported {
|
||||
SupportedResolutions::Full | SupportedResolutions::Fast => {
|
||||
Ok(Some(CommonResolutionEnum::FourEightyP))
|
||||
}
|
||||
@@ -160,7 +160,7 @@ fn plan_output_resolution(
|
||||
RequestMismatchMitigationStrategy::ErrorOut => {
|
||||
Err(ArtcraftRouterError::Client(ClientError::ModelDoesNotSupportOption {
|
||||
field: "resolution",
|
||||
value: format!("{:?}", CommonResolution::FourEightyP),
|
||||
value: format!("{:?}", RouterResolution::FourEightyP),
|
||||
}))
|
||||
}
|
||||
RequestMismatchMitigationStrategy::PayMoreUpgrade => Ok(Some(CommonResolutionEnum::TenEightyP)),
|
||||
@@ -168,9 +168,9 @@ fn plan_output_resolution(
|
||||
},
|
||||
},
|
||||
|
||||
Some(CommonResolution::SevenTwentyP) => Ok(Some(CommonResolutionEnum::SevenTwentyP)),
|
||||
Some(RouterResolution::SevenTwentyP) => Ok(Some(CommonResolutionEnum::SevenTwentyP)),
|
||||
|
||||
Some(CommonResolution::TenEightyP) => match supported {
|
||||
Some(RouterResolution::TenEightyP) => match supported {
|
||||
SupportedResolutions::Full | SupportedResolutions::NoFourEightyP => {
|
||||
Ok(Some(CommonResolutionEnum::TenEightyP))
|
||||
}
|
||||
@@ -178,7 +178,7 @@ fn plan_output_resolution(
|
||||
RequestMismatchMitigationStrategy::ErrorOut => {
|
||||
Err(ArtcraftRouterError::Client(ClientError::ModelDoesNotSupportOption {
|
||||
field: "resolution",
|
||||
value: format!("{:?}", CommonResolution::TenEightyP),
|
||||
value: format!("{:?}", RouterResolution::TenEightyP),
|
||||
}))
|
||||
}
|
||||
_ => Ok(Some(CommonResolutionEnum::SevenTwentyP)),
|
||||
@@ -194,14 +194,14 @@ fn plan_output_resolution(
|
||||
}
|
||||
RequestMismatchMitigationStrategy::PayMoreUpgrade => {
|
||||
Ok(Some(match (unsupported, supported) {
|
||||
(CommonResolution::HalfK, _) => CommonResolutionEnum::FourEightyP,
|
||||
(RouterResolution::HalfK, _) => CommonResolutionEnum::FourEightyP,
|
||||
(_, SupportedResolutions::Fast) => CommonResolutionEnum::SevenTwentyP,
|
||||
_ => CommonResolutionEnum::TenEightyP,
|
||||
}))
|
||||
}
|
||||
RequestMismatchMitigationStrategy::PayLessDowngrade => {
|
||||
Ok(Some(match (unsupported, supported) {
|
||||
(CommonResolution::HalfK, _) => CommonResolutionEnum::FourEightyP,
|
||||
(RouterResolution::HalfK, _) => CommonResolutionEnum::FourEightyP,
|
||||
(_, SupportedResolutions::Fast) => CommonResolutionEnum::SevenTwentyP,
|
||||
_ => CommonResolutionEnum::TenEightyP,
|
||||
}))
|
||||
|
||||
+6
-6
@@ -38,10 +38,10 @@ mod tests {
|
||||
use tokens::tokens::media_files::MediaFileToken;
|
||||
|
||||
use crate::api::character_list_ref::CharacterListRef;
|
||||
use crate::api::common_resolution::CommonResolution;
|
||||
use crate::api::router_resolution::RouterResolution;
|
||||
use crate::api::image_list_ref::ImageListRef;
|
||||
use crate::api::image_ref::ImageRef;
|
||||
use crate::api::provider::Provider;
|
||||
use crate::api::router_provider::RouterProvider;
|
||||
use crate::generate::generate_video::generate_video_request_builder::GenerateVideoRequestBuilder;
|
||||
use crate::generate::generate_video_v2::video_generation_draft_or_request::VideoGenerationDraftOrRequest;
|
||||
use crate::generate::generate_video_v2::video_generation_request::VideoGenerationRequest;
|
||||
@@ -87,20 +87,20 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn res_480p() {
|
||||
let req = unwrap_request(make_builder(|b| { b.resolution = Some(CommonResolution::FourEightyP); }));
|
||||
let req = unwrap_request(make_builder(|b| { b.resolution = Some(RouterResolution::FourEightyP); }));
|
||||
assert_eq!(req.request.resolution, Some(CommonResolutionEnum::FourEightyP));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn res_720p() {
|
||||
let req = unwrap_request(make_builder(|b| { b.resolution = Some(CommonResolution::SevenTwentyP); }));
|
||||
let req = unwrap_request(make_builder(|b| { b.resolution = Some(RouterResolution::SevenTwentyP); }));
|
||||
assert_eq!(req.request.resolution, Some(CommonResolutionEnum::SevenTwentyP));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn res_1080p_downgrades_to_720p() {
|
||||
// SupportedResolutions::Fast caps at 720p (Grok Imagine doesn't render 1080p output).
|
||||
let req = unwrap_request(make_builder(|b| { b.resolution = Some(CommonResolution::TenEightyP); }));
|
||||
let req = unwrap_request(make_builder(|b| { b.resolution = Some(RouterResolution::TenEightyP); }));
|
||||
assert_eq!(req.request.resolution, Some(CommonResolutionEnum::SevenTwentyP));
|
||||
}
|
||||
|
||||
@@ -155,7 +155,7 @@ mod tests {
|
||||
|
||||
fn base_builder() -> GenerateVideoRequestBuilder {
|
||||
GenerateVideoRequestBuilder {
|
||||
provider: Provider::Artcraft,
|
||||
provider: RouterProvider::Artcraft,
|
||||
duration_seconds: Some(5),
|
||||
video_batch_count: Some(1),
|
||||
..Default::default()
|
||||
|
||||
+57
-57
@@ -72,11 +72,11 @@ impl ArtcraftGrokImagineVideoCostState {
|
||||
mod tests {
|
||||
use tokens::tokens::media_files::MediaFileToken;
|
||||
|
||||
use crate::api::common_resolution::CommonResolution;
|
||||
use crate::api::common_video_model::CommonVideoModel;
|
||||
use crate::api::router_resolution::RouterResolution;
|
||||
use crate::api::router_video_model::RouterVideoModel;
|
||||
use crate::api::image_list_ref::ImageListRef;
|
||||
use crate::api::image_ref::ImageRef;
|
||||
use crate::api::provider::Provider;
|
||||
use crate::api::router_provider::RouterProvider;
|
||||
use crate::generate::generate_video::generate_video_request_builder::GenerateVideoRequestBuilder;
|
||||
use crate::generate::generate_video::video_generation_cost_estimate::VideoGenerationCostEstimate;
|
||||
|
||||
@@ -90,30 +90,30 @@ mod tests {
|
||||
// 9.1 × 5 = 45.5 → 46
|
||||
// 9.1 × 10 = 91.0 → 91
|
||||
// 9.1 × 15 = 136.5 → 137
|
||||
assert_eq!(cost_cents(Some(CommonResolution::SevenTwentyP), 5, 1), 46);
|
||||
assert_eq!(cost_cents(Some(CommonResolution::SevenTwentyP), 10, 1), 91);
|
||||
assert_eq!(cost_cents(Some(CommonResolution::SevenTwentyP), 15, 1), 137);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::SevenTwentyP), 5, 1), 46);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::SevenTwentyP), 10, 1), 91);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::SevenTwentyP), 15, 1), 137);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn batch_2() {
|
||||
// 9.1 × 5 × 2 = 91 → 91
|
||||
assert_eq!(cost_cents(Some(CommonResolution::SevenTwentyP), 5, 2), 91);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::SevenTwentyP), 5, 2), 91);
|
||||
// 9.1 × 15 × 2 = 273 → 273
|
||||
assert_eq!(cost_cents(Some(CommonResolution::SevenTwentyP), 15, 2), 273);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::SevenTwentyP), 15, 2), 273);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn batch_4() {
|
||||
// 9.1 × 5 × 4 = 182 → 182
|
||||
assert_eq!(cost_cents(Some(CommonResolution::SevenTwentyP), 5, 4), 182);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::SevenTwentyP), 5, 4), 182);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn none_defaults_to_720p() {
|
||||
assert_eq!(
|
||||
cost_cents(None, 5, 1),
|
||||
cost_cents(Some(CommonResolution::SevenTwentyP), 5, 1),
|
||||
cost_cents(Some(RouterResolution::SevenTwentyP), 5, 1),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -128,21 +128,21 @@ mod tests {
|
||||
// 6.5 × 5 = 32.5 → 33
|
||||
// 6.5 × 10 = 65.0 → 65
|
||||
// 6.5 × 15 = 97.5 → 98
|
||||
assert_eq!(cost_cents(Some(CommonResolution::FourEightyP), 5, 1), 33);
|
||||
assert_eq!(cost_cents(Some(CommonResolution::FourEightyP), 10, 1), 65);
|
||||
assert_eq!(cost_cents(Some(CommonResolution::FourEightyP), 15, 1), 98);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::FourEightyP), 5, 1), 33);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::FourEightyP), 10, 1), 65);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::FourEightyP), 15, 1), 98);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn batch_2() {
|
||||
// 6.5 × 5 × 2 = 65 → 65
|
||||
assert_eq!(cost_cents(Some(CommonResolution::FourEightyP), 5, 2), 65);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::FourEightyP), 5, 2), 65);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn batch_4() {
|
||||
// 6.5 × 5 × 4 = 130 → 130
|
||||
assert_eq!(cost_cents(Some(CommonResolution::FourEightyP), 5, 4), 130);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::FourEightyP), 5, 4), 130);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,8 +155,8 @@ mod tests {
|
||||
fn single_start_frame_adds_input_charge() {
|
||||
// 720p 5s batch 1 = 45.5 + 0.26 (one start_frame) = 45.76 → ceil 46
|
||||
// Identical to the no-image case (45.5 → 46) because of ceil rounding.
|
||||
let with_img = cost_cents_with_images(Some(CommonResolution::SevenTwentyP), 5, 1, true, 0);
|
||||
let no_img = cost_cents_with_images(Some(CommonResolution::SevenTwentyP), 5, 1, false, 0);
|
||||
let with_img = cost_cents_with_images(Some(RouterResolution::SevenTwentyP), 5, 1, true, 0);
|
||||
let no_img = cost_cents_with_images(Some(RouterResolution::SevenTwentyP), 5, 1, false, 0);
|
||||
assert_eq!(with_img, 46);
|
||||
assert_eq!(no_img, 46);
|
||||
}
|
||||
@@ -167,9 +167,9 @@ mod tests {
|
||||
// N=0 → 26
|
||||
// N=1 → 26.26 → 27
|
||||
// N=4 → 27.04 → 28
|
||||
assert_eq!(cost_cents_with_images(Some(CommonResolution::FourEightyP), 4, 1, false, 0), 26);
|
||||
assert_eq!(cost_cents_with_images(Some(CommonResolution::FourEightyP), 4, 1, false, 1), 27);
|
||||
assert_eq!(cost_cents_with_images(Some(CommonResolution::FourEightyP), 4, 1, false, 4), 28);
|
||||
assert_eq!(cost_cents_with_images(Some(RouterResolution::FourEightyP), 4, 1, false, 0), 26);
|
||||
assert_eq!(cost_cents_with_images(Some(RouterResolution::FourEightyP), 4, 1, false, 1), 27);
|
||||
assert_eq!(cost_cents_with_images(Some(RouterResolution::FourEightyP), 4, 1, false, 4), 28);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -180,25 +180,25 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn cost_480p_cheaper_than_720p() {
|
||||
let c480 = cost_cents(Some(CommonResolution::FourEightyP), 10, 1);
|
||||
let c720 = cost_cents(Some(CommonResolution::SevenTwentyP), 10, 1);
|
||||
let c480 = cost_cents(Some(RouterResolution::FourEightyP), 10, 1);
|
||||
let c720 = cost_cents(Some(RouterResolution::SevenTwentyP), 10, 1);
|
||||
assert!(c480 < c720, "480p ({c480}) should be cheaper than 720p ({c720})");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn cost_scales_with_duration() {
|
||||
let c5 = cost_cents(Some(CommonResolution::SevenTwentyP), 5, 1);
|
||||
let c10 = cost_cents(Some(CommonResolution::SevenTwentyP), 10, 1);
|
||||
let c15 = cost_cents(Some(CommonResolution::SevenTwentyP), 15, 1);
|
||||
let c5 = cost_cents(Some(RouterResolution::SevenTwentyP), 5, 1);
|
||||
let c10 = cost_cents(Some(RouterResolution::SevenTwentyP), 10, 1);
|
||||
let c15 = cost_cents(Some(RouterResolution::SevenTwentyP), 15, 1);
|
||||
assert!(c5 < c10);
|
||||
assert!(c10 < c15);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn cost_scales_with_batch() {
|
||||
let b1 = cost_cents(Some(CommonResolution::SevenTwentyP), 5, 1);
|
||||
let b2 = cost_cents(Some(CommonResolution::SevenTwentyP), 5, 2);
|
||||
let b4 = cost_cents(Some(CommonResolution::SevenTwentyP), 5, 4);
|
||||
let b1 = cost_cents(Some(RouterResolution::SevenTwentyP), 5, 1);
|
||||
let b2 = cost_cents(Some(RouterResolution::SevenTwentyP), 5, 2);
|
||||
let b4 = cost_cents(Some(RouterResolution::SevenTwentyP), 5, 4);
|
||||
assert!(b1 < b2);
|
||||
assert!(b2 < b4);
|
||||
}
|
||||
@@ -212,8 +212,8 @@ mod tests {
|
||||
#[test]
|
||||
fn credits_equal_usd_cents_all_combos() {
|
||||
let resolutions = [
|
||||
Some(CommonResolution::FourEightyP),
|
||||
Some(CommonResolution::SevenTwentyP),
|
||||
Some(RouterResolution::FourEightyP),
|
||||
Some(RouterResolution::SevenTwentyP),
|
||||
None,
|
||||
];
|
||||
for res in resolutions {
|
||||
@@ -235,27 +235,27 @@ mod tests {
|
||||
|
||||
mod small_margin {
|
||||
use super::*;
|
||||
use crate::api::common_aspect_ratio::CommonAspectRatio;
|
||||
use crate::api::router_aspect_ratio::RouterAspectRatio;
|
||||
|
||||
#[test]
|
||||
fn small_margin() {
|
||||
let resolutions = [
|
||||
None,
|
||||
Some(CommonResolution::FourEightyP),
|
||||
Some(CommonResolution::SevenTwentyP),
|
||||
Some(CommonResolution::TenEightyP), // clamps to 720p on both sides
|
||||
Some(RouterResolution::FourEightyP),
|
||||
Some(RouterResolution::SevenTwentyP),
|
||||
Some(RouterResolution::TenEightyP), // clamps to 720p on both sides
|
||||
];
|
||||
let durations: &[u16] = &[1, 4, 5, 8, 10, 12, 15];
|
||||
let aspect_ratios = [
|
||||
None,
|
||||
Some(CommonAspectRatio::Auto),
|
||||
Some(CommonAspectRatio::Square),
|
||||
Some(CommonAspectRatio::WideSixteenByNine),
|
||||
Some(CommonAspectRatio::TallNineBySixteen),
|
||||
Some(CommonAspectRatio::WideFourByThree),
|
||||
Some(CommonAspectRatio::TallThreeByFour),
|
||||
Some(CommonAspectRatio::WideThreeByTwo),
|
||||
Some(CommonAspectRatio::TallTwoByThree),
|
||||
Some(RouterAspectRatio::Auto),
|
||||
Some(RouterAspectRatio::Square),
|
||||
Some(RouterAspectRatio::WideSixteenByNine),
|
||||
Some(RouterAspectRatio::TallNineBySixteen),
|
||||
Some(RouterAspectRatio::WideFourByThree),
|
||||
Some(RouterAspectRatio::TallThreeByFour),
|
||||
Some(RouterAspectRatio::WideThreeByTwo),
|
||||
Some(RouterAspectRatio::TallTwoByThree),
|
||||
];
|
||||
// (has_start_frame, num_reference_images). At most one of the two is
|
||||
// non-default — start_frame and reference_images are mutually exclusive
|
||||
@@ -322,9 +322,9 @@ mod tests {
|
||||
// ── Cross-provider helpers ──
|
||||
|
||||
fn artcraft_cents(
|
||||
resolution: Option<CommonResolution>,
|
||||
resolution: Option<RouterResolution>,
|
||||
duration_seconds: u16,
|
||||
aspect_ratio: Option<CommonAspectRatio>,
|
||||
aspect_ratio: Option<RouterAspectRatio>,
|
||||
has_start_frame: bool,
|
||||
num_reference_images: usize,
|
||||
) -> u64 {
|
||||
@@ -341,8 +341,8 @@ mod tests {
|
||||
} else { None };
|
||||
|
||||
let builder = GenerateVideoRequestBuilder {
|
||||
model: CommonVideoModel::GrokImagineVideo,
|
||||
provider: Provider::Artcraft,
|
||||
model: RouterVideoModel::GrokImagineVideo,
|
||||
provider: RouterProvider::Artcraft,
|
||||
resolution,
|
||||
aspect_ratio,
|
||||
duration_seconds: Some(duration_seconds),
|
||||
@@ -363,9 +363,9 @@ mod tests {
|
||||
}
|
||||
|
||||
fn grokapi_cents(
|
||||
resolution: Option<CommonResolution>,
|
||||
resolution: Option<RouterResolution>,
|
||||
duration_seconds: u16,
|
||||
aspect_ratio: Option<CommonAspectRatio>,
|
||||
aspect_ratio: Option<RouterAspectRatio>,
|
||||
has_start_frame: bool,
|
||||
num_reference_images: usize,
|
||||
) -> u64 {
|
||||
@@ -382,8 +382,8 @@ mod tests {
|
||||
} else { None };
|
||||
|
||||
let builder = GenerateVideoRequestBuilder {
|
||||
model: CommonVideoModel::GrokImagineVideo,
|
||||
provider: Provider::GrokApi,
|
||||
model: RouterVideoModel::GrokImagineVideo,
|
||||
provider: RouterProvider::GrokApi,
|
||||
resolution,
|
||||
aspect_ratio,
|
||||
duration_seconds: Some(duration_seconds),
|
||||
@@ -404,13 +404,13 @@ mod tests {
|
||||
// ── Helpers ──
|
||||
|
||||
fn build_cost(
|
||||
resolution: Option<CommonResolution>,
|
||||
resolution: Option<RouterResolution>,
|
||||
duration_seconds: u16,
|
||||
video_batch_count: u16,
|
||||
) -> VideoGenerationCostEstimate {
|
||||
let builder = GenerateVideoRequestBuilder {
|
||||
model: CommonVideoModel::GrokImagineVideo,
|
||||
provider: Provider::Artcraft,
|
||||
model: RouterVideoModel::GrokImagineVideo,
|
||||
provider: RouterProvider::Artcraft,
|
||||
resolution,
|
||||
duration_seconds: Some(duration_seconds),
|
||||
video_batch_count: Some(video_batch_count),
|
||||
@@ -423,7 +423,7 @@ mod tests {
|
||||
}
|
||||
|
||||
fn cost_cents(
|
||||
resolution: Option<CommonResolution>,
|
||||
resolution: Option<RouterResolution>,
|
||||
duration_seconds: u16,
|
||||
video_batch_count: u16,
|
||||
) -> u64 {
|
||||
@@ -433,7 +433,7 @@ mod tests {
|
||||
}
|
||||
|
||||
fn cost_cents_with_images(
|
||||
resolution: Option<CommonResolution>,
|
||||
resolution: Option<RouterResolution>,
|
||||
duration_seconds: u16,
|
||||
video_batch_count: u16,
|
||||
has_start_frame: bool,
|
||||
@@ -451,8 +451,8 @@ mod tests {
|
||||
} else { None };
|
||||
|
||||
let builder = GenerateVideoRequestBuilder {
|
||||
model: CommonVideoModel::GrokImagineVideo,
|
||||
provider: Provider::Artcraft,
|
||||
model: RouterVideoModel::GrokImagineVideo,
|
||||
provider: RouterProvider::Artcraft,
|
||||
resolution,
|
||||
duration_seconds: Some(duration_seconds),
|
||||
video_batch_count: Some(video_batch_count),
|
||||
|
||||
+7
-7
@@ -28,10 +28,10 @@ mod tests {
|
||||
use tokens::tokens::media_files::MediaFileToken;
|
||||
|
||||
use crate::api::character_list_ref::CharacterListRef;
|
||||
use crate::api::common_resolution::CommonResolution;
|
||||
use crate::api::router_resolution::RouterResolution;
|
||||
use crate::api::image_list_ref::ImageListRef;
|
||||
use crate::api::image_ref::ImageRef;
|
||||
use crate::api::provider::Provider;
|
||||
use crate::api::router_provider::RouterProvider;
|
||||
use crate::generate::generate_video::generate_video_request_builder::GenerateVideoRequestBuilder;
|
||||
use crate::generate::generate_video_v2::video_generation_draft_or_request::VideoGenerationDraftOrRequest;
|
||||
use crate::generate::generate_video_v2::video_generation_request::VideoGenerationRequest;
|
||||
@@ -77,13 +77,13 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn res_720p() {
|
||||
let req = unwrap_request(make_builder(|b| { b.resolution = Some(CommonResolution::SevenTwentyP); }));
|
||||
let req = unwrap_request(make_builder(|b| { b.resolution = Some(RouterResolution::SevenTwentyP); }));
|
||||
assert_eq!(req.request.resolution, Some(CommonResolutionEnum::SevenTwentyP));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn res_1080p() {
|
||||
let req = unwrap_request(make_builder(|b| { b.resolution = Some(CommonResolution::TenEightyP); }));
|
||||
let req = unwrap_request(make_builder(|b| { b.resolution = Some(RouterResolution::TenEightyP); }));
|
||||
assert_eq!(req.request.resolution, Some(CommonResolutionEnum::TenEightyP));
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn unsupported_480p_upgrades() {
|
||||
let req = unwrap_request(make_builder(|b| { b.resolution = Some(CommonResolution::FourEightyP); }));
|
||||
let req = unwrap_request(make_builder(|b| { b.resolution = Some(RouterResolution::FourEightyP); }));
|
||||
assert_eq!(req.request.resolution, Some(CommonResolutionEnum::TenEightyP));
|
||||
}
|
||||
}
|
||||
@@ -144,8 +144,8 @@ mod tests {
|
||||
|
||||
fn base_builder() -> GenerateVideoRequestBuilder {
|
||||
GenerateVideoRequestBuilder {
|
||||
model: crate::api::common_video_model::CommonVideoModel::HappyHorse1p0,
|
||||
provider: Provider::Artcraft,
|
||||
model: crate::api::router_video_model::RouterVideoModel::HappyHorse1p0,
|
||||
provider: RouterProvider::Artcraft,
|
||||
duration_seconds: Some(5),
|
||||
video_batch_count: Some(1),
|
||||
..Default::default()
|
||||
|
||||
+30
-30
@@ -66,9 +66,9 @@ impl ArtcraftHappyHorse1p0CostState {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::api::common_resolution::CommonResolution;
|
||||
use crate::api::common_video_model::CommonVideoModel;
|
||||
use crate::api::provider::Provider;
|
||||
use crate::api::router_resolution::RouterResolution;
|
||||
use crate::api::router_video_model::RouterVideoModel;
|
||||
use crate::api::router_provider::RouterProvider;
|
||||
use crate::generate::generate_video::generate_video_request_builder::GenerateVideoRequestBuilder;
|
||||
|
||||
// ── 720p pricing (33 upstream credits/sec) ──
|
||||
@@ -80,25 +80,25 @@ mod tests {
|
||||
fn batch_1() {
|
||||
// 33 credits/sec; upstream_credits / 193 * 100
|
||||
// (NB: duration 3s is clamped to 4s by the builder)
|
||||
assert_eq!(cost_cents(Some(CommonResolution::SevenTwentyP), 4, 1), 68);
|
||||
assert_eq!(cost_cents(Some(CommonResolution::SevenTwentyP), 5, 1), 85);
|
||||
assert_eq!(cost_cents(Some(CommonResolution::SevenTwentyP), 10, 1), 171);
|
||||
assert_eq!(cost_cents(Some(CommonResolution::SevenTwentyP), 15, 1), 256);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::SevenTwentyP), 4, 1), 68);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::SevenTwentyP), 5, 1), 85);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::SevenTwentyP), 10, 1), 171);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::SevenTwentyP), 15, 1), 256);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn batch_2() {
|
||||
assert_eq!(cost_cents(Some(CommonResolution::SevenTwentyP), 5, 2), 171);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::SevenTwentyP), 5, 2), 171);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn batch_4() {
|
||||
assert_eq!(cost_cents(Some(CommonResolution::SevenTwentyP), 5, 4), 342);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::SevenTwentyP), 5, 4), 342);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn none_defaults_to_720p() {
|
||||
assert_eq!(cost_cents(None, 5, 1), cost_cents(Some(CommonResolution::SevenTwentyP), 5, 1));
|
||||
assert_eq!(cost_cents(None, 5, 1), cost_cents(Some(RouterResolution::SevenTwentyP), 5, 1));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,20 +111,20 @@ mod tests {
|
||||
fn batch_1() {
|
||||
// 66 credits/sec; upstream_credits / 193 * 100
|
||||
// (NB: duration 3s is clamped to 4s by the builder)
|
||||
assert_eq!(cost_cents(Some(CommonResolution::TenEightyP), 4, 1), 137);
|
||||
assert_eq!(cost_cents(Some(CommonResolution::TenEightyP), 5, 1), 171);
|
||||
assert_eq!(cost_cents(Some(CommonResolution::TenEightyP), 10, 1), 342);
|
||||
assert_eq!(cost_cents(Some(CommonResolution::TenEightyP), 15, 1), 513);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::TenEightyP), 4, 1), 137);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::TenEightyP), 5, 1), 171);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::TenEightyP), 10, 1), 342);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::TenEightyP), 15, 1), 513);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn batch_2() {
|
||||
assert_eq!(cost_cents(Some(CommonResolution::TenEightyP), 5, 2), 342);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::TenEightyP), 5, 2), 342);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn batch_4() {
|
||||
assert_eq!(cost_cents(Some(CommonResolution::TenEightyP), 5, 4), 684);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::TenEightyP), 5, 4), 684);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,8 +135,8 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn cost_720p_cheaper_than_1080p() {
|
||||
let c720 = cost_cents(Some(CommonResolution::SevenTwentyP), 5, 1);
|
||||
let c1080 = cost_cents(Some(CommonResolution::TenEightyP), 5, 1);
|
||||
let c720 = cost_cents(Some(RouterResolution::SevenTwentyP), 5, 1);
|
||||
let c1080 = cost_cents(Some(RouterResolution::TenEightyP), 5, 1);
|
||||
assert!(c720 < c1080);
|
||||
}
|
||||
|
||||
@@ -145,8 +145,8 @@ mod tests {
|
||||
// 1080p upstream credits are exactly 2× 720p, but USD cents may differ
|
||||
// by ±1 due to rounding (each is rounded independently).
|
||||
for dur in [4u16, 5, 10, 15] {
|
||||
let c720 = cost_cents(Some(CommonResolution::SevenTwentyP), dur, 1);
|
||||
let c1080 = cost_cents(Some(CommonResolution::TenEightyP), dur, 1);
|
||||
let c720 = cost_cents(Some(RouterResolution::SevenTwentyP), dur, 1);
|
||||
let c1080 = cost_cents(Some(RouterResolution::TenEightyP), dur, 1);
|
||||
let expected = c720 * 2;
|
||||
assert!(
|
||||
c1080 >= expected - 1 && c1080 <= expected + 1,
|
||||
@@ -182,8 +182,8 @@ mod tests {
|
||||
#[test]
|
||||
fn credits_equal_usd_cents() {
|
||||
let resolutions = [
|
||||
Some(CommonResolution::SevenTwentyP),
|
||||
Some(CommonResolution::TenEightyP),
|
||||
Some(RouterResolution::SevenTwentyP),
|
||||
Some(RouterResolution::TenEightyP),
|
||||
None,
|
||||
];
|
||||
for res in resolutions {
|
||||
@@ -209,9 +209,9 @@ mod tests {
|
||||
#[test]
|
||||
fn artcraft_matches_kinovi_all_combos() {
|
||||
let resolutions = [
|
||||
Some(CommonResolution::SevenTwentyP),
|
||||
Some(RouterResolution::SevenTwentyP),
|
||||
None,
|
||||
Some(CommonResolution::TenEightyP),
|
||||
Some(RouterResolution::TenEightyP),
|
||||
];
|
||||
let durations: [u16; 4] = [4, 5, 10, 15];
|
||||
let batches: [u16; 3] = [1, 2, 4];
|
||||
@@ -222,8 +222,8 @@ mod tests {
|
||||
let artcraft_cost = build_cost(*res, *dur, *batch);
|
||||
|
||||
let kinovi = GenerateVideoRequestBuilder {
|
||||
model: CommonVideoModel::HappyHorse1p0,
|
||||
provider: Provider::Seedance2Pro,
|
||||
model: RouterVideoModel::HappyHorse1p0,
|
||||
provider: RouterProvider::Seedance2Pro,
|
||||
resolution: *res,
|
||||
duration_seconds: Some(*dur),
|
||||
video_batch_count: Some(*batch),
|
||||
@@ -248,13 +248,13 @@ mod tests {
|
||||
// ── Helpers ──
|
||||
|
||||
fn build_cost(
|
||||
resolution: Option<CommonResolution>,
|
||||
resolution: Option<RouterResolution>,
|
||||
duration_seconds: u16,
|
||||
video_batch_count: u16,
|
||||
) -> crate::generate::generate_video::video_generation_cost_estimate::VideoGenerationCostEstimate {
|
||||
let builder = GenerateVideoRequestBuilder {
|
||||
model: CommonVideoModel::HappyHorse1p0,
|
||||
provider: Provider::Artcraft,
|
||||
model: RouterVideoModel::HappyHorse1p0,
|
||||
provider: RouterProvider::Artcraft,
|
||||
resolution,
|
||||
duration_seconds: Some(duration_seconds),
|
||||
video_batch_count: Some(video_batch_count),
|
||||
@@ -267,7 +267,7 @@ mod tests {
|
||||
}
|
||||
|
||||
fn cost_cents(
|
||||
resolution: Option<CommonResolution>,
|
||||
resolution: Option<RouterResolution>,
|
||||
duration_seconds: u16,
|
||||
video_batch_count: u16,
|
||||
) -> u64 {
|
||||
|
||||
+13
-13
@@ -20,11 +20,11 @@ impl ArtcraftHappyHorse1p0RequestState {
|
||||
mod tests {
|
||||
use tokens::tokens::media_files::MediaFileToken;
|
||||
|
||||
use crate::api::common_aspect_ratio::CommonAspectRatio;
|
||||
use crate::api::common_resolution::CommonResolution;
|
||||
use crate::api::common_video_model::CommonVideoModel;
|
||||
use crate::api::router_aspect_ratio::RouterAspectRatio;
|
||||
use crate::api::router_resolution::RouterResolution;
|
||||
use crate::api::router_video_model::RouterVideoModel;
|
||||
use crate::api::image_ref::ImageRef;
|
||||
use crate::api::provider::Provider;
|
||||
use crate::api::router_provider::RouterProvider;
|
||||
use crate::client::router_artcraft_client::RouterArtcraftClient;
|
||||
use crate::client::router_client::RouterClient;
|
||||
use crate::generate::generate_video::generate_video_request_builder::GenerateVideoRequestBuilder;
|
||||
@@ -43,7 +43,7 @@ mod tests {
|
||||
async fn landscape() {
|
||||
let response = run_pipeline(GenerateVideoRequestBuilder {
|
||||
prompt: Some("A corgi running through a field of wildflowers at sunset.".to_string()),
|
||||
aspect_ratio: Some(CommonAspectRatio::WideSixteenByNine),
|
||||
aspect_ratio: Some(RouterAspectRatio::WideSixteenByNine),
|
||||
..artcraft_builder()
|
||||
}).await;
|
||||
assert!(matches!(response, GenerateVideoResponse::Artcraft(_)));
|
||||
@@ -55,7 +55,7 @@ mod tests {
|
||||
async fn portrait() {
|
||||
let response = run_pipeline(GenerateVideoRequestBuilder {
|
||||
prompt: Some("A cat sitting on a windowsill watching rain.".to_string()),
|
||||
aspect_ratio: Some(CommonAspectRatio::TallNineBySixteen),
|
||||
aspect_ratio: Some(RouterAspectRatio::TallNineBySixteen),
|
||||
..artcraft_builder()
|
||||
}).await;
|
||||
assert!(matches!(response, GenerateVideoResponse::Artcraft(_)));
|
||||
@@ -67,7 +67,7 @@ mod tests {
|
||||
async fn square() {
|
||||
let response = run_pipeline(GenerateVideoRequestBuilder {
|
||||
prompt: Some("A hummingbird hovering near a flower.".to_string()),
|
||||
aspect_ratio: Some(CommonAspectRatio::Square),
|
||||
aspect_ratio: Some(RouterAspectRatio::Square),
|
||||
..artcraft_builder()
|
||||
}).await;
|
||||
assert!(matches!(response, GenerateVideoResponse::Artcraft(_)));
|
||||
@@ -83,7 +83,7 @@ mod tests {
|
||||
async fn res_720p() {
|
||||
let response = run_pipeline(GenerateVideoRequestBuilder {
|
||||
prompt: Some("A golden retriever catching a frisbee on the beach.".to_string()),
|
||||
resolution: Some(CommonResolution::SevenTwentyP),
|
||||
resolution: Some(RouterResolution::SevenTwentyP),
|
||||
..artcraft_builder()
|
||||
}).await;
|
||||
assert!(matches!(response, GenerateVideoResponse::Artcraft(_)));
|
||||
@@ -95,7 +95,7 @@ mod tests {
|
||||
async fn res_1080p() {
|
||||
let response = run_pipeline(GenerateVideoRequestBuilder {
|
||||
prompt: Some("A fox walking through a snowy forest.".to_string()),
|
||||
resolution: Some(CommonResolution::TenEightyP),
|
||||
resolution: Some(RouterResolution::TenEightyP),
|
||||
..artcraft_builder()
|
||||
}).await;
|
||||
assert!(matches!(response, GenerateVideoResponse::Artcraft(_)));
|
||||
@@ -111,7 +111,7 @@ mod tests {
|
||||
async fn text_to_video() {
|
||||
let response = run_pipeline(GenerateVideoRequestBuilder {
|
||||
prompt: Some("A whale breaching in the open ocean at dawn, cinematic.".to_string()),
|
||||
aspect_ratio: Some(CommonAspectRatio::WideSixteenByNine),
|
||||
aspect_ratio: Some(RouterAspectRatio::WideSixteenByNine),
|
||||
..artcraft_builder()
|
||||
}).await;
|
||||
assert!(matches!(response, GenerateVideoResponse::Artcraft(_)));
|
||||
@@ -124,7 +124,7 @@ mod tests {
|
||||
let response = run_pipeline(GenerateVideoRequestBuilder {
|
||||
prompt: Some("The dog watches the lake as the sun sets.".to_string()),
|
||||
start_frame: Some(ImageRef::MediaFileToken(MediaFileToken::new(JUNO_AT_LAKE_PRODUCTION_MEDIA_TOKEN.to_string()))),
|
||||
aspect_ratio: Some(CommonAspectRatio::WideSixteenByNine),
|
||||
aspect_ratio: Some(RouterAspectRatio::WideSixteenByNine),
|
||||
..artcraft_builder()
|
||||
}).await;
|
||||
assert!(matches!(response, GenerateVideoResponse::Artcraft(_)));
|
||||
@@ -136,8 +136,8 @@ mod tests {
|
||||
|
||||
fn artcraft_builder() -> GenerateVideoRequestBuilder {
|
||||
GenerateVideoRequestBuilder {
|
||||
model: CommonVideoModel::HappyHorse1p0,
|
||||
provider: Provider::Artcraft,
|
||||
model: RouterVideoModel::HappyHorse1p0,
|
||||
provider: RouterProvider::Artcraft,
|
||||
duration_seconds: Some(4),
|
||||
video_batch_count: Some(1),
|
||||
..Default::default()
|
||||
|
||||
+4
-4
@@ -32,16 +32,16 @@ impl ArtcraftKling16ProCostState {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::api::common_video_model::CommonVideoModel;
|
||||
use crate::api::router_video_model::RouterVideoModel;
|
||||
use crate::api::image_ref::ImageRef;
|
||||
use crate::api::provider::Provider;
|
||||
use crate::api::router_provider::RouterProvider;
|
||||
use crate::generate::generate_video::generate_video_request_builder::GenerateVideoRequestBuilder;
|
||||
use tokens::tokens::media_files::MediaFileToken;
|
||||
|
||||
fn cost_cents(duration_seconds: Option<u16>) -> u64 {
|
||||
let b = GenerateVideoRequestBuilder {
|
||||
model: CommonVideoModel::Kling16Pro,
|
||||
provider: Provider::Artcraft,
|
||||
model: RouterVideoModel::Kling16Pro,
|
||||
provider: RouterProvider::Artcraft,
|
||||
prompt: Some("test".to_string()),
|
||||
start_frame: Some(ImageRef::MediaFileToken(MediaFileToken::new("mf_x".to_string()))),
|
||||
duration_seconds,
|
||||
|
||||
+4
-4
@@ -29,16 +29,16 @@ impl ArtcraftKling21MasterCostState {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::api::common_video_model::CommonVideoModel;
|
||||
use crate::api::router_video_model::RouterVideoModel;
|
||||
use crate::api::image_ref::ImageRef;
|
||||
use crate::api::provider::Provider;
|
||||
use crate::api::router_provider::RouterProvider;
|
||||
use crate::generate::generate_video::generate_video_request_builder::GenerateVideoRequestBuilder;
|
||||
use tokens::tokens::media_files::MediaFileToken;
|
||||
|
||||
fn cost_cents(duration_seconds: Option<u16>) -> u64 {
|
||||
let b = GenerateVideoRequestBuilder {
|
||||
model: CommonVideoModel::Kling21Master,
|
||||
provider: Provider::Artcraft,
|
||||
model: RouterVideoModel::Kling21Master,
|
||||
provider: RouterProvider::Artcraft,
|
||||
prompt: Some("test".to_string()),
|
||||
start_frame: Some(ImageRef::MediaFileToken(MediaFileToken::new("mf_x".to_string()))),
|
||||
duration_seconds,
|
||||
|
||||
+4
-4
@@ -29,16 +29,16 @@ impl ArtcraftKling21ProCostState {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::api::common_video_model::CommonVideoModel;
|
||||
use crate::api::router_video_model::RouterVideoModel;
|
||||
use crate::api::image_ref::ImageRef;
|
||||
use crate::api::provider::Provider;
|
||||
use crate::api::router_provider::RouterProvider;
|
||||
use crate::generate::generate_video::generate_video_request_builder::GenerateVideoRequestBuilder;
|
||||
use tokens::tokens::media_files::MediaFileToken;
|
||||
|
||||
fn cost_cents(duration_seconds: Option<u16>) -> u64 {
|
||||
let b = GenerateVideoRequestBuilder {
|
||||
model: CommonVideoModel::Kling21Pro,
|
||||
provider: Provider::Artcraft,
|
||||
model: RouterVideoModel::Kling21Pro,
|
||||
provider: RouterProvider::Artcraft,
|
||||
prompt: Some("test".to_string()),
|
||||
start_frame: Some(ImageRef::MediaFileToken(MediaFileToken::new("mf_x".to_string()))),
|
||||
duration_seconds,
|
||||
|
||||
+4
-4
@@ -29,14 +29,14 @@ impl ArtcraftKling2p5TurboProCostState {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::api::common_video_model::CommonVideoModel;
|
||||
use crate::api::provider::Provider;
|
||||
use crate::api::router_video_model::RouterVideoModel;
|
||||
use crate::api::router_provider::RouterProvider;
|
||||
use crate::generate::generate_video::generate_video_request_builder::GenerateVideoRequestBuilder;
|
||||
|
||||
fn cost_cents(duration_seconds: Option<u16>) -> u64 {
|
||||
let b = GenerateVideoRequestBuilder {
|
||||
model: CommonVideoModel::Kling2p5TurboPro,
|
||||
provider: Provider::Artcraft,
|
||||
model: RouterVideoModel::Kling2p5TurboPro,
|
||||
provider: RouterProvider::Artcraft,
|
||||
prompt: Some("test".to_string()),
|
||||
duration_seconds,
|
||||
..Default::default()
|
||||
|
||||
+4
-4
@@ -41,14 +41,14 @@ impl ArtcraftKling2p6ProCostState {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::api::common_video_model::CommonVideoModel;
|
||||
use crate::api::provider::Provider;
|
||||
use crate::api::router_video_model::RouterVideoModel;
|
||||
use crate::api::router_provider::RouterProvider;
|
||||
use crate::generate::generate_video::generate_video_request_builder::GenerateVideoRequestBuilder;
|
||||
|
||||
fn cost_cents(duration_seconds: Option<u16>, generate_audio: Option<bool>) -> u64 {
|
||||
let b = GenerateVideoRequestBuilder {
|
||||
model: CommonVideoModel::Kling2p6Pro,
|
||||
provider: Provider::Artcraft,
|
||||
model: RouterVideoModel::Kling2p6Pro,
|
||||
provider: RouterProvider::Artcraft,
|
||||
prompt: Some("test".to_string()),
|
||||
duration_seconds,
|
||||
generate_audio,
|
||||
|
||||
+4
-4
@@ -38,14 +38,14 @@ impl ArtcraftKling3p0ProCostState {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::api::common_video_model::CommonVideoModel;
|
||||
use crate::api::provider::Provider;
|
||||
use crate::api::router_video_model::RouterVideoModel;
|
||||
use crate::api::router_provider::RouterProvider;
|
||||
use crate::generate::generate_video::generate_video_request_builder::GenerateVideoRequestBuilder;
|
||||
|
||||
fn cost_cents(duration_seconds: Option<u16>, generate_audio: Option<bool>) -> u64 {
|
||||
let b = GenerateVideoRequestBuilder {
|
||||
model: CommonVideoModel::Kling3p0Pro,
|
||||
provider: Provider::Artcraft,
|
||||
model: RouterVideoModel::Kling3p0Pro,
|
||||
provider: RouterProvider::Artcraft,
|
||||
prompt: Some("test".to_string()),
|
||||
duration_seconds,
|
||||
generate_audio,
|
||||
|
||||
+4
-4
@@ -36,14 +36,14 @@ impl ArtcraftKling3p0StandardCostState {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::api::common_video_model::CommonVideoModel;
|
||||
use crate::api::provider::Provider;
|
||||
use crate::api::router_video_model::RouterVideoModel;
|
||||
use crate::api::router_provider::RouterProvider;
|
||||
use crate::generate::generate_video::generate_video_request_builder::GenerateVideoRequestBuilder;
|
||||
|
||||
fn cost_cents(duration_seconds: Option<u16>, generate_audio: Option<bool>) -> u64 {
|
||||
let b = GenerateVideoRequestBuilder {
|
||||
model: CommonVideoModel::Kling3p0Standard,
|
||||
provider: Provider::Artcraft,
|
||||
model: RouterVideoModel::Kling3p0Standard,
|
||||
provider: RouterProvider::Artcraft,
|
||||
prompt: Some("test".to_string()),
|
||||
duration_seconds,
|
||||
generate_audio,
|
||||
|
||||
+6
-6
@@ -28,10 +28,10 @@ mod tests {
|
||||
use tokens::tokens::media_files::MediaFileToken;
|
||||
|
||||
use crate::api::character_list_ref::CharacterListRef;
|
||||
use crate::api::common_resolution::CommonResolution;
|
||||
use crate::api::router_resolution::RouterResolution;
|
||||
use crate::api::image_list_ref::ImageListRef;
|
||||
use crate::api::image_ref::ImageRef;
|
||||
use crate::api::provider::Provider;
|
||||
use crate::api::router_provider::RouterProvider;
|
||||
use crate::generate::generate_video::generate_video_request_builder::GenerateVideoRequestBuilder;
|
||||
use crate::generate::generate_video_v2::video_generation_draft_or_request::VideoGenerationDraftOrRequest;
|
||||
use crate::generate::generate_video_v2::video_generation_request::VideoGenerationRequest;
|
||||
@@ -81,19 +81,19 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn res_480p() {
|
||||
let req = unwrap_request(make_builder(|b| { b.resolution = Some(CommonResolution::FourEightyP); }));
|
||||
let req = unwrap_request(make_builder(|b| { b.resolution = Some(RouterResolution::FourEightyP); }));
|
||||
assert_eq!(req.request.resolution, Some(CommonResolutionEnum::FourEightyP));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn res_720p() {
|
||||
let req = unwrap_request(make_builder(|b| { b.resolution = Some(CommonResolution::SevenTwentyP); }));
|
||||
let req = unwrap_request(make_builder(|b| { b.resolution = Some(RouterResolution::SevenTwentyP); }));
|
||||
assert_eq!(req.request.resolution, Some(CommonResolutionEnum::SevenTwentyP));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn res_1080p() {
|
||||
let req = unwrap_request(make_builder(|b| { b.resolution = Some(CommonResolution::TenEightyP); }));
|
||||
let req = unwrap_request(make_builder(|b| { b.resolution = Some(RouterResolution::TenEightyP); }));
|
||||
assert_eq!(req.request.resolution, Some(CommonResolutionEnum::TenEightyP));
|
||||
}
|
||||
|
||||
@@ -150,7 +150,7 @@ mod tests {
|
||||
|
||||
fn base_builder() -> GenerateVideoRequestBuilder {
|
||||
GenerateVideoRequestBuilder {
|
||||
provider: Provider::Artcraft,
|
||||
provider: RouterProvider::Artcraft,
|
||||
duration_seconds: Some(5),
|
||||
video_batch_count: Some(1),
|
||||
..Default::default()
|
||||
|
||||
+40
-40
@@ -55,9 +55,9 @@ impl ArtcraftPreviewModelCostState {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::api::common_resolution::CommonResolution;
|
||||
use crate::api::common_video_model::CommonVideoModel;
|
||||
use crate::api::provider::Provider;
|
||||
use crate::api::router_resolution::RouterResolution;
|
||||
use crate::api::router_video_model::RouterVideoModel;
|
||||
use crate::api::router_provider::RouterProvider;
|
||||
use crate::generate::generate_video::generate_video_request_builder::GenerateVideoRequestBuilder;
|
||||
|
||||
// -- 720p pricing --
|
||||
@@ -67,27 +67,27 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn batch_1() {
|
||||
assert_eq!(cost_cents(Some(CommonResolution::SevenTwentyP), 4, 1), 100);
|
||||
assert_eq!(cost_cents(Some(CommonResolution::SevenTwentyP), 5, 1), 125);
|
||||
assert_eq!(cost_cents(Some(CommonResolution::SevenTwentyP), 10, 1), 250);
|
||||
assert_eq!(cost_cents(Some(CommonResolution::SevenTwentyP), 15, 1), 375);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::SevenTwentyP), 4, 1), 100);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::SevenTwentyP), 5, 1), 125);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::SevenTwentyP), 10, 1), 250);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::SevenTwentyP), 15, 1), 375);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn batch_2() {
|
||||
assert_eq!(cost_cents(Some(CommonResolution::SevenTwentyP), 5, 2), 250);
|
||||
assert_eq!(cost_cents(Some(CommonResolution::SevenTwentyP), 15, 2), 750);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::SevenTwentyP), 5, 2), 250);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::SevenTwentyP), 15, 2), 750);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn batch_4() {
|
||||
assert_eq!(cost_cents(Some(CommonResolution::SevenTwentyP), 5, 4), 500);
|
||||
assert_eq!(cost_cents(Some(CommonResolution::SevenTwentyP), 15, 4), 1500);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::SevenTwentyP), 5, 4), 500);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::SevenTwentyP), 15, 4), 1500);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn none_defaults_to_720p() {
|
||||
assert_eq!(cost_cents(None, 5, 1), cost_cents(Some(CommonResolution::SevenTwentyP), 5, 1));
|
||||
assert_eq!(cost_cents(None, 5, 1), cost_cents(Some(RouterResolution::SevenTwentyP), 5, 1));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,20 +98,20 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn batch_1() {
|
||||
assert_eq!(cost_cents(Some(CommonResolution::FourEightyP), 4, 1), 40);
|
||||
assert_eq!(cost_cents(Some(CommonResolution::FourEightyP), 5, 1), 50);
|
||||
assert_eq!(cost_cents(Some(CommonResolution::FourEightyP), 10, 1), 100);
|
||||
assert_eq!(cost_cents(Some(CommonResolution::FourEightyP), 15, 1), 150);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::FourEightyP), 4, 1), 40);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::FourEightyP), 5, 1), 50);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::FourEightyP), 10, 1), 100);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::FourEightyP), 15, 1), 150);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn batch_2() {
|
||||
assert_eq!(cost_cents(Some(CommonResolution::FourEightyP), 5, 2), 100);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::FourEightyP), 5, 2), 100);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn batch_4() {
|
||||
assert_eq!(cost_cents(Some(CommonResolution::FourEightyP), 5, 4), 200);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::FourEightyP), 5, 4), 200);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,20 +122,20 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn batch_1() {
|
||||
assert_eq!(cost_cents(Some(CommonResolution::TenEightyP), 4, 1), 200);
|
||||
assert_eq!(cost_cents(Some(CommonResolution::TenEightyP), 5, 1), 250);
|
||||
assert_eq!(cost_cents(Some(CommonResolution::TenEightyP), 10, 1), 500);
|
||||
assert_eq!(cost_cents(Some(CommonResolution::TenEightyP), 15, 1), 750);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::TenEightyP), 4, 1), 200);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::TenEightyP), 5, 1), 250);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::TenEightyP), 10, 1), 500);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::TenEightyP), 15, 1), 750);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn batch_2() {
|
||||
assert_eq!(cost_cents(Some(CommonResolution::TenEightyP), 5, 2), 500);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::TenEightyP), 5, 2), 500);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn batch_4() {
|
||||
assert_eq!(cost_cents(Some(CommonResolution::TenEightyP), 5, 4), 1000);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::TenEightyP), 5, 4), 1000);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,27 +146,27 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn cost_480p_cheaper_than_720p_cheaper_than_1080p() {
|
||||
let c480 = cost_cents(Some(CommonResolution::FourEightyP), 5, 1);
|
||||
let c720 = cost_cents(Some(CommonResolution::SevenTwentyP), 5, 1);
|
||||
let c1080 = cost_cents(Some(CommonResolution::TenEightyP), 5, 1);
|
||||
let c480 = cost_cents(Some(RouterResolution::FourEightyP), 5, 1);
|
||||
let c720 = cost_cents(Some(RouterResolution::SevenTwentyP), 5, 1);
|
||||
let c1080 = cost_cents(Some(RouterResolution::TenEightyP), 5, 1);
|
||||
assert!(c480 < c720);
|
||||
assert!(c720 < c1080);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn cost_scales_with_duration() {
|
||||
let c4 = cost_cents(Some(CommonResolution::SevenTwentyP), 4, 1);
|
||||
let c10 = cost_cents(Some(CommonResolution::SevenTwentyP), 10, 1);
|
||||
let c15 = cost_cents(Some(CommonResolution::SevenTwentyP), 15, 1);
|
||||
let c4 = cost_cents(Some(RouterResolution::SevenTwentyP), 4, 1);
|
||||
let c10 = cost_cents(Some(RouterResolution::SevenTwentyP), 10, 1);
|
||||
let c15 = cost_cents(Some(RouterResolution::SevenTwentyP), 15, 1);
|
||||
assert!(c4 < c10);
|
||||
assert!(c10 < c15);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn cost_scales_with_batch() {
|
||||
let b1 = cost_cents(Some(CommonResolution::TenEightyP), 5, 1);
|
||||
let b2 = cost_cents(Some(CommonResolution::TenEightyP), 5, 2);
|
||||
let b4 = cost_cents(Some(CommonResolution::TenEightyP), 5, 4);
|
||||
let b1 = cost_cents(Some(RouterResolution::TenEightyP), 5, 1);
|
||||
let b2 = cost_cents(Some(RouterResolution::TenEightyP), 5, 2);
|
||||
let b4 = cost_cents(Some(RouterResolution::TenEightyP), 5, 4);
|
||||
assert!(b1 < b2);
|
||||
assert!(b2 < b4);
|
||||
}
|
||||
@@ -180,9 +180,9 @@ mod tests {
|
||||
#[test]
|
||||
fn credits_equal_usd_cents_all_combos() {
|
||||
let resolutions = [
|
||||
Some(CommonResolution::FourEightyP),
|
||||
Some(CommonResolution::SevenTwentyP),
|
||||
Some(CommonResolution::TenEightyP),
|
||||
Some(RouterResolution::FourEightyP),
|
||||
Some(RouterResolution::SevenTwentyP),
|
||||
Some(RouterResolution::TenEightyP),
|
||||
None,
|
||||
];
|
||||
for res in resolutions {
|
||||
@@ -203,13 +203,13 @@ mod tests {
|
||||
// -- Helpers --
|
||||
|
||||
fn build_cost(
|
||||
resolution: Option<CommonResolution>,
|
||||
resolution: Option<RouterResolution>,
|
||||
duration_seconds: u16,
|
||||
video_batch_count: u16,
|
||||
) -> crate::generate::generate_video::video_generation_cost_estimate::VideoGenerationCostEstimate {
|
||||
let builder = GenerateVideoRequestBuilder {
|
||||
model: CommonVideoModel::PreviewModel,
|
||||
provider: Provider::Artcraft,
|
||||
model: RouterVideoModel::PreviewModel,
|
||||
provider: RouterProvider::Artcraft,
|
||||
resolution,
|
||||
duration_seconds: Some(duration_seconds),
|
||||
video_batch_count: Some(video_batch_count),
|
||||
@@ -222,7 +222,7 @@ mod tests {
|
||||
}
|
||||
|
||||
fn cost_cents(
|
||||
resolution: Option<CommonResolution>,
|
||||
resolution: Option<RouterResolution>,
|
||||
duration_seconds: u16,
|
||||
video_batch_count: u16,
|
||||
) -> u64 {
|
||||
|
||||
+13
-13
@@ -28,11 +28,11 @@ mod tests {
|
||||
use tokens::tokens::media_files::MediaFileToken;
|
||||
|
||||
use crate::api::character_list_ref::CharacterListRef;
|
||||
use crate::api::common_resolution::CommonResolution;
|
||||
use crate::api::common_video_model::CommonVideoModel;
|
||||
use crate::api::router_resolution::RouterResolution;
|
||||
use crate::api::router_video_model::RouterVideoModel;
|
||||
use crate::api::image_list_ref::ImageListRef;
|
||||
use crate::api::image_ref::ImageRef;
|
||||
use crate::api::provider::Provider;
|
||||
use crate::api::router_provider::RouterProvider;
|
||||
use crate::client::request_mismatch_mitigation_strategy::RequestMismatchMitigationStrategy;
|
||||
use crate::generate::generate_video::generate_video_request_builder::GenerateVideoRequestBuilder;
|
||||
use crate::generate::generate_video_v2::video_generation_draft_or_request::VideoGenerationDraftOrRequest;
|
||||
@@ -83,28 +83,28 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn res_480p() {
|
||||
let req = unwrap_request(make_builder(|b| { b.resolution = Some(CommonResolution::FourEightyP); }));
|
||||
let req = unwrap_request(make_builder(|b| { b.resolution = Some(RouterResolution::FourEightyP); }));
|
||||
assert_eq!(req.request.resolution, Some(CommonResolutionEnum::FourEightyP));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn res_720p() {
|
||||
let req = unwrap_request(make_builder(|b| { b.resolution = Some(CommonResolution::SevenTwentyP); }));
|
||||
let req = unwrap_request(make_builder(|b| { b.resolution = Some(RouterResolution::SevenTwentyP); }));
|
||||
assert_eq!(req.request.resolution, Some(CommonResolutionEnum::SevenTwentyP));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn res_1080p_downgrades_to_720p() {
|
||||
let req = unwrap_request(make_builder(|b| { b.resolution = Some(CommonResolution::TenEightyP); }));
|
||||
let req = unwrap_request(make_builder(|b| { b.resolution = Some(RouterResolution::TenEightyP); }));
|
||||
assert_eq!(req.request.resolution, Some(CommonResolutionEnum::SevenTwentyP));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn res_1080p_error_out() {
|
||||
let result = build_artcraft_preview_model_fast(GenerateVideoRequestBuilder {
|
||||
model: CommonVideoModel::PreviewModelFast,
|
||||
provider: Provider::Artcraft,
|
||||
resolution: Some(CommonResolution::TenEightyP),
|
||||
model: RouterVideoModel::PreviewModelFast,
|
||||
provider: RouterProvider::Artcraft,
|
||||
resolution: Some(RouterResolution::TenEightyP),
|
||||
request_mismatch_mitigation_strategy: RequestMismatchMitigationStrategy::ErrorOut,
|
||||
..Default::default()
|
||||
});
|
||||
@@ -135,8 +135,8 @@ mod tests {
|
||||
#[test]
|
||||
fn url_start_frame_rejected() {
|
||||
let result = build_artcraft_preview_model_fast(GenerateVideoRequestBuilder {
|
||||
model: CommonVideoModel::PreviewModelFast,
|
||||
provider: Provider::Artcraft,
|
||||
model: RouterVideoModel::PreviewModelFast,
|
||||
provider: RouterProvider::Artcraft,
|
||||
start_frame: Some(ImageRef::Url("https://example.com".to_string())),
|
||||
..Default::default()
|
||||
});
|
||||
@@ -166,8 +166,8 @@ mod tests {
|
||||
|
||||
fn make_builder(f: impl FnOnce(&mut GenerateVideoRequestBuilder)) -> GenerateVideoRequestBuilder {
|
||||
let mut builder = GenerateVideoRequestBuilder {
|
||||
model: CommonVideoModel::PreviewModelFast,
|
||||
provider: Provider::Artcraft,
|
||||
model: RouterVideoModel::PreviewModelFast,
|
||||
provider: RouterProvider::Artcraft,
|
||||
duration_seconds: Some(5),
|
||||
video_batch_count: Some(1),
|
||||
..Default::default()
|
||||
|
||||
+32
-32
@@ -52,9 +52,9 @@ impl ArtcraftPreviewModelFastCostState {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::api::common_resolution::CommonResolution;
|
||||
use crate::api::common_video_model::CommonVideoModel;
|
||||
use crate::api::provider::Provider;
|
||||
use crate::api::router_resolution::RouterResolution;
|
||||
use crate::api::router_video_model::RouterVideoModel;
|
||||
use crate::api::router_provider::RouterProvider;
|
||||
use crate::generate::generate_video::generate_video_request_builder::GenerateVideoRequestBuilder;
|
||||
|
||||
// -- 720p pricing --
|
||||
@@ -64,27 +64,27 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn batch_1() {
|
||||
assert_eq!(cost_cents(Some(CommonResolution::SevenTwentyP), 4, 1), 80);
|
||||
assert_eq!(cost_cents(Some(CommonResolution::SevenTwentyP), 5, 1), 100);
|
||||
assert_eq!(cost_cents(Some(CommonResolution::SevenTwentyP), 10, 1), 200);
|
||||
assert_eq!(cost_cents(Some(CommonResolution::SevenTwentyP), 15, 1), 300);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::SevenTwentyP), 4, 1), 80);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::SevenTwentyP), 5, 1), 100);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::SevenTwentyP), 10, 1), 200);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::SevenTwentyP), 15, 1), 300);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn batch_2() {
|
||||
assert_eq!(cost_cents(Some(CommonResolution::SevenTwentyP), 5, 2), 200);
|
||||
assert_eq!(cost_cents(Some(CommonResolution::SevenTwentyP), 15, 2), 600);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::SevenTwentyP), 5, 2), 200);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::SevenTwentyP), 15, 2), 600);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn batch_4() {
|
||||
assert_eq!(cost_cents(Some(CommonResolution::SevenTwentyP), 5, 4), 400);
|
||||
assert_eq!(cost_cents(Some(CommonResolution::SevenTwentyP), 15, 4), 1200);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::SevenTwentyP), 5, 4), 400);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::SevenTwentyP), 15, 4), 1200);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn none_defaults_to_720p() {
|
||||
assert_eq!(cost_cents(None, 5, 1), cost_cents(Some(CommonResolution::SevenTwentyP), 5, 1));
|
||||
assert_eq!(cost_cents(None, 5, 1), cost_cents(Some(RouterResolution::SevenTwentyP), 5, 1));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,20 +95,20 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn batch_1() {
|
||||
assert_eq!(cost_cents(Some(CommonResolution::FourEightyP), 4, 1), 36);
|
||||
assert_eq!(cost_cents(Some(CommonResolution::FourEightyP), 5, 1), 45);
|
||||
assert_eq!(cost_cents(Some(CommonResolution::FourEightyP), 10, 1), 90);
|
||||
assert_eq!(cost_cents(Some(CommonResolution::FourEightyP), 15, 1), 135);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::FourEightyP), 4, 1), 36);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::FourEightyP), 5, 1), 45);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::FourEightyP), 10, 1), 90);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::FourEightyP), 15, 1), 135);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn batch_2() {
|
||||
assert_eq!(cost_cents(Some(CommonResolution::FourEightyP), 5, 2), 90);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::FourEightyP), 5, 2), 90);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn batch_4() {
|
||||
assert_eq!(cost_cents(Some(CommonResolution::FourEightyP), 5, 4), 180);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::FourEightyP), 5, 4), 180);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,25 +119,25 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn cost_480p_cheaper_than_720p() {
|
||||
let c480 = cost_cents(Some(CommonResolution::FourEightyP), 5, 1);
|
||||
let c720 = cost_cents(Some(CommonResolution::SevenTwentyP), 5, 1);
|
||||
let c480 = cost_cents(Some(RouterResolution::FourEightyP), 5, 1);
|
||||
let c720 = cost_cents(Some(RouterResolution::SevenTwentyP), 5, 1);
|
||||
assert!(c480 < c720);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn cost_scales_with_duration() {
|
||||
let c4 = cost_cents(Some(CommonResolution::SevenTwentyP), 4, 1);
|
||||
let c10 = cost_cents(Some(CommonResolution::SevenTwentyP), 10, 1);
|
||||
let c15 = cost_cents(Some(CommonResolution::SevenTwentyP), 15, 1);
|
||||
let c4 = cost_cents(Some(RouterResolution::SevenTwentyP), 4, 1);
|
||||
let c10 = cost_cents(Some(RouterResolution::SevenTwentyP), 10, 1);
|
||||
let c15 = cost_cents(Some(RouterResolution::SevenTwentyP), 15, 1);
|
||||
assert!(c4 < c10);
|
||||
assert!(c10 < c15);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn cost_scales_with_batch() {
|
||||
let b1 = cost_cents(Some(CommonResolution::SevenTwentyP), 5, 1);
|
||||
let b2 = cost_cents(Some(CommonResolution::SevenTwentyP), 5, 2);
|
||||
let b4 = cost_cents(Some(CommonResolution::SevenTwentyP), 5, 4);
|
||||
let b1 = cost_cents(Some(RouterResolution::SevenTwentyP), 5, 1);
|
||||
let b2 = cost_cents(Some(RouterResolution::SevenTwentyP), 5, 2);
|
||||
let b4 = cost_cents(Some(RouterResolution::SevenTwentyP), 5, 4);
|
||||
assert!(b1 < b2);
|
||||
assert!(b2 < b4);
|
||||
}
|
||||
@@ -151,8 +151,8 @@ mod tests {
|
||||
#[test]
|
||||
fn credits_equal_usd_cents_all_combos() {
|
||||
let resolutions = [
|
||||
Some(CommonResolution::FourEightyP),
|
||||
Some(CommonResolution::SevenTwentyP),
|
||||
Some(RouterResolution::FourEightyP),
|
||||
Some(RouterResolution::SevenTwentyP),
|
||||
None,
|
||||
];
|
||||
for res in resolutions {
|
||||
@@ -173,13 +173,13 @@ mod tests {
|
||||
// -- Helpers --
|
||||
|
||||
fn build_cost(
|
||||
resolution: Option<CommonResolution>,
|
||||
resolution: Option<RouterResolution>,
|
||||
duration_seconds: u16,
|
||||
video_batch_count: u16,
|
||||
) -> crate::generate::generate_video::video_generation_cost_estimate::VideoGenerationCostEstimate {
|
||||
let builder = GenerateVideoRequestBuilder {
|
||||
model: CommonVideoModel::PreviewModelFast,
|
||||
provider: Provider::Artcraft,
|
||||
model: RouterVideoModel::PreviewModelFast,
|
||||
provider: RouterProvider::Artcraft,
|
||||
resolution,
|
||||
duration_seconds: Some(duration_seconds),
|
||||
video_batch_count: Some(video_batch_count),
|
||||
@@ -192,7 +192,7 @@ mod tests {
|
||||
}
|
||||
|
||||
fn cost_cents(
|
||||
resolution: Option<CommonResolution>,
|
||||
resolution: Option<RouterResolution>,
|
||||
duration_seconds: u16,
|
||||
video_batch_count: u16,
|
||||
) -> u64 {
|
||||
|
||||
+10
-10
@@ -57,15 +57,15 @@ impl ArtcraftSeedance10LiteCostState {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::api::common_resolution::CommonResolution;
|
||||
use crate::api::common_video_model::CommonVideoModel;
|
||||
use crate::api::provider::Provider;
|
||||
use crate::api::router_resolution::RouterResolution;
|
||||
use crate::api::router_video_model::RouterVideoModel;
|
||||
use crate::api::router_provider::RouterProvider;
|
||||
use crate::generate::generate_video::generate_video_request_builder::GenerateVideoRequestBuilder;
|
||||
|
||||
fn cost_cents(duration_seconds: Option<u16>, resolution: Option<CommonResolution>) -> u64 {
|
||||
fn cost_cents(duration_seconds: Option<u16>, resolution: Option<RouterResolution>) -> u64 {
|
||||
let b = GenerateVideoRequestBuilder {
|
||||
model: CommonVideoModel::Seedance10Lite,
|
||||
provider: Provider::Artcraft,
|
||||
model: RouterVideoModel::Seedance10Lite,
|
||||
provider: RouterProvider::Artcraft,
|
||||
prompt: Some("test".to_string()),
|
||||
duration_seconds,
|
||||
resolution,
|
||||
@@ -81,22 +81,22 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn p720_5s_is_18() { assert_eq!(cost_cents(Some(5), Some(CommonResolution::SevenTwentyP)), 18); }
|
||||
fn p720_5s_is_18() { assert_eq!(cost_cents(Some(5), Some(RouterResolution::SevenTwentyP)), 18); }
|
||||
|
||||
#[test]
|
||||
fn p720_10s_is_95() {
|
||||
// 1280×720×30×10/1024 = 270000 tokens × $1.8/M = $0.486 → ceil = 49¢ ...
|
||||
// No wait — fal kling not seedance. The Seedance 1.0 Lite rate is different.
|
||||
// Trust the fal calculator: assert whatever the actual computed value is.
|
||||
let v = cost_cents(Some(10), Some(CommonResolution::SevenTwentyP));
|
||||
let v = cost_cents(Some(10), Some(RouterResolution::SevenTwentyP));
|
||||
assert!(v > 18, "10s should cost more than 5s, got {}", v);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn p480_5s_cheaper_than_p720_5s() {
|
||||
assert!(
|
||||
cost_cents(Some(5), Some(CommonResolution::FourEightyP))
|
||||
< cost_cents(Some(5), Some(CommonResolution::SevenTwentyP))
|
||||
cost_cents(Some(5), Some(RouterResolution::FourEightyP))
|
||||
< cost_cents(Some(5), Some(RouterResolution::SevenTwentyP))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -78,14 +78,14 @@ fn common_resolution_to_seedance(r: CommonResolutionEnum) -> Option<EnqueueSeeda
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::api::common_video_model::CommonVideoModel;
|
||||
use crate::api::provider::Provider;
|
||||
use crate::api::router_video_model::RouterVideoModel;
|
||||
use crate::api::router_provider::RouterProvider;
|
||||
use crate::generate::generate_video::generate_video_request_builder::GenerateVideoRequestBuilder;
|
||||
|
||||
fn cost_cents(duration_seconds: Option<u16>) -> u64 {
|
||||
let b = GenerateVideoRequestBuilder {
|
||||
model: CommonVideoModel::Seedance1p5Pro,
|
||||
provider: Provider::Artcraft,
|
||||
model: RouterVideoModel::Seedance1p5Pro,
|
||||
provider: RouterProvider::Artcraft,
|
||||
prompt: Some("test".to_string()),
|
||||
duration_seconds,
|
||||
..Default::default()
|
||||
|
||||
+6
-6
@@ -28,10 +28,10 @@ mod tests {
|
||||
use tokens::tokens::media_files::MediaFileToken;
|
||||
|
||||
use crate::api::character_list_ref::CharacterListRef;
|
||||
use crate::api::common_resolution::CommonResolution;
|
||||
use crate::api::router_resolution::RouterResolution;
|
||||
use crate::api::image_list_ref::ImageListRef;
|
||||
use crate::api::image_ref::ImageRef;
|
||||
use crate::api::provider::Provider;
|
||||
use crate::api::router_provider::RouterProvider;
|
||||
use crate::generate::generate_video::generate_video_request_builder::GenerateVideoRequestBuilder;
|
||||
use crate::generate::generate_video_v2::video_generation_draft_or_request::VideoGenerationDraftOrRequest;
|
||||
use crate::generate::generate_video_v2::video_generation_request::VideoGenerationRequest;
|
||||
@@ -81,19 +81,19 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn res_480p() {
|
||||
let req = unwrap_request(make_builder(|b| { b.resolution = Some(CommonResolution::FourEightyP); }));
|
||||
let req = unwrap_request(make_builder(|b| { b.resolution = Some(RouterResolution::FourEightyP); }));
|
||||
assert_eq!(req.request.resolution, Some(CommonResolutionEnum::FourEightyP));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn res_720p() {
|
||||
let req = unwrap_request(make_builder(|b| { b.resolution = Some(CommonResolution::SevenTwentyP); }));
|
||||
let req = unwrap_request(make_builder(|b| { b.resolution = Some(RouterResolution::SevenTwentyP); }));
|
||||
assert_eq!(req.request.resolution, Some(CommonResolutionEnum::SevenTwentyP));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn res_1080p() {
|
||||
let req = unwrap_request(make_builder(|b| { b.resolution = Some(CommonResolution::TenEightyP); }));
|
||||
let req = unwrap_request(make_builder(|b| { b.resolution = Some(RouterResolution::TenEightyP); }));
|
||||
assert_eq!(req.request.resolution, Some(CommonResolutionEnum::TenEightyP));
|
||||
}
|
||||
|
||||
@@ -150,7 +150,7 @@ mod tests {
|
||||
|
||||
fn base_builder() -> GenerateVideoRequestBuilder {
|
||||
GenerateVideoRequestBuilder {
|
||||
provider: Provider::Artcraft,
|
||||
provider: RouterProvider::Artcraft,
|
||||
duration_seconds: Some(5),
|
||||
video_batch_count: Some(1),
|
||||
..Default::default()
|
||||
|
||||
+45
-45
@@ -67,8 +67,8 @@ impl ArtcraftSeedance2p0CostState {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::api::common_resolution::CommonResolution;
|
||||
use crate::api::provider::Provider;
|
||||
use crate::api::router_resolution::RouterResolution;
|
||||
use crate::api::router_provider::RouterProvider;
|
||||
use crate::generate::generate_video::generate_video_request_builder::GenerateVideoRequestBuilder;
|
||||
|
||||
// -- 720p pricing --
|
||||
@@ -78,30 +78,30 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn batch_1() {
|
||||
assert_eq!(cost_cents(Some(CommonResolution::SevenTwentyP), 4, 1), 64);
|
||||
assert_eq!(cost_cents(Some(CommonResolution::SevenTwentyP), 5, 1), 80);
|
||||
assert_eq!(cost_cents(Some(CommonResolution::SevenTwentyP), 6, 1), 96);
|
||||
assert_eq!(cost_cents(Some(CommonResolution::SevenTwentyP), 10, 1), 160);
|
||||
assert_eq!(cost_cents(Some(CommonResolution::SevenTwentyP), 15, 1), 240);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::SevenTwentyP), 4, 1), 64);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::SevenTwentyP), 5, 1), 80);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::SevenTwentyP), 6, 1), 96);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::SevenTwentyP), 10, 1), 160);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::SevenTwentyP), 15, 1), 240);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn batch_2() {
|
||||
assert_eq!(cost_cents(Some(CommonResolution::SevenTwentyP), 4, 2), 128);
|
||||
assert_eq!(cost_cents(Some(CommonResolution::SevenTwentyP), 5, 2), 160);
|
||||
assert_eq!(cost_cents(Some(CommonResolution::SevenTwentyP), 15, 2), 480);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::SevenTwentyP), 4, 2), 128);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::SevenTwentyP), 5, 2), 160);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::SevenTwentyP), 15, 2), 480);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn batch_4() {
|
||||
assert_eq!(cost_cents(Some(CommonResolution::SevenTwentyP), 4, 4), 256);
|
||||
assert_eq!(cost_cents(Some(CommonResolution::SevenTwentyP), 5, 4), 320);
|
||||
assert_eq!(cost_cents(Some(CommonResolution::SevenTwentyP), 15, 4), 960);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::SevenTwentyP), 4, 4), 256);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::SevenTwentyP), 5, 4), 320);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::SevenTwentyP), 15, 4), 960);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn none_defaults_to_720p() {
|
||||
assert_eq!(cost_cents(None, 5, 1), cost_cents(Some(CommonResolution::SevenTwentyP), 5, 1));
|
||||
assert_eq!(cost_cents(None, 5, 1), cost_cents(Some(RouterResolution::SevenTwentyP), 5, 1));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,20 +112,20 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn batch_1() {
|
||||
assert_eq!(cost_cents(Some(CommonResolution::FourEightyP), 4, 1), 31);
|
||||
assert_eq!(cost_cents(Some(CommonResolution::FourEightyP), 5, 1), 39);
|
||||
assert_eq!(cost_cents(Some(CommonResolution::FourEightyP), 10, 1), 78);
|
||||
assert_eq!(cost_cents(Some(CommonResolution::FourEightyP), 15, 1), 117);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::FourEightyP), 4, 1), 31);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::FourEightyP), 5, 1), 39);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::FourEightyP), 10, 1), 78);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::FourEightyP), 15, 1), 117);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn batch_2() {
|
||||
assert_eq!(cost_cents(Some(CommonResolution::FourEightyP), 5, 2), 78);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::FourEightyP), 5, 2), 78);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn batch_4() {
|
||||
assert_eq!(cost_cents(Some(CommonResolution::FourEightyP), 5, 4), 155);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::FourEightyP), 5, 4), 155);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,20 +136,20 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn batch_1() {
|
||||
assert_eq!(cost_cents(Some(CommonResolution::TenEightyP), 4, 1), 187);
|
||||
assert_eq!(cost_cents(Some(CommonResolution::TenEightyP), 5, 1), 233);
|
||||
assert_eq!(cost_cents(Some(CommonResolution::TenEightyP), 10, 1), 466);
|
||||
assert_eq!(cost_cents(Some(CommonResolution::TenEightyP), 15, 1), 699);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::TenEightyP), 4, 1), 187);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::TenEightyP), 5, 1), 233);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::TenEightyP), 10, 1), 466);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::TenEightyP), 15, 1), 699);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn batch_2() {
|
||||
assert_eq!(cost_cents(Some(CommonResolution::TenEightyP), 5, 2), 466);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::TenEightyP), 5, 2), 466);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn batch_4() {
|
||||
assert_eq!(cost_cents(Some(CommonResolution::TenEightyP), 5, 4), 933);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::TenEightyP), 5, 4), 933);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -160,27 +160,27 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn cost_480p_cheaper_than_720p_cheaper_than_1080p() {
|
||||
let c480 = cost_cents(Some(CommonResolution::FourEightyP), 5, 1);
|
||||
let c720 = cost_cents(Some(CommonResolution::SevenTwentyP), 5, 1);
|
||||
let c1080 = cost_cents(Some(CommonResolution::TenEightyP), 5, 1);
|
||||
let c480 = cost_cents(Some(RouterResolution::FourEightyP), 5, 1);
|
||||
let c720 = cost_cents(Some(RouterResolution::SevenTwentyP), 5, 1);
|
||||
let c1080 = cost_cents(Some(RouterResolution::TenEightyP), 5, 1);
|
||||
assert!(c480 < c720);
|
||||
assert!(c720 < c1080);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn cost_scales_with_duration() {
|
||||
let c4 = cost_cents(Some(CommonResolution::SevenTwentyP), 4, 1);
|
||||
let c10 = cost_cents(Some(CommonResolution::SevenTwentyP), 10, 1);
|
||||
let c15 = cost_cents(Some(CommonResolution::SevenTwentyP), 15, 1);
|
||||
let c4 = cost_cents(Some(RouterResolution::SevenTwentyP), 4, 1);
|
||||
let c10 = cost_cents(Some(RouterResolution::SevenTwentyP), 10, 1);
|
||||
let c15 = cost_cents(Some(RouterResolution::SevenTwentyP), 15, 1);
|
||||
assert!(c4 < c10);
|
||||
assert!(c10 < c15);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn cost_scales_with_batch() {
|
||||
let b1 = cost_cents(Some(CommonResolution::TenEightyP), 5, 1);
|
||||
let b2 = cost_cents(Some(CommonResolution::TenEightyP), 5, 2);
|
||||
let b4 = cost_cents(Some(CommonResolution::TenEightyP), 5, 4);
|
||||
let b1 = cost_cents(Some(RouterResolution::TenEightyP), 5, 1);
|
||||
let b2 = cost_cents(Some(RouterResolution::TenEightyP), 5, 2);
|
||||
let b4 = cost_cents(Some(RouterResolution::TenEightyP), 5, 4);
|
||||
assert!(b1 < b2);
|
||||
assert!(b2 < b4);
|
||||
}
|
||||
@@ -194,9 +194,9 @@ mod tests {
|
||||
#[test]
|
||||
fn credits_equal_usd_cents_all_combos() {
|
||||
let resolutions = [
|
||||
Some(CommonResolution::FourEightyP),
|
||||
Some(CommonResolution::SevenTwentyP),
|
||||
Some(CommonResolution::TenEightyP),
|
||||
Some(RouterResolution::FourEightyP),
|
||||
Some(RouterResolution::SevenTwentyP),
|
||||
Some(RouterResolution::TenEightyP),
|
||||
None,
|
||||
];
|
||||
for res in resolutions {
|
||||
@@ -222,10 +222,10 @@ mod tests {
|
||||
#[test]
|
||||
fn artcraft_matches_kinovi_all_combos() {
|
||||
let resolutions = [
|
||||
Some(CommonResolution::FourEightyP),
|
||||
Some(CommonResolution::TenEightyP),
|
||||
Some(RouterResolution::FourEightyP),
|
||||
Some(RouterResolution::TenEightyP),
|
||||
// NB: These are underpriced (for now)
|
||||
//Some(CommonResolution::SevenTwentyP),
|
||||
//Some(RouterResolution::SevenTwentyP),
|
||||
//None,
|
||||
];
|
||||
let durations: [u16; 4] = [4, 5, 10, 15];
|
||||
@@ -237,7 +237,7 @@ mod tests {
|
||||
let artcraft_cost = build_cost(*res, *dur, *batch);
|
||||
|
||||
let kinovi = GenerateVideoRequestBuilder {
|
||||
provider: Provider::Seedance2Pro,
|
||||
provider: RouterProvider::Seedance2Pro,
|
||||
resolution: *res,
|
||||
duration_seconds: Some(*dur),
|
||||
video_batch_count: Some(*batch),
|
||||
@@ -263,12 +263,12 @@ mod tests {
|
||||
|
||||
/// Build a cost estimate end-to-end: GenerateVideoRequestBuilder → build2 → estimate_cost.
|
||||
fn build_cost(
|
||||
resolution: Option<CommonResolution>,
|
||||
resolution: Option<RouterResolution>,
|
||||
duration_seconds: u16,
|
||||
video_batch_count: u16,
|
||||
) -> crate::generate::generate_video::video_generation_cost_estimate::VideoGenerationCostEstimate {
|
||||
let builder = GenerateVideoRequestBuilder {
|
||||
provider: Provider::Artcraft,
|
||||
provider: RouterProvider::Artcraft,
|
||||
resolution,
|
||||
duration_seconds: Some(duration_seconds),
|
||||
video_batch_count: Some(video_batch_count),
|
||||
@@ -281,7 +281,7 @@ mod tests {
|
||||
}
|
||||
|
||||
fn cost_cents(
|
||||
resolution: Option<CommonResolution>,
|
||||
resolution: Option<RouterResolution>,
|
||||
duration_seconds: u16,
|
||||
video_batch_count: u16,
|
||||
) -> u64 {
|
||||
|
||||
+14
-14
@@ -22,11 +22,11 @@ mod tests {
|
||||
use tokens::tokens::media_files::MediaFileToken;
|
||||
|
||||
use crate::api::character_list_ref::CharacterListRef;
|
||||
use crate::api::common_aspect_ratio::CommonAspectRatio;
|
||||
use crate::api::common_resolution::CommonResolution;
|
||||
use crate::api::router_aspect_ratio::RouterAspectRatio;
|
||||
use crate::api::router_resolution::RouterResolution;
|
||||
use crate::api::image_list_ref::ImageListRef;
|
||||
use crate::api::image_ref::ImageRef;
|
||||
use crate::api::provider::Provider;
|
||||
use crate::api::router_provider::RouterProvider;
|
||||
use crate::client::router_artcraft_client::RouterArtcraftClient;
|
||||
use crate::client::router_client::RouterClient;
|
||||
use crate::generate::generate_video::generate_video_request_builder::GenerateVideoRequestBuilder;
|
||||
@@ -52,7 +52,7 @@ mod tests {
|
||||
async fn landscape() {
|
||||
let response = run_pipeline(GenerateVideoRequestBuilder {
|
||||
prompt: Some("A corgi running through a field of wildflowers at sunset.".to_string()),
|
||||
aspect_ratio: Some(CommonAspectRatio::WideSixteenByNine),
|
||||
aspect_ratio: Some(RouterAspectRatio::WideSixteenByNine),
|
||||
..artcraft_builder()
|
||||
}).await;
|
||||
assert!(matches!(response, GenerateVideoResponse::Artcraft(_)));
|
||||
@@ -64,7 +64,7 @@ mod tests {
|
||||
async fn portrait() {
|
||||
let response = run_pipeline(GenerateVideoRequestBuilder {
|
||||
prompt: Some("A cat sitting on a windowsill watching rain.".to_string()),
|
||||
aspect_ratio: Some(CommonAspectRatio::TallNineBySixteen),
|
||||
aspect_ratio: Some(RouterAspectRatio::TallNineBySixteen),
|
||||
..artcraft_builder()
|
||||
}).await;
|
||||
assert!(matches!(response, GenerateVideoResponse::Artcraft(_)));
|
||||
@@ -76,7 +76,7 @@ mod tests {
|
||||
async fn square() {
|
||||
let response = run_pipeline(GenerateVideoRequestBuilder {
|
||||
prompt: Some("A hummingbird hovering near a flower.".to_string()),
|
||||
aspect_ratio: Some(CommonAspectRatio::Square),
|
||||
aspect_ratio: Some(RouterAspectRatio::Square),
|
||||
..artcraft_builder()
|
||||
}).await;
|
||||
assert!(matches!(response, GenerateVideoResponse::Artcraft(_)));
|
||||
@@ -94,7 +94,7 @@ mod tests {
|
||||
async fn res_480p() {
|
||||
let response = run_pipeline(GenerateVideoRequestBuilder {
|
||||
prompt: Some("A shiba inu playing in autumn leaves.".to_string()),
|
||||
resolution: Some(CommonResolution::FourEightyP),
|
||||
resolution: Some(RouterResolution::FourEightyP),
|
||||
..artcraft_builder()
|
||||
}).await;
|
||||
assert!(matches!(response, GenerateVideoResponse::Artcraft(_)));
|
||||
@@ -106,7 +106,7 @@ mod tests {
|
||||
async fn res_720p() {
|
||||
let response = run_pipeline(GenerateVideoRequestBuilder {
|
||||
prompt: Some("A golden retriever catching a frisbee on the beach.".to_string()),
|
||||
resolution: Some(CommonResolution::SevenTwentyP),
|
||||
resolution: Some(RouterResolution::SevenTwentyP),
|
||||
..artcraft_builder()
|
||||
}).await;
|
||||
assert!(matches!(response, GenerateVideoResponse::Artcraft(_)));
|
||||
@@ -118,7 +118,7 @@ mod tests {
|
||||
async fn res_1080p() {
|
||||
let response = run_pipeline(GenerateVideoRequestBuilder {
|
||||
prompt: Some("A fox walking through a snowy forest.".to_string()),
|
||||
resolution: Some(CommonResolution::TenEightyP),
|
||||
resolution: Some(RouterResolution::TenEightyP),
|
||||
..artcraft_builder()
|
||||
}).await;
|
||||
assert!(matches!(response, GenerateVideoResponse::Artcraft(_)));
|
||||
@@ -137,7 +137,7 @@ mod tests {
|
||||
async fn text_to_video() {
|
||||
let response = run_pipeline(GenerateVideoRequestBuilder {
|
||||
prompt: Some("A whale breaching in the open ocean at dawn, cinematic.".to_string()),
|
||||
aspect_ratio: Some(CommonAspectRatio::WideSixteenByNine),
|
||||
aspect_ratio: Some(RouterAspectRatio::WideSixteenByNine),
|
||||
..artcraft_builder()
|
||||
}).await;
|
||||
assert!(matches!(response, GenerateVideoResponse::Artcraft(_)));
|
||||
@@ -151,7 +151,7 @@ mod tests {
|
||||
prompt: Some("The dog walks from the lake to the forest.".to_string()),
|
||||
start_frame: Some(ImageRef::MediaFileToken(MediaFileToken::new(JUNO_AT_LAKE_PRODUCTION_MEDIA_TOKEN.to_string()))),
|
||||
end_frame: Some(ImageRef::MediaFileToken(MediaFileToken::new(FOREST_BACKDROP_PRODUCTION_MEDIA_TOKEN.to_string()))),
|
||||
aspect_ratio: Some(CommonAspectRatio::WideSixteenByNine),
|
||||
aspect_ratio: Some(RouterAspectRatio::WideSixteenByNine),
|
||||
..artcraft_builder()
|
||||
}).await;
|
||||
assert!(matches!(response, GenerateVideoResponse::Artcraft(_)));
|
||||
@@ -168,7 +168,7 @@ mod tests {
|
||||
MediaFileToken::new(TALL_MOCHI_WITH_GLASSES_PRODUCTION_MEDIA_TOKEN.to_string()),
|
||||
MediaFileToken::new(WHITE_HOUSE_SUNSET_PRODUCTION_MEDIA_TOKEN.to_string()),
|
||||
])),
|
||||
aspect_ratio: Some(CommonAspectRatio::WideSixteenByNine),
|
||||
aspect_ratio: Some(RouterAspectRatio::WideSixteenByNine),
|
||||
..artcraft_builder()
|
||||
}).await;
|
||||
assert!(matches!(response, GenerateVideoResponse::Artcraft(_)));
|
||||
@@ -184,7 +184,7 @@ mod tests {
|
||||
CharacterToken::new(JIM.token.to_string()),
|
||||
CharacterToken::new(KNIGHT.token.to_string()),
|
||||
])),
|
||||
aspect_ratio: Some(CommonAspectRatio::WideSixteenByNine),
|
||||
aspect_ratio: Some(RouterAspectRatio::WideSixteenByNine),
|
||||
..artcraft_builder()
|
||||
}).await;
|
||||
assert!(matches!(response, GenerateVideoResponse::Artcraft(_)));
|
||||
@@ -196,7 +196,7 @@ mod tests {
|
||||
|
||||
fn artcraft_builder() -> GenerateVideoRequestBuilder {
|
||||
GenerateVideoRequestBuilder {
|
||||
provider: Provider::Artcraft,
|
||||
provider: RouterProvider::Artcraft,
|
||||
duration_seconds: Some(4),
|
||||
video_batch_count: Some(1),
|
||||
..Default::default()
|
||||
|
||||
+6
-6
@@ -28,10 +28,10 @@ mod tests {
|
||||
use tokens::tokens::media_files::MediaFileToken;
|
||||
|
||||
use crate::api::character_list_ref::CharacterListRef;
|
||||
use crate::api::common_resolution::CommonResolution;
|
||||
use crate::api::router_resolution::RouterResolution;
|
||||
use crate::api::image_list_ref::ImageListRef;
|
||||
use crate::api::image_ref::ImageRef;
|
||||
use crate::api::provider::Provider;
|
||||
use crate::api::router_provider::RouterProvider;
|
||||
use crate::generate::generate_video::generate_video_request_builder::GenerateVideoRequestBuilder;
|
||||
use crate::generate::generate_video_v2::video_generation_draft_or_request::VideoGenerationDraftOrRequest;
|
||||
use crate::generate::generate_video_v2::video_generation_request::VideoGenerationRequest;
|
||||
@@ -77,19 +77,19 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn res_480p() {
|
||||
let req = unwrap_request(make_builder(|b| { b.resolution = Some(CommonResolution::FourEightyP); }));
|
||||
let req = unwrap_request(make_builder(|b| { b.resolution = Some(RouterResolution::FourEightyP); }));
|
||||
assert_eq!(req.request.resolution, Some(CommonResolutionEnum::FourEightyP));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn res_720p() {
|
||||
let req = unwrap_request(make_builder(|b| { b.resolution = Some(CommonResolution::SevenTwentyP); }));
|
||||
let req = unwrap_request(make_builder(|b| { b.resolution = Some(RouterResolution::SevenTwentyP); }));
|
||||
assert_eq!(req.request.resolution, Some(CommonResolutionEnum::SevenTwentyP));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn res_1080p() {
|
||||
let req = unwrap_request(make_builder(|b| { b.resolution = Some(CommonResolution::TenEightyP); }));
|
||||
let req = unwrap_request(make_builder(|b| { b.resolution = Some(RouterResolution::TenEightyP); }));
|
||||
assert_eq!(req.request.resolution, Some(CommonResolutionEnum::TenEightyP));
|
||||
}
|
||||
|
||||
@@ -142,7 +142,7 @@ mod tests {
|
||||
|
||||
fn base_builder() -> GenerateVideoRequestBuilder {
|
||||
GenerateVideoRequestBuilder {
|
||||
provider: Provider::Artcraft,
|
||||
provider: RouterProvider::Artcraft,
|
||||
duration_seconds: Some(5),
|
||||
video_batch_count: Some(1),
|
||||
..Default::default()
|
||||
|
||||
+30
-30
@@ -49,9 +49,9 @@ impl ArtcraftSeedance2p0BytePlusCostState {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::api::common_resolution::CommonResolution;
|
||||
use crate::api::common_video_model::CommonVideoModel;
|
||||
use crate::api::provider::Provider;
|
||||
use crate::api::router_resolution::RouterResolution;
|
||||
use crate::api::router_video_model::RouterVideoModel;
|
||||
use crate::api::router_provider::RouterProvider;
|
||||
use crate::generate::generate_video::generate_video_request_builder::GenerateVideoRequestBuilder;
|
||||
|
||||
mod pricing_720p {
|
||||
@@ -59,25 +59,25 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn batch_1() {
|
||||
assert_eq!(cost_cents(Some(CommonResolution::SevenTwentyP), 4, 1), 100);
|
||||
assert_eq!(cost_cents(Some(CommonResolution::SevenTwentyP), 5, 1), 125);
|
||||
assert_eq!(cost_cents(Some(CommonResolution::SevenTwentyP), 10, 1), 250);
|
||||
assert_eq!(cost_cents(Some(CommonResolution::SevenTwentyP), 15, 1), 375);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::SevenTwentyP), 4, 1), 100);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::SevenTwentyP), 5, 1), 125);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::SevenTwentyP), 10, 1), 250);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::SevenTwentyP), 15, 1), 375);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn batch_2() {
|
||||
assert_eq!(cost_cents(Some(CommonResolution::SevenTwentyP), 5, 2), 250);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::SevenTwentyP), 5, 2), 250);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn batch_4() {
|
||||
assert_eq!(cost_cents(Some(CommonResolution::SevenTwentyP), 5, 4), 500);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::SevenTwentyP), 5, 4), 500);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn none_defaults_to_720p() {
|
||||
assert_eq!(cost_cents(None, 5, 1), cost_cents(Some(CommonResolution::SevenTwentyP), 5, 1));
|
||||
assert_eq!(cost_cents(None, 5, 1), cost_cents(Some(RouterResolution::SevenTwentyP), 5, 1));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,20 +86,20 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn batch_1() {
|
||||
assert_eq!(cost_cents(Some(CommonResolution::FourEightyP), 4, 1), 40);
|
||||
assert_eq!(cost_cents(Some(CommonResolution::FourEightyP), 5, 1), 50);
|
||||
assert_eq!(cost_cents(Some(CommonResolution::FourEightyP), 10, 1), 100);
|
||||
assert_eq!(cost_cents(Some(CommonResolution::FourEightyP), 15, 1), 150);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::FourEightyP), 4, 1), 40);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::FourEightyP), 5, 1), 50);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::FourEightyP), 10, 1), 100);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::FourEightyP), 15, 1), 150);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn batch_2() {
|
||||
assert_eq!(cost_cents(Some(CommonResolution::FourEightyP), 5, 2), 100);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::FourEightyP), 5, 2), 100);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn batch_4() {
|
||||
assert_eq!(cost_cents(Some(CommonResolution::FourEightyP), 5, 4), 200);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::FourEightyP), 5, 4), 200);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,20 +108,20 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn batch_1() {
|
||||
assert_eq!(cost_cents(Some(CommonResolution::TenEightyP), 4, 1), 200);
|
||||
assert_eq!(cost_cents(Some(CommonResolution::TenEightyP), 5, 1), 250);
|
||||
assert_eq!(cost_cents(Some(CommonResolution::TenEightyP), 10, 1), 500);
|
||||
assert_eq!(cost_cents(Some(CommonResolution::TenEightyP), 15, 1), 750);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::TenEightyP), 4, 1), 200);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::TenEightyP), 5, 1), 250);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::TenEightyP), 10, 1), 500);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::TenEightyP), 15, 1), 750);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn batch_2() {
|
||||
assert_eq!(cost_cents(Some(CommonResolution::TenEightyP), 5, 2), 500);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::TenEightyP), 5, 2), 500);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn batch_4() {
|
||||
assert_eq!(cost_cents(Some(CommonResolution::TenEightyP), 5, 4), 1000);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::TenEightyP), 5, 4), 1000);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,9 +130,9 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn cost_480p_cheaper_than_720p_cheaper_than_1080p() {
|
||||
let c480 = cost_cents(Some(CommonResolution::FourEightyP), 5, 1);
|
||||
let c720 = cost_cents(Some(CommonResolution::SevenTwentyP), 5, 1);
|
||||
let c1080 = cost_cents(Some(CommonResolution::TenEightyP), 5, 1);
|
||||
let c480 = cost_cents(Some(RouterResolution::FourEightyP), 5, 1);
|
||||
let c720 = cost_cents(Some(RouterResolution::SevenTwentyP), 5, 1);
|
||||
let c1080 = cost_cents(Some(RouterResolution::TenEightyP), 5, 1);
|
||||
assert!(c480 < c720);
|
||||
assert!(c720 < c1080);
|
||||
}
|
||||
@@ -143,7 +143,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn credits_equal_usd_cents() {
|
||||
for res in [Some(CommonResolution::FourEightyP), Some(CommonResolution::SevenTwentyP), Some(CommonResolution::TenEightyP), None] {
|
||||
for res in [Some(RouterResolution::FourEightyP), Some(RouterResolution::SevenTwentyP), Some(RouterResolution::TenEightyP), None] {
|
||||
for dur in [4, 5, 10, 15] {
|
||||
for batch in [1, 2, 4] {
|
||||
let cost = build_cost(res, dur, batch);
|
||||
@@ -155,13 +155,13 @@ mod tests {
|
||||
}
|
||||
|
||||
fn build_cost(
|
||||
resolution: Option<CommonResolution>,
|
||||
resolution: Option<RouterResolution>,
|
||||
duration_seconds: u16,
|
||||
video_batch_count: u16,
|
||||
) -> crate::generate::generate_video::video_generation_cost_estimate::VideoGenerationCostEstimate {
|
||||
GenerateVideoRequestBuilder {
|
||||
model: CommonVideoModel::Seedance2p0BytePlus,
|
||||
provider: Provider::Artcraft,
|
||||
model: RouterVideoModel::Seedance2p0BytePlus,
|
||||
provider: RouterProvider::Artcraft,
|
||||
resolution,
|
||||
duration_seconds: Some(duration_seconds),
|
||||
video_batch_count: Some(video_batch_count),
|
||||
@@ -169,7 +169,7 @@ mod tests {
|
||||
}.build2().expect("build2").estimate_cost().expect("estimate_cost")
|
||||
}
|
||||
|
||||
fn cost_cents(resolution: Option<CommonResolution>, duration_seconds: u16, video_batch_count: u16) -> u64 {
|
||||
fn cost_cents(resolution: Option<RouterResolution>, duration_seconds: u16, video_batch_count: u16) -> u64 {
|
||||
build_cost(resolution, duration_seconds, video_batch_count).cost_in_usd_cents.unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
+13
-13
@@ -28,11 +28,11 @@ mod tests {
|
||||
use tokens::tokens::media_files::MediaFileToken;
|
||||
|
||||
use crate::api::character_list_ref::CharacterListRef;
|
||||
use crate::api::common_resolution::CommonResolution;
|
||||
use crate::api::common_video_model::CommonVideoModel;
|
||||
use crate::api::router_resolution::RouterResolution;
|
||||
use crate::api::router_video_model::RouterVideoModel;
|
||||
use crate::api::image_list_ref::ImageListRef;
|
||||
use crate::api::image_ref::ImageRef;
|
||||
use crate::api::provider::Provider;
|
||||
use crate::api::router_provider::RouterProvider;
|
||||
use crate::client::request_mismatch_mitigation_strategy::RequestMismatchMitigationStrategy;
|
||||
use crate::generate::generate_video::generate_video_request_builder::GenerateVideoRequestBuilder;
|
||||
use crate::generate::generate_video_v2::video_generation_draft_or_request::VideoGenerationDraftOrRequest;
|
||||
@@ -79,28 +79,28 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn res_480p() {
|
||||
let req = unwrap_request(make_builder(|b| { b.resolution = Some(CommonResolution::FourEightyP); }));
|
||||
let req = unwrap_request(make_builder(|b| { b.resolution = Some(RouterResolution::FourEightyP); }));
|
||||
assert_eq!(req.request.resolution, Some(CommonResolutionEnum::FourEightyP));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn res_720p() {
|
||||
let req = unwrap_request(make_builder(|b| { b.resolution = Some(CommonResolution::SevenTwentyP); }));
|
||||
let req = unwrap_request(make_builder(|b| { b.resolution = Some(RouterResolution::SevenTwentyP); }));
|
||||
assert_eq!(req.request.resolution, Some(CommonResolutionEnum::SevenTwentyP));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn res_1080p_downgrades_to_720p() {
|
||||
let req = unwrap_request(make_builder(|b| { b.resolution = Some(CommonResolution::TenEightyP); }));
|
||||
let req = unwrap_request(make_builder(|b| { b.resolution = Some(RouterResolution::TenEightyP); }));
|
||||
assert_eq!(req.request.resolution, Some(CommonResolutionEnum::SevenTwentyP));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn res_1080p_error_out() {
|
||||
let result = build_artcraft_seedance_2p0_bp_fast(GenerateVideoRequestBuilder {
|
||||
model: CommonVideoModel::Seedance2p0BytePlusFast,
|
||||
provider: Provider::Artcraft,
|
||||
resolution: Some(CommonResolution::TenEightyP),
|
||||
model: RouterVideoModel::Seedance2p0BytePlusFast,
|
||||
provider: RouterProvider::Artcraft,
|
||||
resolution: Some(RouterResolution::TenEightyP),
|
||||
request_mismatch_mitigation_strategy: RequestMismatchMitigationStrategy::ErrorOut,
|
||||
..Default::default()
|
||||
});
|
||||
@@ -129,8 +129,8 @@ mod tests {
|
||||
#[test]
|
||||
fn url_start_frame_rejected() {
|
||||
let result = build_artcraft_seedance_2p0_bp_fast(GenerateVideoRequestBuilder {
|
||||
model: CommonVideoModel::Seedance2p0BytePlusFast,
|
||||
provider: Provider::Artcraft,
|
||||
model: RouterVideoModel::Seedance2p0BytePlusFast,
|
||||
provider: RouterProvider::Artcraft,
|
||||
start_frame: Some(ImageRef::Url("https://example.com".to_string())),
|
||||
..Default::default()
|
||||
});
|
||||
@@ -158,8 +158,8 @@ mod tests {
|
||||
|
||||
fn make_builder(f: impl FnOnce(&mut GenerateVideoRequestBuilder)) -> GenerateVideoRequestBuilder {
|
||||
let mut builder = GenerateVideoRequestBuilder {
|
||||
model: CommonVideoModel::Seedance2p0BytePlusFast,
|
||||
provider: Provider::Artcraft,
|
||||
model: RouterVideoModel::Seedance2p0BytePlusFast,
|
||||
provider: RouterProvider::Artcraft,
|
||||
duration_seconds: Some(5),
|
||||
video_batch_count: Some(1),
|
||||
..Default::default()
|
||||
|
||||
+22
-22
@@ -46,9 +46,9 @@ impl ArtcraftSeedance2p0BytePlusFastCostState {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::api::common_resolution::CommonResolution;
|
||||
use crate::api::common_video_model::CommonVideoModel;
|
||||
use crate::api::provider::Provider;
|
||||
use crate::api::router_resolution::RouterResolution;
|
||||
use crate::api::router_video_model::RouterVideoModel;
|
||||
use crate::api::router_provider::RouterProvider;
|
||||
use crate::generate::generate_video::generate_video_request_builder::GenerateVideoRequestBuilder;
|
||||
|
||||
mod pricing_720p {
|
||||
@@ -56,25 +56,25 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn batch_1() {
|
||||
assert_eq!(cost_cents(Some(CommonResolution::SevenTwentyP), 4, 1), 80);
|
||||
assert_eq!(cost_cents(Some(CommonResolution::SevenTwentyP), 5, 1), 100);
|
||||
assert_eq!(cost_cents(Some(CommonResolution::SevenTwentyP), 10, 1), 200);
|
||||
assert_eq!(cost_cents(Some(CommonResolution::SevenTwentyP), 15, 1), 300);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::SevenTwentyP), 4, 1), 80);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::SevenTwentyP), 5, 1), 100);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::SevenTwentyP), 10, 1), 200);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::SevenTwentyP), 15, 1), 300);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn batch_2() {
|
||||
assert_eq!(cost_cents(Some(CommonResolution::SevenTwentyP), 5, 2), 200);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::SevenTwentyP), 5, 2), 200);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn batch_4() {
|
||||
assert_eq!(cost_cents(Some(CommonResolution::SevenTwentyP), 5, 4), 400);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::SevenTwentyP), 5, 4), 400);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn none_defaults_to_720p() {
|
||||
assert_eq!(cost_cents(None, 5, 1), cost_cents(Some(CommonResolution::SevenTwentyP), 5, 1));
|
||||
assert_eq!(cost_cents(None, 5, 1), cost_cents(Some(RouterResolution::SevenTwentyP), 5, 1));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,20 +83,20 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn batch_1() {
|
||||
assert_eq!(cost_cents(Some(CommonResolution::FourEightyP), 4, 1), 36);
|
||||
assert_eq!(cost_cents(Some(CommonResolution::FourEightyP), 5, 1), 45);
|
||||
assert_eq!(cost_cents(Some(CommonResolution::FourEightyP), 10, 1), 90);
|
||||
assert_eq!(cost_cents(Some(CommonResolution::FourEightyP), 15, 1), 135);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::FourEightyP), 4, 1), 36);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::FourEightyP), 5, 1), 45);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::FourEightyP), 10, 1), 90);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::FourEightyP), 15, 1), 135);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn batch_2() {
|
||||
assert_eq!(cost_cents(Some(CommonResolution::FourEightyP), 5, 2), 90);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::FourEightyP), 5, 2), 90);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn batch_4() {
|
||||
assert_eq!(cost_cents(Some(CommonResolution::FourEightyP), 5, 4), 180);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::FourEightyP), 5, 4), 180);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn cost_480p_cheaper_than_720p() {
|
||||
assert!(cost_cents(Some(CommonResolution::FourEightyP), 5, 1) < cost_cents(Some(CommonResolution::SevenTwentyP), 5, 1));
|
||||
assert!(cost_cents(Some(RouterResolution::FourEightyP), 5, 1) < cost_cents(Some(RouterResolution::SevenTwentyP), 5, 1));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,7 +114,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn credits_equal_usd_cents() {
|
||||
for res in [Some(CommonResolution::FourEightyP), Some(CommonResolution::SevenTwentyP), None] {
|
||||
for res in [Some(RouterResolution::FourEightyP), Some(RouterResolution::SevenTwentyP), None] {
|
||||
for dur in [4, 5, 10, 15] {
|
||||
for batch in [1, 2, 4] {
|
||||
let cost = build_cost(res, dur, batch);
|
||||
@@ -126,13 +126,13 @@ mod tests {
|
||||
}
|
||||
|
||||
fn build_cost(
|
||||
resolution: Option<CommonResolution>,
|
||||
resolution: Option<RouterResolution>,
|
||||
duration_seconds: u16,
|
||||
video_batch_count: u16,
|
||||
) -> crate::generate::generate_video::video_generation_cost_estimate::VideoGenerationCostEstimate {
|
||||
GenerateVideoRequestBuilder {
|
||||
model: CommonVideoModel::Seedance2p0BytePlusFast,
|
||||
provider: Provider::Artcraft,
|
||||
model: RouterVideoModel::Seedance2p0BytePlusFast,
|
||||
provider: RouterProvider::Artcraft,
|
||||
resolution,
|
||||
duration_seconds: Some(duration_seconds),
|
||||
video_batch_count: Some(video_batch_count),
|
||||
@@ -140,7 +140,7 @@ mod tests {
|
||||
}.build2().expect("build2").estimate_cost().expect("estimate_cost")
|
||||
}
|
||||
|
||||
fn cost_cents(resolution: Option<CommonResolution>, duration_seconds: u16, video_batch_count: u16) -> u64 {
|
||||
fn cost_cents(resolution: Option<RouterResolution>, duration_seconds: u16, video_batch_count: u16) -> u64 {
|
||||
build_cost(resolution, duration_seconds, video_batch_count).cost_in_usd_cents.unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
+17
-17
@@ -29,12 +29,12 @@ mod tests {
|
||||
use tokens::tokens::media_files::MediaFileToken;
|
||||
|
||||
use crate::api::character_list_ref::CharacterListRef;
|
||||
use crate::api::common_aspect_ratio::CommonAspectRatio;
|
||||
use crate::api::common_resolution::CommonResolution;
|
||||
use crate::api::common_video_model::CommonVideoModel;
|
||||
use crate::api::router_aspect_ratio::RouterAspectRatio;
|
||||
use crate::api::router_resolution::RouterResolution;
|
||||
use crate::api::router_video_model::RouterVideoModel;
|
||||
use crate::api::image_list_ref::ImageListRef;
|
||||
use crate::api::image_ref::ImageRef;
|
||||
use crate::api::provider::Provider;
|
||||
use crate::api::router_provider::RouterProvider;
|
||||
use crate::api::video_list_ref::VideoListRef;
|
||||
use crate::client::request_mismatch_mitigation_strategy::RequestMismatchMitigationStrategy;
|
||||
use crate::generate::generate_video::generate_video_request_builder::GenerateVideoRequestBuilder;
|
||||
@@ -93,7 +93,7 @@ mod tests {
|
||||
#[test]
|
||||
fn wide() {
|
||||
let req = unwrap_request(artcraft_fast_builder_with(|b| {
|
||||
b.aspect_ratio = Some(CommonAspectRatio::WideSixteenByNine);
|
||||
b.aspect_ratio = Some(RouterAspectRatio::WideSixteenByNine);
|
||||
}));
|
||||
assert_eq!(req.request.aspect_ratio, Some(CommonAspectRatioEnum::WideSixteenByNine));
|
||||
}
|
||||
@@ -101,7 +101,7 @@ mod tests {
|
||||
#[test]
|
||||
fn tall() {
|
||||
let req = unwrap_request(artcraft_fast_builder_with(|b| {
|
||||
b.aspect_ratio = Some(CommonAspectRatio::TallNineBySixteen);
|
||||
b.aspect_ratio = Some(RouterAspectRatio::TallNineBySixteen);
|
||||
}));
|
||||
assert_eq!(req.request.aspect_ratio, Some(CommonAspectRatioEnum::TallNineBySixteen));
|
||||
}
|
||||
@@ -109,7 +109,7 @@ mod tests {
|
||||
#[test]
|
||||
fn square() {
|
||||
let req = unwrap_request(artcraft_fast_builder_with(|b| {
|
||||
b.aspect_ratio = Some(CommonAspectRatio::Square);
|
||||
b.aspect_ratio = Some(RouterAspectRatio::Square);
|
||||
}));
|
||||
assert_eq!(req.request.aspect_ratio, Some(CommonAspectRatioEnum::Square));
|
||||
}
|
||||
@@ -129,7 +129,7 @@ mod tests {
|
||||
#[test]
|
||||
fn res_480p() {
|
||||
let req = unwrap_request(artcraft_fast_builder_with(|b| {
|
||||
b.resolution = Some(CommonResolution::FourEightyP);
|
||||
b.resolution = Some(RouterResolution::FourEightyP);
|
||||
}));
|
||||
assert_eq!(req.request.resolution, Some(CommonResolutionEnum::FourEightyP));
|
||||
}
|
||||
@@ -137,7 +137,7 @@ mod tests {
|
||||
#[test]
|
||||
fn res_720p() {
|
||||
let req = unwrap_request(artcraft_fast_builder_with(|b| {
|
||||
b.resolution = Some(CommonResolution::SevenTwentyP);
|
||||
b.resolution = Some(RouterResolution::SevenTwentyP);
|
||||
}));
|
||||
assert_eq!(req.request.resolution, Some(CommonResolutionEnum::SevenTwentyP));
|
||||
}
|
||||
@@ -145,7 +145,7 @@ mod tests {
|
||||
#[test]
|
||||
fn res_1080p_downgrades_to_720p() {
|
||||
let req = unwrap_request(artcraft_fast_builder_with(|b| {
|
||||
b.resolution = Some(CommonResolution::TenEightyP);
|
||||
b.resolution = Some(RouterResolution::TenEightyP);
|
||||
}));
|
||||
assert_eq!(req.request.resolution, Some(CommonResolutionEnum::SevenTwentyP));
|
||||
}
|
||||
@@ -153,9 +153,9 @@ mod tests {
|
||||
#[test]
|
||||
fn res_1080p_error_out() {
|
||||
let result = build_artcraft_seedance_2p0_fast(GenerateVideoRequestBuilder {
|
||||
model: CommonVideoModel::Seedance2p0Fast,
|
||||
provider: Provider::Artcraft,
|
||||
resolution: Some(CommonResolution::TenEightyP),
|
||||
model: RouterVideoModel::Seedance2p0Fast,
|
||||
provider: RouterProvider::Artcraft,
|
||||
resolution: Some(RouterResolution::TenEightyP),
|
||||
request_mismatch_mitigation_strategy: RequestMismatchMitigationStrategy::ErrorOut,
|
||||
..Default::default()
|
||||
});
|
||||
@@ -186,8 +186,8 @@ mod tests {
|
||||
#[test]
|
||||
fn url_start_frame_rejected() {
|
||||
let result = build_artcraft_seedance_2p0_fast(GenerateVideoRequestBuilder {
|
||||
model: CommonVideoModel::Seedance2p0Fast,
|
||||
provider: Provider::Artcraft,
|
||||
model: RouterVideoModel::Seedance2p0Fast,
|
||||
provider: RouterProvider::Artcraft,
|
||||
start_frame: Some(ImageRef::Url("https://example.com".to_string())),
|
||||
..Default::default()
|
||||
});
|
||||
@@ -223,8 +223,8 @@ mod tests {
|
||||
|
||||
fn artcraft_fast_builder_with(f: impl FnOnce(&mut GenerateVideoRequestBuilder)) -> GenerateVideoRequestBuilder {
|
||||
let mut builder = GenerateVideoRequestBuilder {
|
||||
model: CommonVideoModel::Seedance2p0Fast,
|
||||
provider: Provider::Artcraft,
|
||||
model: RouterVideoModel::Seedance2p0Fast,
|
||||
provider: RouterProvider::Artcraft,
|
||||
duration_seconds: Some(5),
|
||||
video_batch_count: Some(1),
|
||||
..Default::default()
|
||||
|
||||
+38
-38
@@ -64,9 +64,9 @@ impl ArtcraftSeedance2p0FastCostState {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::api::common_resolution::CommonResolution;
|
||||
use crate::api::common_video_model::CommonVideoModel;
|
||||
use crate::api::provider::Provider;
|
||||
use crate::api::router_resolution::RouterResolution;
|
||||
use crate::api::router_video_model::RouterVideoModel;
|
||||
use crate::api::router_provider::RouterProvider;
|
||||
use crate::generate::generate_video::generate_video_request_builder::GenerateVideoRequestBuilder;
|
||||
|
||||
// -- 720p pricing --
|
||||
@@ -76,29 +76,29 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn batch_1() {
|
||||
assert_eq!(cost_cents(Some(CommonResolution::SevenTwentyP), 4, 1), 51);
|
||||
assert_eq!(cost_cents(Some(CommonResolution::SevenTwentyP), 5, 1), 64);
|
||||
assert_eq!(cost_cents(Some(CommonResolution::SevenTwentyP), 10, 1), 127);
|
||||
assert_eq!(cost_cents(Some(CommonResolution::SevenTwentyP), 15, 1), 191);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::SevenTwentyP), 4, 1), 51);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::SevenTwentyP), 5, 1), 64);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::SevenTwentyP), 10, 1), 127);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::SevenTwentyP), 15, 1), 191);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn batch_2() {
|
||||
assert_eq!(cost_cents(Some(CommonResolution::SevenTwentyP), 4, 2), 102);
|
||||
assert_eq!(cost_cents(Some(CommonResolution::SevenTwentyP), 5, 2), 127);
|
||||
assert_eq!(cost_cents(Some(CommonResolution::SevenTwentyP), 15, 2), 382);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::SevenTwentyP), 4, 2), 102);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::SevenTwentyP), 5, 2), 127);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::SevenTwentyP), 15, 2), 382);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn batch_4() {
|
||||
assert_eq!(cost_cents(Some(CommonResolution::SevenTwentyP), 4, 4), 204);
|
||||
assert_eq!(cost_cents(Some(CommonResolution::SevenTwentyP), 5, 4), 255);
|
||||
assert_eq!(cost_cents(Some(CommonResolution::SevenTwentyP), 15, 4), 764);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::SevenTwentyP), 4, 4), 204);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::SevenTwentyP), 5, 4), 255);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::SevenTwentyP), 15, 4), 764);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn none_defaults_to_720p() {
|
||||
assert_eq!(cost_cents(None, 5, 1), cost_cents(Some(CommonResolution::SevenTwentyP), 5, 1));
|
||||
assert_eq!(cost_cents(None, 5, 1), cost_cents(Some(RouterResolution::SevenTwentyP), 5, 1));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,20 +109,20 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn batch_1() {
|
||||
assert_eq!(cost_cents(Some(CommonResolution::FourEightyP), 4, 1), 21);
|
||||
assert_eq!(cost_cents(Some(CommonResolution::FourEightyP), 5, 1), 26);
|
||||
assert_eq!(cost_cents(Some(CommonResolution::FourEightyP), 10, 1), 52);
|
||||
assert_eq!(cost_cents(Some(CommonResolution::FourEightyP), 15, 1), 78);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::FourEightyP), 4, 1), 21);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::FourEightyP), 5, 1), 26);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::FourEightyP), 10, 1), 52);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::FourEightyP), 15, 1), 78);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn batch_2() {
|
||||
assert_eq!(cost_cents(Some(CommonResolution::FourEightyP), 5, 2), 52);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::FourEightyP), 5, 2), 52);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn batch_4() {
|
||||
assert_eq!(cost_cents(Some(CommonResolution::FourEightyP), 5, 4), 104);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::FourEightyP), 5, 4), 104);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,25 +133,25 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn cost_480p_cheaper_than_720p() {
|
||||
let c480 = cost_cents(Some(CommonResolution::FourEightyP), 5, 1);
|
||||
let c720 = cost_cents(Some(CommonResolution::SevenTwentyP), 5, 1);
|
||||
let c480 = cost_cents(Some(RouterResolution::FourEightyP), 5, 1);
|
||||
let c720 = cost_cents(Some(RouterResolution::SevenTwentyP), 5, 1);
|
||||
assert!(c480 < c720, "480p ({}) should be cheaper than 720p ({})", c480, c720);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn cost_scales_with_duration() {
|
||||
let c4 = cost_cents(Some(CommonResolution::SevenTwentyP), 4, 1);
|
||||
let c10 = cost_cents(Some(CommonResolution::SevenTwentyP), 10, 1);
|
||||
let c15 = cost_cents(Some(CommonResolution::SevenTwentyP), 15, 1);
|
||||
let c4 = cost_cents(Some(RouterResolution::SevenTwentyP), 4, 1);
|
||||
let c10 = cost_cents(Some(RouterResolution::SevenTwentyP), 10, 1);
|
||||
let c15 = cost_cents(Some(RouterResolution::SevenTwentyP), 15, 1);
|
||||
assert!(c4 < c10);
|
||||
assert!(c10 < c15);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn cost_scales_with_batch() {
|
||||
let b1 = cost_cents(Some(CommonResolution::SevenTwentyP), 5, 1);
|
||||
let b2 = cost_cents(Some(CommonResolution::SevenTwentyP), 5, 2);
|
||||
let b4 = cost_cents(Some(CommonResolution::SevenTwentyP), 5, 4);
|
||||
let b1 = cost_cents(Some(RouterResolution::SevenTwentyP), 5, 1);
|
||||
let b2 = cost_cents(Some(RouterResolution::SevenTwentyP), 5, 2);
|
||||
let b4 = cost_cents(Some(RouterResolution::SevenTwentyP), 5, 4);
|
||||
assert!(b1 < b2);
|
||||
assert!(b2 < b4);
|
||||
}
|
||||
@@ -165,8 +165,8 @@ mod tests {
|
||||
#[test]
|
||||
fn credits_equal_usd_cents_all_combos() {
|
||||
let resolutions = [
|
||||
Some(CommonResolution::FourEightyP),
|
||||
Some(CommonResolution::SevenTwentyP),
|
||||
Some(RouterResolution::FourEightyP),
|
||||
Some(RouterResolution::SevenTwentyP),
|
||||
None,
|
||||
];
|
||||
for res in resolutions {
|
||||
@@ -192,8 +192,8 @@ mod tests {
|
||||
// #[test]
|
||||
// fn artcraft_fast_matches_kinovi_fast_all_combos() {
|
||||
// let resolutions = [
|
||||
// Some(CommonResolution::FourEightyP),
|
||||
// Some(CommonResolution::SevenTwentyP),
|
||||
// Some(RouterResolution::FourEightyP),
|
||||
// Some(RouterResolution::SevenTwentyP),
|
||||
// None,
|
||||
// ];
|
||||
// let durations: [u16; 4] = [4, 5, 10, 15];
|
||||
@@ -205,8 +205,8 @@ mod tests {
|
||||
// let artcraft_cost = build_cost(*res, *dur, *batch);
|
||||
//
|
||||
// let kinovi = GenerateVideoRequestBuilder {
|
||||
// model: CommonVideoModel::Seedance2p0Fast,
|
||||
// provider: Provider::Seedance2Pro,
|
||||
// model: RouterVideoModel::Seedance2p0Fast,
|
||||
// provider: RouterProvider::Seedance2Pro,
|
||||
// resolution: *res,
|
||||
// duration_seconds: Some(*dur),
|
||||
// video_batch_count: Some(*batch),
|
||||
@@ -231,13 +231,13 @@ mod tests {
|
||||
// -- Helpers --
|
||||
|
||||
fn build_cost(
|
||||
resolution: Option<CommonResolution>,
|
||||
resolution: Option<RouterResolution>,
|
||||
duration_seconds: u16,
|
||||
video_batch_count: u16,
|
||||
) -> crate::generate::generate_video::video_generation_cost_estimate::VideoGenerationCostEstimate {
|
||||
let builder = GenerateVideoRequestBuilder {
|
||||
model: CommonVideoModel::Seedance2p0Fast,
|
||||
provider: Provider::Artcraft,
|
||||
model: RouterVideoModel::Seedance2p0Fast,
|
||||
provider: RouterProvider::Artcraft,
|
||||
resolution,
|
||||
duration_seconds: Some(duration_seconds),
|
||||
video_batch_count: Some(video_batch_count),
|
||||
@@ -250,7 +250,7 @@ mod tests {
|
||||
}
|
||||
|
||||
fn cost_cents(
|
||||
resolution: Option<CommonResolution>,
|
||||
resolution: Option<RouterResolution>,
|
||||
duration_seconds: u16,
|
||||
video_batch_count: u16,
|
||||
) -> u64 {
|
||||
|
||||
+15
-15
@@ -22,12 +22,12 @@ mod tests {
|
||||
use tokens::tokens::media_files::MediaFileToken;
|
||||
|
||||
use crate::api::character_list_ref::CharacterListRef;
|
||||
use crate::api::common_aspect_ratio::CommonAspectRatio;
|
||||
use crate::api::common_resolution::CommonResolution;
|
||||
use crate::api::common_video_model::CommonVideoModel;
|
||||
use crate::api::router_aspect_ratio::RouterAspectRatio;
|
||||
use crate::api::router_resolution::RouterResolution;
|
||||
use crate::api::router_video_model::RouterVideoModel;
|
||||
use crate::api::image_list_ref::ImageListRef;
|
||||
use crate::api::image_ref::ImageRef;
|
||||
use crate::api::provider::Provider;
|
||||
use crate::api::router_provider::RouterProvider;
|
||||
use crate::client::router_artcraft_client::RouterArtcraftClient;
|
||||
use crate::client::router_client::RouterClient;
|
||||
use crate::generate::generate_video::generate_video_request_builder::GenerateVideoRequestBuilder;
|
||||
@@ -53,7 +53,7 @@ mod tests {
|
||||
async fn landscape() {
|
||||
let response = run_pipeline(GenerateVideoRequestBuilder {
|
||||
prompt: Some("A corgi running through a field of wildflowers at sunset.".to_string()),
|
||||
aspect_ratio: Some(CommonAspectRatio::WideSixteenByNine),
|
||||
aspect_ratio: Some(RouterAspectRatio::WideSixteenByNine),
|
||||
..artcraft_fast_builder()
|
||||
}).await;
|
||||
assert!(matches!(response, GenerateVideoResponse::Artcraft(_)));
|
||||
@@ -65,7 +65,7 @@ mod tests {
|
||||
async fn portrait() {
|
||||
let response = run_pipeline(GenerateVideoRequestBuilder {
|
||||
prompt: Some("A cat sitting on a windowsill watching rain.".to_string()),
|
||||
aspect_ratio: Some(CommonAspectRatio::TallNineBySixteen),
|
||||
aspect_ratio: Some(RouterAspectRatio::TallNineBySixteen),
|
||||
..artcraft_fast_builder()
|
||||
}).await;
|
||||
assert!(matches!(response, GenerateVideoResponse::Artcraft(_)));
|
||||
@@ -77,7 +77,7 @@ mod tests {
|
||||
async fn square() {
|
||||
let response = run_pipeline(GenerateVideoRequestBuilder {
|
||||
prompt: Some("A hummingbird hovering near a flower.".to_string()),
|
||||
aspect_ratio: Some(CommonAspectRatio::Square),
|
||||
aspect_ratio: Some(RouterAspectRatio::Square),
|
||||
..artcraft_fast_builder()
|
||||
}).await;
|
||||
assert!(matches!(response, GenerateVideoResponse::Artcraft(_)));
|
||||
@@ -95,7 +95,7 @@ mod tests {
|
||||
async fn res_480p() {
|
||||
let response = run_pipeline(GenerateVideoRequestBuilder {
|
||||
prompt: Some("A shiba inu playing in autumn leaves.".to_string()),
|
||||
resolution: Some(CommonResolution::FourEightyP),
|
||||
resolution: Some(RouterResolution::FourEightyP),
|
||||
..artcraft_fast_builder()
|
||||
}).await;
|
||||
assert!(matches!(response, GenerateVideoResponse::Artcraft(_)));
|
||||
@@ -107,7 +107,7 @@ mod tests {
|
||||
async fn res_720p() {
|
||||
let response = run_pipeline(GenerateVideoRequestBuilder {
|
||||
prompt: Some("A golden retriever catching a frisbee on the beach.".to_string()),
|
||||
resolution: Some(CommonResolution::SevenTwentyP),
|
||||
resolution: Some(RouterResolution::SevenTwentyP),
|
||||
..artcraft_fast_builder()
|
||||
}).await;
|
||||
assert!(matches!(response, GenerateVideoResponse::Artcraft(_)));
|
||||
@@ -126,7 +126,7 @@ mod tests {
|
||||
async fn text_to_video() {
|
||||
let response = run_pipeline(GenerateVideoRequestBuilder {
|
||||
prompt: Some("A sky whale breaching in the open sky, pink clouds at dawn, cinematic.".to_string()),
|
||||
aspect_ratio: Some(CommonAspectRatio::WideSixteenByNine),
|
||||
aspect_ratio: Some(RouterAspectRatio::WideSixteenByNine),
|
||||
..artcraft_fast_builder()
|
||||
}).await;
|
||||
assert!(matches!(response, GenerateVideoResponse::Artcraft(_)));
|
||||
@@ -140,7 +140,7 @@ mod tests {
|
||||
prompt: Some("The dog walks from the lake to the forest.".to_string()),
|
||||
start_frame: Some(ImageRef::MediaFileToken(MediaFileToken::new(JUNO_AT_LAKE_PRODUCTION_MEDIA_TOKEN.to_string()))),
|
||||
end_frame: Some(ImageRef::MediaFileToken(MediaFileToken::new(FOREST_BACKDROP_PRODUCTION_MEDIA_TOKEN.to_string()))),
|
||||
aspect_ratio: Some(CommonAspectRatio::WideSixteenByNine),
|
||||
aspect_ratio: Some(RouterAspectRatio::WideSixteenByNine),
|
||||
..artcraft_fast_builder()
|
||||
}).await;
|
||||
assert!(matches!(response, GenerateVideoResponse::Artcraft(_)));
|
||||
@@ -157,7 +157,7 @@ mod tests {
|
||||
MediaFileToken::new(TALL_MOCHI_WITH_GLASSES_PRODUCTION_MEDIA_TOKEN.to_string()),
|
||||
MediaFileToken::new(WHITE_HOUSE_SUNSET_PRODUCTION_MEDIA_TOKEN.to_string()),
|
||||
])),
|
||||
aspect_ratio: Some(CommonAspectRatio::WideSixteenByNine),
|
||||
aspect_ratio: Some(RouterAspectRatio::WideSixteenByNine),
|
||||
..artcraft_fast_builder()
|
||||
}).await;
|
||||
assert!(matches!(response, GenerateVideoResponse::Artcraft(_)));
|
||||
@@ -173,7 +173,7 @@ mod tests {
|
||||
CharacterToken::new(JIM.token.to_string()),
|
||||
CharacterToken::new(KNIGHT.token.to_string()),
|
||||
])),
|
||||
aspect_ratio: Some(CommonAspectRatio::WideSixteenByNine),
|
||||
aspect_ratio: Some(RouterAspectRatio::WideSixteenByNine),
|
||||
..artcraft_fast_builder()
|
||||
}).await;
|
||||
assert!(matches!(response, GenerateVideoResponse::Artcraft(_)));
|
||||
@@ -185,8 +185,8 @@ mod tests {
|
||||
|
||||
fn artcraft_fast_builder() -> GenerateVideoRequestBuilder {
|
||||
GenerateVideoRequestBuilder {
|
||||
model: CommonVideoModel::Seedance2p0Fast,
|
||||
provider: Provider::Artcraft,
|
||||
model: RouterVideoModel::Seedance2p0Fast,
|
||||
provider: RouterProvider::Artcraft,
|
||||
duration_seconds: Some(4),
|
||||
video_batch_count: Some(1),
|
||||
..Default::default()
|
||||
|
||||
+6
-6
@@ -28,10 +28,10 @@ mod tests {
|
||||
use tokens::tokens::media_files::MediaFileToken;
|
||||
|
||||
use crate::api::character_list_ref::CharacterListRef;
|
||||
use crate::api::common_resolution::CommonResolution;
|
||||
use crate::api::router_resolution::RouterResolution;
|
||||
use crate::api::image_list_ref::ImageListRef;
|
||||
use crate::api::image_ref::ImageRef;
|
||||
use crate::api::provider::Provider;
|
||||
use crate::api::router_provider::RouterProvider;
|
||||
use crate::generate::generate_video::generate_video_request_builder::GenerateVideoRequestBuilder;
|
||||
use crate::generate::generate_video_v2::video_generation_draft_or_request::VideoGenerationDraftOrRequest;
|
||||
use crate::generate::generate_video_v2::video_generation_request::VideoGenerationRequest;
|
||||
@@ -81,19 +81,19 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn res_480p() {
|
||||
let req = unwrap_request(make_builder(|b| { b.resolution = Some(CommonResolution::FourEightyP); }));
|
||||
let req = unwrap_request(make_builder(|b| { b.resolution = Some(RouterResolution::FourEightyP); }));
|
||||
assert_eq!(req.request.resolution, Some(CommonResolutionEnum::FourEightyP));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn res_720p() {
|
||||
let req = unwrap_request(make_builder(|b| { b.resolution = Some(CommonResolution::SevenTwentyP); }));
|
||||
let req = unwrap_request(make_builder(|b| { b.resolution = Some(RouterResolution::SevenTwentyP); }));
|
||||
assert_eq!(req.request.resolution, Some(CommonResolutionEnum::SevenTwentyP));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn res_1080p() {
|
||||
let req = unwrap_request(make_builder(|b| { b.resolution = Some(CommonResolution::TenEightyP); }));
|
||||
let req = unwrap_request(make_builder(|b| { b.resolution = Some(RouterResolution::TenEightyP); }));
|
||||
assert_eq!(req.request.resolution, Some(CommonResolutionEnum::TenEightyP));
|
||||
}
|
||||
|
||||
@@ -150,7 +150,7 @@ mod tests {
|
||||
|
||||
fn base_builder() -> GenerateVideoRequestBuilder {
|
||||
GenerateVideoRequestBuilder {
|
||||
provider: Provider::Artcraft,
|
||||
provider: RouterProvider::Artcraft,
|
||||
duration_seconds: Some(5),
|
||||
video_batch_count: Some(1),
|
||||
..Default::default()
|
||||
|
||||
+25
-25
@@ -49,9 +49,9 @@ impl ArtcraftSeedance2p0UltraCostState {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::api::common_resolution::CommonResolution;
|
||||
use crate::api::common_video_model::CommonVideoModel;
|
||||
use crate::api::provider::Provider;
|
||||
use crate::api::router_resolution::RouterResolution;
|
||||
use crate::api::router_video_model::RouterVideoModel;
|
||||
use crate::api::router_provider::RouterProvider;
|
||||
use crate::generate::generate_video::generate_video_request_builder::GenerateVideoRequestBuilder;
|
||||
|
||||
mod pricing_720p {
|
||||
@@ -60,27 +60,27 @@ mod tests {
|
||||
#[test]
|
||||
fn batch_1() {
|
||||
// 11.2 * 5 = 56¢
|
||||
assert_eq!(cost_cents(Some(CommonResolution::SevenTwentyP), 5, 1), 56);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::SevenTwentyP), 5, 1), 56);
|
||||
// 11.2 * 10 = 112¢
|
||||
assert_eq!(cost_cents(Some(CommonResolution::SevenTwentyP), 10, 1), 112);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::SevenTwentyP), 10, 1), 112);
|
||||
// 11.2 * 15 = 168¢
|
||||
assert_eq!(cost_cents(Some(CommonResolution::SevenTwentyP), 15, 1), 168);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::SevenTwentyP), 15, 1), 168);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn batch_2() {
|
||||
assert_eq!(cost_cents(Some(CommonResolution::SevenTwentyP), 5, 2), 112);
|
||||
assert_eq!(cost_cents(Some(CommonResolution::SevenTwentyP), 10, 2), 224);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::SevenTwentyP), 5, 2), 112);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::SevenTwentyP), 10, 2), 224);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn batch_4() {
|
||||
assert_eq!(cost_cents(Some(CommonResolution::SevenTwentyP), 5, 4), 224);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::SevenTwentyP), 5, 4), 224);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn none_defaults_to_720p() {
|
||||
assert_eq!(cost_cents(None, 10, 1), cost_cents(Some(CommonResolution::SevenTwentyP), 10, 1));
|
||||
assert_eq!(cost_cents(None, 10, 1), cost_cents(Some(RouterResolution::SevenTwentyP), 10, 1));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,16 +90,16 @@ mod tests {
|
||||
#[test]
|
||||
fn batch_1() {
|
||||
// 5.4404 * 5 = 27.202 → ceil = 28¢
|
||||
assert_eq!(cost_cents(Some(CommonResolution::FourEightyP), 5, 1), 28);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::FourEightyP), 5, 1), 28);
|
||||
// 5.4404 * 10 = 54.404 → ceil = 55¢
|
||||
assert_eq!(cost_cents(Some(CommonResolution::FourEightyP), 10, 1), 55);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::FourEightyP), 10, 1), 55);
|
||||
// 5.4404 * 15 = 81.606 → ceil = 82¢
|
||||
assert_eq!(cost_cents(Some(CommonResolution::FourEightyP), 15, 1), 82);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::FourEightyP), 15, 1), 82);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn batch_4() {
|
||||
assert_eq!(cost_cents(Some(CommonResolution::FourEightyP), 10, 4), 220);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::FourEightyP), 10, 4), 220);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,16 +109,16 @@ mod tests {
|
||||
#[test]
|
||||
fn batch_1() {
|
||||
// 32.6424 * 5 = 163.212 → ceil = 164¢
|
||||
assert_eq!(cost_cents(Some(CommonResolution::TenEightyP), 5, 1), 164);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::TenEightyP), 5, 1), 164);
|
||||
// 32.6424 * 10 = 326.424 → ceil = 327¢
|
||||
assert_eq!(cost_cents(Some(CommonResolution::TenEightyP), 10, 1), 327);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::TenEightyP), 10, 1), 327);
|
||||
// 32.6424 * 15 = 489.636 → ceil = 490¢
|
||||
assert_eq!(cost_cents(Some(CommonResolution::TenEightyP), 15, 1), 490);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::TenEightyP), 15, 1), 490);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn batch_4() {
|
||||
assert_eq!(cost_cents(Some(CommonResolution::TenEightyP), 10, 4), 1308);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::TenEightyP), 10, 4), 1308);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,9 +127,9 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn cost_480p_cheaper_than_720p_cheaper_than_1080p() {
|
||||
let c480 = cost_cents(Some(CommonResolution::FourEightyP), 10, 1);
|
||||
let c720 = cost_cents(Some(CommonResolution::SevenTwentyP), 10, 1);
|
||||
let c1080 = cost_cents(Some(CommonResolution::TenEightyP), 10, 1);
|
||||
let c480 = cost_cents(Some(RouterResolution::FourEightyP), 10, 1);
|
||||
let c720 = cost_cents(Some(RouterResolution::SevenTwentyP), 10, 1);
|
||||
let c1080 = cost_cents(Some(RouterResolution::TenEightyP), 10, 1);
|
||||
assert!(c480 < c720);
|
||||
assert!(c720 < c1080);
|
||||
}
|
||||
@@ -160,13 +160,13 @@ mod tests {
|
||||
}
|
||||
|
||||
fn build_cost(
|
||||
resolution: Option<CommonResolution>,
|
||||
resolution: Option<RouterResolution>,
|
||||
duration_seconds: u16,
|
||||
video_batch_count: u16,
|
||||
) -> crate::generate::generate_video::video_generation_cost_estimate::VideoGenerationCostEstimate {
|
||||
let builder = GenerateVideoRequestBuilder {
|
||||
model: CommonVideoModel::Seedance2p0Ultra,
|
||||
provider: Provider::Artcraft,
|
||||
model: RouterVideoModel::Seedance2p0Ultra,
|
||||
provider: RouterProvider::Artcraft,
|
||||
resolution,
|
||||
duration_seconds: Some(duration_seconds),
|
||||
video_batch_count: Some(video_batch_count),
|
||||
@@ -175,7 +175,7 @@ mod tests {
|
||||
builder.build2().expect("build2").estimate_cost().expect("estimate_cost")
|
||||
}
|
||||
|
||||
fn cost_cents(resolution: Option<CommonResolution>, duration_seconds: u16, batch: u16) -> u64 {
|
||||
fn cost_cents(resolution: Option<RouterResolution>, duration_seconds: u16, batch: u16) -> u64 {
|
||||
build_cost(resolution, duration_seconds, batch).cost_in_usd_cents.unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
+14
-14
@@ -22,11 +22,11 @@ mod tests {
|
||||
use tokens::tokens::media_files::MediaFileToken;
|
||||
|
||||
use crate::api::character_list_ref::CharacterListRef;
|
||||
use crate::api::common_aspect_ratio::CommonAspectRatio;
|
||||
use crate::api::common_resolution::CommonResolution;
|
||||
use crate::api::router_aspect_ratio::RouterAspectRatio;
|
||||
use crate::api::router_resolution::RouterResolution;
|
||||
use crate::api::image_list_ref::ImageListRef;
|
||||
use crate::api::image_ref::ImageRef;
|
||||
use crate::api::provider::Provider;
|
||||
use crate::api::router_provider::RouterProvider;
|
||||
use crate::client::router_artcraft_client::RouterArtcraftClient;
|
||||
use crate::client::router_client::RouterClient;
|
||||
use crate::generate::generate_video::generate_video_request_builder::GenerateVideoRequestBuilder;
|
||||
@@ -52,7 +52,7 @@ mod tests {
|
||||
async fn landscape() {
|
||||
let response = run_pipeline(GenerateVideoRequestBuilder {
|
||||
prompt: Some("A corgi running through a field of wildflowers at sunset.".to_string()),
|
||||
aspect_ratio: Some(CommonAspectRatio::WideSixteenByNine),
|
||||
aspect_ratio: Some(RouterAspectRatio::WideSixteenByNine),
|
||||
..artcraft_builder()
|
||||
}).await;
|
||||
assert!(matches!(response, GenerateVideoResponse::Artcraft(_)));
|
||||
@@ -64,7 +64,7 @@ mod tests {
|
||||
async fn portrait() {
|
||||
let response = run_pipeline(GenerateVideoRequestBuilder {
|
||||
prompt: Some("A cat sitting on a windowsill watching rain.".to_string()),
|
||||
aspect_ratio: Some(CommonAspectRatio::TallNineBySixteen),
|
||||
aspect_ratio: Some(RouterAspectRatio::TallNineBySixteen),
|
||||
..artcraft_builder()
|
||||
}).await;
|
||||
assert!(matches!(response, GenerateVideoResponse::Artcraft(_)));
|
||||
@@ -76,7 +76,7 @@ mod tests {
|
||||
async fn square() {
|
||||
let response = run_pipeline(GenerateVideoRequestBuilder {
|
||||
prompt: Some("A hummingbird hovering near a flower.".to_string()),
|
||||
aspect_ratio: Some(CommonAspectRatio::Square),
|
||||
aspect_ratio: Some(RouterAspectRatio::Square),
|
||||
..artcraft_builder()
|
||||
}).await;
|
||||
assert!(matches!(response, GenerateVideoResponse::Artcraft(_)));
|
||||
@@ -94,7 +94,7 @@ mod tests {
|
||||
async fn res_480p() {
|
||||
let response = run_pipeline(GenerateVideoRequestBuilder {
|
||||
prompt: Some("A shiba inu playing in autumn leaves.".to_string()),
|
||||
resolution: Some(CommonResolution::FourEightyP),
|
||||
resolution: Some(RouterResolution::FourEightyP),
|
||||
..artcraft_builder()
|
||||
}).await;
|
||||
assert!(matches!(response, GenerateVideoResponse::Artcraft(_)));
|
||||
@@ -106,7 +106,7 @@ mod tests {
|
||||
async fn res_720p() {
|
||||
let response = run_pipeline(GenerateVideoRequestBuilder {
|
||||
prompt: Some("A golden retriever catching a frisbee on the beach.".to_string()),
|
||||
resolution: Some(CommonResolution::SevenTwentyP),
|
||||
resolution: Some(RouterResolution::SevenTwentyP),
|
||||
..artcraft_builder()
|
||||
}).await;
|
||||
assert!(matches!(response, GenerateVideoResponse::Artcraft(_)));
|
||||
@@ -118,7 +118,7 @@ mod tests {
|
||||
async fn res_1080p() {
|
||||
let response = run_pipeline(GenerateVideoRequestBuilder {
|
||||
prompt: Some("A fox walking through a snowy forest.".to_string()),
|
||||
resolution: Some(CommonResolution::TenEightyP),
|
||||
resolution: Some(RouterResolution::TenEightyP),
|
||||
..artcraft_builder()
|
||||
}).await;
|
||||
assert!(matches!(response, GenerateVideoResponse::Artcraft(_)));
|
||||
@@ -137,7 +137,7 @@ mod tests {
|
||||
async fn text_to_video() {
|
||||
let response = run_pipeline(GenerateVideoRequestBuilder {
|
||||
prompt: Some("A whale breaching in the open ocean at dawn, cinematic.".to_string()),
|
||||
aspect_ratio: Some(CommonAspectRatio::WideSixteenByNine),
|
||||
aspect_ratio: Some(RouterAspectRatio::WideSixteenByNine),
|
||||
..artcraft_builder()
|
||||
}).await;
|
||||
assert!(matches!(response, GenerateVideoResponse::Artcraft(_)));
|
||||
@@ -151,7 +151,7 @@ mod tests {
|
||||
prompt: Some("The dog walks from the lake to the forest.".to_string()),
|
||||
start_frame: Some(ImageRef::MediaFileToken(MediaFileToken::new(JUNO_AT_LAKE_PRODUCTION_MEDIA_TOKEN.to_string()))),
|
||||
end_frame: Some(ImageRef::MediaFileToken(MediaFileToken::new(FOREST_BACKDROP_PRODUCTION_MEDIA_TOKEN.to_string()))),
|
||||
aspect_ratio: Some(CommonAspectRatio::WideSixteenByNine),
|
||||
aspect_ratio: Some(RouterAspectRatio::WideSixteenByNine),
|
||||
..artcraft_builder()
|
||||
}).await;
|
||||
assert!(matches!(response, GenerateVideoResponse::Artcraft(_)));
|
||||
@@ -168,7 +168,7 @@ mod tests {
|
||||
MediaFileToken::new(TALL_MOCHI_WITH_GLASSES_PRODUCTION_MEDIA_TOKEN.to_string()),
|
||||
MediaFileToken::new(WHITE_HOUSE_SUNSET_PRODUCTION_MEDIA_TOKEN.to_string()),
|
||||
])),
|
||||
aspect_ratio: Some(CommonAspectRatio::WideSixteenByNine),
|
||||
aspect_ratio: Some(RouterAspectRatio::WideSixteenByNine),
|
||||
..artcraft_builder()
|
||||
}).await;
|
||||
assert!(matches!(response, GenerateVideoResponse::Artcraft(_)));
|
||||
@@ -184,7 +184,7 @@ mod tests {
|
||||
CharacterToken::new(JIM.token.to_string()),
|
||||
CharacterToken::new(KNIGHT.token.to_string()),
|
||||
])),
|
||||
aspect_ratio: Some(CommonAspectRatio::WideSixteenByNine),
|
||||
aspect_ratio: Some(RouterAspectRatio::WideSixteenByNine),
|
||||
..artcraft_builder()
|
||||
}).await;
|
||||
assert!(matches!(response, GenerateVideoResponse::Artcraft(_)));
|
||||
@@ -196,7 +196,7 @@ mod tests {
|
||||
|
||||
fn artcraft_builder() -> GenerateVideoRequestBuilder {
|
||||
GenerateVideoRequestBuilder {
|
||||
provider: Provider::Artcraft,
|
||||
provider: RouterProvider::Artcraft,
|
||||
duration_seconds: Some(4),
|
||||
video_batch_count: Some(1),
|
||||
..Default::default()
|
||||
|
||||
+17
-17
@@ -29,12 +29,12 @@ mod tests {
|
||||
use tokens::tokens::media_files::MediaFileToken;
|
||||
|
||||
use crate::api::character_list_ref::CharacterListRef;
|
||||
use crate::api::common_aspect_ratio::CommonAspectRatio;
|
||||
use crate::api::common_resolution::CommonResolution;
|
||||
use crate::api::common_video_model::CommonVideoModel;
|
||||
use crate::api::router_aspect_ratio::RouterAspectRatio;
|
||||
use crate::api::router_resolution::RouterResolution;
|
||||
use crate::api::router_video_model::RouterVideoModel;
|
||||
use crate::api::image_list_ref::ImageListRef;
|
||||
use crate::api::image_ref::ImageRef;
|
||||
use crate::api::provider::Provider;
|
||||
use crate::api::router_provider::RouterProvider;
|
||||
use crate::api::video_list_ref::VideoListRef;
|
||||
use crate::client::request_mismatch_mitigation_strategy::RequestMismatchMitigationStrategy;
|
||||
use crate::generate::generate_video::generate_video_request_builder::GenerateVideoRequestBuilder;
|
||||
@@ -93,7 +93,7 @@ mod tests {
|
||||
#[test]
|
||||
fn wide() {
|
||||
let req = unwrap_request(artcraft_fast_builder_with(|b| {
|
||||
b.aspect_ratio = Some(CommonAspectRatio::WideSixteenByNine);
|
||||
b.aspect_ratio = Some(RouterAspectRatio::WideSixteenByNine);
|
||||
}));
|
||||
assert_eq!(req.request.aspect_ratio, Some(CommonAspectRatioEnum::WideSixteenByNine));
|
||||
}
|
||||
@@ -101,7 +101,7 @@ mod tests {
|
||||
#[test]
|
||||
fn tall() {
|
||||
let req = unwrap_request(artcraft_fast_builder_with(|b| {
|
||||
b.aspect_ratio = Some(CommonAspectRatio::TallNineBySixteen);
|
||||
b.aspect_ratio = Some(RouterAspectRatio::TallNineBySixteen);
|
||||
}));
|
||||
assert_eq!(req.request.aspect_ratio, Some(CommonAspectRatioEnum::TallNineBySixteen));
|
||||
}
|
||||
@@ -109,7 +109,7 @@ mod tests {
|
||||
#[test]
|
||||
fn square() {
|
||||
let req = unwrap_request(artcraft_fast_builder_with(|b| {
|
||||
b.aspect_ratio = Some(CommonAspectRatio::Square);
|
||||
b.aspect_ratio = Some(RouterAspectRatio::Square);
|
||||
}));
|
||||
assert_eq!(req.request.aspect_ratio, Some(CommonAspectRatioEnum::Square));
|
||||
}
|
||||
@@ -129,7 +129,7 @@ mod tests {
|
||||
#[test]
|
||||
fn res_480p() {
|
||||
let req = unwrap_request(artcraft_fast_builder_with(|b| {
|
||||
b.resolution = Some(CommonResolution::FourEightyP);
|
||||
b.resolution = Some(RouterResolution::FourEightyP);
|
||||
}));
|
||||
assert_eq!(req.request.resolution, Some(CommonResolutionEnum::FourEightyP));
|
||||
}
|
||||
@@ -137,7 +137,7 @@ mod tests {
|
||||
#[test]
|
||||
fn res_720p() {
|
||||
let req = unwrap_request(artcraft_fast_builder_with(|b| {
|
||||
b.resolution = Some(CommonResolution::SevenTwentyP);
|
||||
b.resolution = Some(RouterResolution::SevenTwentyP);
|
||||
}));
|
||||
assert_eq!(req.request.resolution, Some(CommonResolutionEnum::SevenTwentyP));
|
||||
}
|
||||
@@ -145,7 +145,7 @@ mod tests {
|
||||
#[test]
|
||||
fn res_1080p_downgrades_to_720p() {
|
||||
let req = unwrap_request(artcraft_fast_builder_with(|b| {
|
||||
b.resolution = Some(CommonResolution::TenEightyP);
|
||||
b.resolution = Some(RouterResolution::TenEightyP);
|
||||
}));
|
||||
assert_eq!(req.request.resolution, Some(CommonResolutionEnum::SevenTwentyP));
|
||||
}
|
||||
@@ -153,9 +153,9 @@ mod tests {
|
||||
#[test]
|
||||
fn res_1080p_error_out() {
|
||||
let result = build_artcraft_seedance_2p0_u_fast(GenerateVideoRequestBuilder {
|
||||
model: CommonVideoModel::Seedance2p0UltraFast,
|
||||
provider: Provider::Artcraft,
|
||||
resolution: Some(CommonResolution::TenEightyP),
|
||||
model: RouterVideoModel::Seedance2p0UltraFast,
|
||||
provider: RouterProvider::Artcraft,
|
||||
resolution: Some(RouterResolution::TenEightyP),
|
||||
request_mismatch_mitigation_strategy: RequestMismatchMitigationStrategy::ErrorOut,
|
||||
..Default::default()
|
||||
});
|
||||
@@ -186,8 +186,8 @@ mod tests {
|
||||
#[test]
|
||||
fn url_start_frame_rejected() {
|
||||
let result = build_artcraft_seedance_2p0_u_fast(GenerateVideoRequestBuilder {
|
||||
model: CommonVideoModel::Seedance2p0UltraFast,
|
||||
provider: Provider::Artcraft,
|
||||
model: RouterVideoModel::Seedance2p0UltraFast,
|
||||
provider: RouterProvider::Artcraft,
|
||||
start_frame: Some(ImageRef::Url("https://example.com".to_string())),
|
||||
..Default::default()
|
||||
});
|
||||
@@ -223,8 +223,8 @@ mod tests {
|
||||
|
||||
fn artcraft_fast_builder_with(f: impl FnOnce(&mut GenerateVideoRequestBuilder)) -> GenerateVideoRequestBuilder {
|
||||
let mut builder = GenerateVideoRequestBuilder {
|
||||
model: CommonVideoModel::Seedance2p0UltraFast,
|
||||
provider: Provider::Artcraft,
|
||||
model: RouterVideoModel::Seedance2p0UltraFast,
|
||||
provider: RouterProvider::Artcraft,
|
||||
duration_seconds: Some(5),
|
||||
video_batch_count: Some(1),
|
||||
..Default::default()
|
||||
|
||||
+23
-23
@@ -48,9 +48,9 @@ impl ArtcraftSeedance2p0UltraFastCostState {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::api::common_resolution::CommonResolution;
|
||||
use crate::api::common_video_model::CommonVideoModel;
|
||||
use crate::api::provider::Provider;
|
||||
use crate::api::router_resolution::RouterResolution;
|
||||
use crate::api::router_video_model::RouterVideoModel;
|
||||
use crate::api::router_provider::RouterProvider;
|
||||
use crate::generate::generate_video::generate_video_request_builder::GenerateVideoRequestBuilder;
|
||||
|
||||
mod pricing_720p {
|
||||
@@ -59,26 +59,26 @@ mod tests {
|
||||
#[test]
|
||||
fn batch_1() {
|
||||
// 8.9089 * 5 = 44.5445 → ceil = 45¢
|
||||
assert_eq!(cost_cents(Some(CommonResolution::SevenTwentyP), 5, 1), 45);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::SevenTwentyP), 5, 1), 45);
|
||||
// 8.9089 * 10 = 89.089 → ceil = 90¢
|
||||
assert_eq!(cost_cents(Some(CommonResolution::SevenTwentyP), 10, 1), 90);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::SevenTwentyP), 10, 1), 90);
|
||||
// 8.9089 * 15 = 133.6335 → ceil = 134¢
|
||||
assert_eq!(cost_cents(Some(CommonResolution::SevenTwentyP), 15, 1), 134);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::SevenTwentyP), 15, 1), 134);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn batch_2() {
|
||||
assert_eq!(cost_cents(Some(CommonResolution::SevenTwentyP), 10, 2), 180);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::SevenTwentyP), 10, 2), 180);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn batch_4() {
|
||||
assert_eq!(cost_cents(Some(CommonResolution::SevenTwentyP), 10, 4), 360);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::SevenTwentyP), 10, 4), 360);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn none_defaults_to_720p() {
|
||||
assert_eq!(cost_cents(None, 10, 1), cost_cents(Some(CommonResolution::SevenTwentyP), 10, 1));
|
||||
assert_eq!(cost_cents(None, 10, 1), cost_cents(Some(RouterResolution::SevenTwentyP), 10, 1));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,16 +88,16 @@ mod tests {
|
||||
#[test]
|
||||
fn batch_1() {
|
||||
// 3.6267 * 5 = 18.1335 → ceil = 19¢
|
||||
assert_eq!(cost_cents(Some(CommonResolution::FourEightyP), 5, 1), 19);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::FourEightyP), 5, 1), 19);
|
||||
// 3.6267 * 10 = 36.267 → ceil = 37¢
|
||||
assert_eq!(cost_cents(Some(CommonResolution::FourEightyP), 10, 1), 37);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::FourEightyP), 10, 1), 37);
|
||||
// 3.6267 * 15 = 54.4005 → ceil = 55¢
|
||||
assert_eq!(cost_cents(Some(CommonResolution::FourEightyP), 15, 1), 55);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::FourEightyP), 15, 1), 55);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn batch_4() {
|
||||
assert_eq!(cost_cents(Some(CommonResolution::FourEightyP), 10, 4), 148);
|
||||
assert_eq!(cost_cents(Some(RouterResolution::FourEightyP), 10, 4), 148);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,8 +106,8 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn cost_480p_cheaper_than_720p() {
|
||||
let c480 = cost_cents(Some(CommonResolution::FourEightyP), 10, 1);
|
||||
let c720 = cost_cents(Some(CommonResolution::SevenTwentyP), 10, 1);
|
||||
let c480 = cost_cents(Some(RouterResolution::FourEightyP), 10, 1);
|
||||
let c720 = cost_cents(Some(RouterResolution::SevenTwentyP), 10, 1);
|
||||
assert!(c480 < c720, "480p ({c480}) should be < 720p ({c720})");
|
||||
}
|
||||
|
||||
@@ -122,12 +122,12 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn fast_g_cheaper_than_standard_g() {
|
||||
let fast = cost_cents(Some(CommonResolution::SevenTwentyP), 10, 1);
|
||||
let fast = cost_cents(Some(RouterResolution::SevenTwentyP), 10, 1);
|
||||
let standard = {
|
||||
let builder = GenerateVideoRequestBuilder {
|
||||
model: CommonVideoModel::Seedance2p0Ultra,
|
||||
provider: Provider::Artcraft,
|
||||
resolution: Some(CommonResolution::SevenTwentyP),
|
||||
model: RouterVideoModel::Seedance2p0Ultra,
|
||||
provider: RouterProvider::Artcraft,
|
||||
resolution: Some(RouterResolution::SevenTwentyP),
|
||||
duration_seconds: Some(10),
|
||||
video_batch_count: Some(1),
|
||||
..Default::default()
|
||||
@@ -145,13 +145,13 @@ mod tests {
|
||||
}
|
||||
|
||||
fn build_cost(
|
||||
resolution: Option<CommonResolution>,
|
||||
resolution: Option<RouterResolution>,
|
||||
duration_seconds: u16,
|
||||
video_batch_count: u16,
|
||||
) -> crate::generate::generate_video::video_generation_cost_estimate::VideoGenerationCostEstimate {
|
||||
let builder = GenerateVideoRequestBuilder {
|
||||
model: CommonVideoModel::Seedance2p0UltraFast,
|
||||
provider: Provider::Artcraft,
|
||||
model: RouterVideoModel::Seedance2p0UltraFast,
|
||||
provider: RouterProvider::Artcraft,
|
||||
resolution,
|
||||
duration_seconds: Some(duration_seconds),
|
||||
video_batch_count: Some(video_batch_count),
|
||||
@@ -160,7 +160,7 @@ mod tests {
|
||||
builder.build2().expect("build2").estimate_cost().expect("estimate_cost")
|
||||
}
|
||||
|
||||
fn cost_cents(resolution: Option<CommonResolution>, duration_seconds: u16, batch: u16) -> u64 {
|
||||
fn cost_cents(resolution: Option<RouterResolution>, duration_seconds: u16, batch: u16) -> u64 {
|
||||
build_cost(resolution, duration_seconds, batch).cost_in_usd_cents.unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
+15
-15
@@ -22,12 +22,12 @@ mod tests {
|
||||
use tokens::tokens::media_files::MediaFileToken;
|
||||
|
||||
use crate::api::character_list_ref::CharacterListRef;
|
||||
use crate::api::common_aspect_ratio::CommonAspectRatio;
|
||||
use crate::api::common_resolution::CommonResolution;
|
||||
use crate::api::common_video_model::CommonVideoModel;
|
||||
use crate::api::router_aspect_ratio::RouterAspectRatio;
|
||||
use crate::api::router_resolution::RouterResolution;
|
||||
use crate::api::router_video_model::RouterVideoModel;
|
||||
use crate::api::image_list_ref::ImageListRef;
|
||||
use crate::api::image_ref::ImageRef;
|
||||
use crate::api::provider::Provider;
|
||||
use crate::api::router_provider::RouterProvider;
|
||||
use crate::client::router_artcraft_client::RouterArtcraftClient;
|
||||
use crate::client::router_client::RouterClient;
|
||||
use crate::generate::generate_video::generate_video_request_builder::GenerateVideoRequestBuilder;
|
||||
@@ -53,7 +53,7 @@ mod tests {
|
||||
async fn landscape() {
|
||||
let response = run_pipeline(GenerateVideoRequestBuilder {
|
||||
prompt: Some("A corgi running through a field of wildflowers at sunset.".to_string()),
|
||||
aspect_ratio: Some(CommonAspectRatio::WideSixteenByNine),
|
||||
aspect_ratio: Some(RouterAspectRatio::WideSixteenByNine),
|
||||
..artcraft_fast_builder()
|
||||
}).await;
|
||||
assert!(matches!(response, GenerateVideoResponse::Artcraft(_)));
|
||||
@@ -65,7 +65,7 @@ mod tests {
|
||||
async fn portrait() {
|
||||
let response = run_pipeline(GenerateVideoRequestBuilder {
|
||||
prompt: Some("A cat sitting on a windowsill watching rain.".to_string()),
|
||||
aspect_ratio: Some(CommonAspectRatio::TallNineBySixteen),
|
||||
aspect_ratio: Some(RouterAspectRatio::TallNineBySixteen),
|
||||
..artcraft_fast_builder()
|
||||
}).await;
|
||||
assert!(matches!(response, GenerateVideoResponse::Artcraft(_)));
|
||||
@@ -77,7 +77,7 @@ mod tests {
|
||||
async fn square() {
|
||||
let response = run_pipeline(GenerateVideoRequestBuilder {
|
||||
prompt: Some("A hummingbird hovering near a flower.".to_string()),
|
||||
aspect_ratio: Some(CommonAspectRatio::Square),
|
||||
aspect_ratio: Some(RouterAspectRatio::Square),
|
||||
..artcraft_fast_builder()
|
||||
}).await;
|
||||
assert!(matches!(response, GenerateVideoResponse::Artcraft(_)));
|
||||
@@ -95,7 +95,7 @@ mod tests {
|
||||
async fn res_480p() {
|
||||
let response = run_pipeline(GenerateVideoRequestBuilder {
|
||||
prompt: Some("A shiba inu playing in autumn leaves.".to_string()),
|
||||
resolution: Some(CommonResolution::FourEightyP),
|
||||
resolution: Some(RouterResolution::FourEightyP),
|
||||
..artcraft_fast_builder()
|
||||
}).await;
|
||||
assert!(matches!(response, GenerateVideoResponse::Artcraft(_)));
|
||||
@@ -107,7 +107,7 @@ mod tests {
|
||||
async fn res_720p() {
|
||||
let response = run_pipeline(GenerateVideoRequestBuilder {
|
||||
prompt: Some("A golden retriever catching a frisbee on the beach.".to_string()),
|
||||
resolution: Some(CommonResolution::SevenTwentyP),
|
||||
resolution: Some(RouterResolution::SevenTwentyP),
|
||||
..artcraft_fast_builder()
|
||||
}).await;
|
||||
assert!(matches!(response, GenerateVideoResponse::Artcraft(_)));
|
||||
@@ -126,7 +126,7 @@ mod tests {
|
||||
async fn text_to_video() {
|
||||
let response = run_pipeline(GenerateVideoRequestBuilder {
|
||||
prompt: Some("A sky whale breaching in the open sky, pink clouds at dawn, cinematic.".to_string()),
|
||||
aspect_ratio: Some(CommonAspectRatio::WideSixteenByNine),
|
||||
aspect_ratio: Some(RouterAspectRatio::WideSixteenByNine),
|
||||
..artcraft_fast_builder()
|
||||
}).await;
|
||||
assert!(matches!(response, GenerateVideoResponse::Artcraft(_)));
|
||||
@@ -140,7 +140,7 @@ mod tests {
|
||||
prompt: Some("The dog walks from the lake to the forest.".to_string()),
|
||||
start_frame: Some(ImageRef::MediaFileToken(MediaFileToken::new(JUNO_AT_LAKE_PRODUCTION_MEDIA_TOKEN.to_string()))),
|
||||
end_frame: Some(ImageRef::MediaFileToken(MediaFileToken::new(FOREST_BACKDROP_PRODUCTION_MEDIA_TOKEN.to_string()))),
|
||||
aspect_ratio: Some(CommonAspectRatio::WideSixteenByNine),
|
||||
aspect_ratio: Some(RouterAspectRatio::WideSixteenByNine),
|
||||
..artcraft_fast_builder()
|
||||
}).await;
|
||||
assert!(matches!(response, GenerateVideoResponse::Artcraft(_)));
|
||||
@@ -157,7 +157,7 @@ mod tests {
|
||||
MediaFileToken::new(TALL_MOCHI_WITH_GLASSES_PRODUCTION_MEDIA_TOKEN.to_string()),
|
||||
MediaFileToken::new(WHITE_HOUSE_SUNSET_PRODUCTION_MEDIA_TOKEN.to_string()),
|
||||
])),
|
||||
aspect_ratio: Some(CommonAspectRatio::WideSixteenByNine),
|
||||
aspect_ratio: Some(RouterAspectRatio::WideSixteenByNine),
|
||||
..artcraft_fast_builder()
|
||||
}).await;
|
||||
assert!(matches!(response, GenerateVideoResponse::Artcraft(_)));
|
||||
@@ -173,7 +173,7 @@ mod tests {
|
||||
CharacterToken::new(JIM.token.to_string()),
|
||||
CharacterToken::new(KNIGHT.token.to_string()),
|
||||
])),
|
||||
aspect_ratio: Some(CommonAspectRatio::WideSixteenByNine),
|
||||
aspect_ratio: Some(RouterAspectRatio::WideSixteenByNine),
|
||||
..artcraft_fast_builder()
|
||||
}).await;
|
||||
assert!(matches!(response, GenerateVideoResponse::Artcraft(_)));
|
||||
@@ -185,8 +185,8 @@ mod tests {
|
||||
|
||||
fn artcraft_fast_builder() -> GenerateVideoRequestBuilder {
|
||||
GenerateVideoRequestBuilder {
|
||||
model: CommonVideoModel::Seedance2p0UltraFast,
|
||||
provider: Provider::Artcraft,
|
||||
model: RouterVideoModel::Seedance2p0UltraFast,
|
||||
provider: RouterProvider::Artcraft,
|
||||
duration_seconds: Some(4),
|
||||
video_batch_count: Some(1),
|
||||
..Default::default()
|
||||
|
||||
+4
-4
@@ -32,14 +32,14 @@ impl ArtcraftSora2CostState {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::api::common_video_model::CommonVideoModel;
|
||||
use crate::api::provider::Provider;
|
||||
use crate::api::router_video_model::RouterVideoModel;
|
||||
use crate::api::router_provider::RouterProvider;
|
||||
use crate::generate::generate_video::generate_video_request_builder::GenerateVideoRequestBuilder;
|
||||
|
||||
fn cost_cents(duration_seconds: Option<u16>) -> u64 {
|
||||
let b = GenerateVideoRequestBuilder {
|
||||
model: CommonVideoModel::Sora2,
|
||||
provider: Provider::Artcraft,
|
||||
model: RouterVideoModel::Sora2,
|
||||
provider: RouterProvider::Artcraft,
|
||||
prompt: Some("test".to_string()),
|
||||
duration_seconds,
|
||||
..Default::default()
|
||||
|
||||
+13
-13
@@ -47,21 +47,21 @@ fn is_ten_eighty_p_for_cost(resolution: Option<CommonResolutionEnum>, has_start_
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::api::common_resolution::CommonResolution;
|
||||
use crate::api::common_video_model::CommonVideoModel;
|
||||
use crate::api::router_resolution::RouterResolution;
|
||||
use crate::api::router_video_model::RouterVideoModel;
|
||||
use crate::api::image_ref::ImageRef;
|
||||
use crate::api::provider::Provider;
|
||||
use crate::api::router_provider::RouterProvider;
|
||||
use crate::generate::generate_video::generate_video_request_builder::GenerateVideoRequestBuilder;
|
||||
use tokens::tokens::media_files::MediaFileToken;
|
||||
|
||||
fn cost_cents(
|
||||
duration_seconds: Option<u16>,
|
||||
resolution: Option<CommonResolution>,
|
||||
resolution: Option<RouterResolution>,
|
||||
has_start_frame: bool,
|
||||
) -> u64 {
|
||||
let mut b = GenerateVideoRequestBuilder {
|
||||
model: CommonVideoModel::Sora2Pro,
|
||||
provider: Provider::Artcraft,
|
||||
model: RouterVideoModel::Sora2Pro,
|
||||
provider: RouterProvider::Artcraft,
|
||||
prompt: Some("test".to_string()),
|
||||
duration_seconds,
|
||||
resolution,
|
||||
@@ -77,19 +77,19 @@ mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn p720_4s_is_120() { assert_eq!(cost_cents(Some(4), Some(CommonResolution::SevenTwentyP), false), 120); }
|
||||
fn p720_4s_is_120() { assert_eq!(cost_cents(Some(4), Some(RouterResolution::SevenTwentyP), false), 120); }
|
||||
|
||||
#[test]
|
||||
fn p720_8s_is_240() { assert_eq!(cost_cents(Some(8), Some(CommonResolution::SevenTwentyP), false), 240); }
|
||||
fn p720_8s_is_240() { assert_eq!(cost_cents(Some(8), Some(RouterResolution::SevenTwentyP), false), 240); }
|
||||
|
||||
#[test]
|
||||
fn p720_12s_is_360() { assert_eq!(cost_cents(Some(12), Some(CommonResolution::SevenTwentyP), false), 360); }
|
||||
fn p720_12s_is_360() { assert_eq!(cost_cents(Some(12), Some(RouterResolution::SevenTwentyP), false), 360); }
|
||||
|
||||
#[test]
|
||||
fn p1080_4s_is_200() { assert_eq!(cost_cents(Some(4), Some(CommonResolution::TenEightyP), false), 200); }
|
||||
fn p1080_4s_is_200() { assert_eq!(cost_cents(Some(4), Some(RouterResolution::TenEightyP), false), 200); }
|
||||
|
||||
#[test]
|
||||
fn p1080_12s_is_600() { assert_eq!(cost_cents(Some(12), Some(CommonResolution::TenEightyP), false), 600); }
|
||||
fn p1080_12s_is_600() { assert_eq!(cost_cents(Some(12), Some(RouterResolution::TenEightyP), false), 600); }
|
||||
|
||||
#[test]
|
||||
fn t2v_default_resolution_priced_as_1080p() {
|
||||
@@ -106,8 +106,8 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn higher_resolution_costs_more() {
|
||||
let c720 = cost_cents(Some(8), Some(CommonResolution::SevenTwentyP), false);
|
||||
let c1080 = cost_cents(Some(8), Some(CommonResolution::TenEightyP), false);
|
||||
let c720 = cost_cents(Some(8), Some(RouterResolution::SevenTwentyP), false);
|
||||
let c1080 = cost_cents(Some(8), Some(RouterResolution::TenEightyP), false);
|
||||
assert!(c720 < c1080);
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -33,14 +33,14 @@ impl ArtcraftVeo2CostState {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::api::common_video_model::CommonVideoModel;
|
||||
use crate::api::provider::Provider;
|
||||
use crate::api::router_video_model::RouterVideoModel;
|
||||
use crate::api::router_provider::RouterProvider;
|
||||
use crate::generate::generate_video::generate_video_request_builder::GenerateVideoRequestBuilder;
|
||||
|
||||
fn cost_cents(duration_seconds: Option<u16>) -> u64 {
|
||||
let b = GenerateVideoRequestBuilder {
|
||||
model: CommonVideoModel::Veo2,
|
||||
provider: Provider::Artcraft,
|
||||
model: RouterVideoModel::Veo2,
|
||||
provider: RouterProvider::Artcraft,
|
||||
prompt: Some("test".to_string()),
|
||||
duration_seconds,
|
||||
..Default::default()
|
||||
|
||||
+4
-4
@@ -44,14 +44,14 @@ fn duration_seconds_for_cost(d: Option<u16>) -> u64 {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::api::common_video_model::CommonVideoModel;
|
||||
use crate::api::provider::Provider;
|
||||
use crate::api::router_video_model::RouterVideoModel;
|
||||
use crate::api::router_provider::RouterProvider;
|
||||
use crate::generate::generate_video::generate_video_request_builder::GenerateVideoRequestBuilder;
|
||||
|
||||
fn cost_cents(duration_seconds: Option<u16>, generate_audio: Option<bool>) -> u64 {
|
||||
let b = GenerateVideoRequestBuilder {
|
||||
model: CommonVideoModel::Veo3,
|
||||
provider: Provider::Artcraft,
|
||||
model: RouterVideoModel::Veo3,
|
||||
provider: RouterProvider::Artcraft,
|
||||
prompt: Some("test".to_string()),
|
||||
duration_seconds,
|
||||
generate_audio,
|
||||
|
||||
+4
-4
@@ -34,14 +34,14 @@ impl ArtcraftVeo3FastCostState {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::api::common_video_model::CommonVideoModel;
|
||||
use crate::api::provider::Provider;
|
||||
use crate::api::router_video_model::RouterVideoModel;
|
||||
use crate::api::router_provider::RouterProvider;
|
||||
use crate::generate::generate_video::generate_video_request_builder::GenerateVideoRequestBuilder;
|
||||
|
||||
fn cost_cents(duration_seconds: Option<u16>, generate_audio: Option<bool>) -> u64 {
|
||||
let b = GenerateVideoRequestBuilder {
|
||||
model: CommonVideoModel::Veo3Fast,
|
||||
provider: Provider::Artcraft,
|
||||
model: RouterVideoModel::Veo3Fast,
|
||||
provider: RouterProvider::Artcraft,
|
||||
prompt: Some("test".to_string()),
|
||||
duration_seconds,
|
||||
generate_audio,
|
||||
|
||||
+4
-4
@@ -36,14 +36,14 @@ impl ArtcraftVeo3p1CostState {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::api::common_video_model::CommonVideoModel;
|
||||
use crate::api::provider::Provider;
|
||||
use crate::api::router_video_model::RouterVideoModel;
|
||||
use crate::api::router_provider::RouterProvider;
|
||||
use crate::generate::generate_video::generate_video_request_builder::GenerateVideoRequestBuilder;
|
||||
|
||||
fn cost_cents(duration_seconds: Option<u16>, generate_audio: Option<bool>) -> u64 {
|
||||
let b = GenerateVideoRequestBuilder {
|
||||
model: CommonVideoModel::Veo3p1,
|
||||
provider: Provider::Artcraft,
|
||||
model: RouterVideoModel::Veo3p1,
|
||||
provider: RouterProvider::Artcraft,
|
||||
prompt: Some("test".to_string()),
|
||||
duration_seconds,
|
||||
generate_audio,
|
||||
|
||||
+4
-4
@@ -36,14 +36,14 @@ impl ArtcraftVeo3p1FastCostState {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::api::common_video_model::CommonVideoModel;
|
||||
use crate::api::provider::Provider;
|
||||
use crate::api::router_video_model::RouterVideoModel;
|
||||
use crate::api::router_provider::RouterProvider;
|
||||
use crate::generate::generate_video::generate_video_request_builder::GenerateVideoRequestBuilder;
|
||||
|
||||
fn cost_cents(duration_seconds: Option<u16>, generate_audio: Option<bool>) -> u64 {
|
||||
let b = GenerateVideoRequestBuilder {
|
||||
model: CommonVideoModel::Veo3p1Fast,
|
||||
provider: Provider::Artcraft,
|
||||
model: RouterVideoModel::Veo3p1Fast,
|
||||
provider: RouterProvider::Artcraft,
|
||||
prompt: Some("test".to_string()),
|
||||
duration_seconds,
|
||||
generate_audio,
|
||||
|
||||
+13
-13
@@ -2,7 +2,7 @@ use fal_client::requests::webhook::video::image::enqueue_kling_v1p6_pro_image_to
|
||||
Kling1p6ProAspectRatio, Kling1p6ProDuration, Kling1p6ProRequest,
|
||||
};
|
||||
|
||||
use crate::api::common_aspect_ratio::CommonAspectRatio;
|
||||
use crate::api::router_aspect_ratio::RouterAspectRatio;
|
||||
use crate::api::image_ref::ImageRef;
|
||||
use crate::client::request_mismatch_mitigation_strategy::RequestMismatchMitigationStrategy;
|
||||
use crate::errors::artcraft_router_error::ArtcraftRouterError;
|
||||
@@ -63,20 +63,20 @@ pub(crate) fn optional_url(image_ref: Option<ImageRef>) -> Result<Option<String>
|
||||
}
|
||||
|
||||
fn plan_aspect_ratio(
|
||||
aspect_ratio: Option<CommonAspectRatio>,
|
||||
aspect_ratio: Option<RouterAspectRatio>,
|
||||
strategy: RequestMismatchMitigationStrategy,
|
||||
) -> Result<Kling1p6ProAspectRatio, ArtcraftRouterError> {
|
||||
use Kling1p6ProAspectRatio as Ar;
|
||||
match aspect_ratio {
|
||||
None => Ok(Ar::WideSixteenNine),
|
||||
|
||||
Some(CommonAspectRatio::Square) | Some(CommonAspectRatio::SquareHd) => Ok(Ar::Square),
|
||||
Some(CommonAspectRatio::WideSixteenByNine) | Some(CommonAspectRatio::Wide) => Ok(Ar::WideSixteenNine),
|
||||
Some(CommonAspectRatio::TallNineBySixteen) | Some(CommonAspectRatio::Tall) => Ok(Ar::TallNineSixteen),
|
||||
Some(RouterAspectRatio::Square) | Some(RouterAspectRatio::SquareHd) => Ok(Ar::Square),
|
||||
Some(RouterAspectRatio::WideSixteenByNine) | Some(RouterAspectRatio::Wide) => Ok(Ar::WideSixteenNine),
|
||||
Some(RouterAspectRatio::TallNineBySixteen) | Some(RouterAspectRatio::Tall) => Ok(Ar::TallNineSixteen),
|
||||
|
||||
Some(CommonAspectRatio::Auto)
|
||||
| Some(CommonAspectRatio::Auto2k)
|
||||
| Some(CommonAspectRatio::Auto4k) => Ok(Ar::WideSixteenNine),
|
||||
Some(RouterAspectRatio::Auto)
|
||||
| Some(RouterAspectRatio::Auto2k)
|
||||
| Some(RouterAspectRatio::Auto4k) => Ok(Ar::WideSixteenNine),
|
||||
|
||||
Some(other) => match strategy {
|
||||
RequestMismatchMitigationStrategy::ErrorOut => {
|
||||
@@ -113,15 +113,15 @@ fn plan_duration(
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::api::common_video_model::CommonVideoModel;
|
||||
use crate::api::provider::Provider;
|
||||
use crate::api::router_video_model::RouterVideoModel;
|
||||
use crate::api::router_provider::RouterProvider;
|
||||
|
||||
use super::*;
|
||||
|
||||
fn base_builder() -> GenerateVideoRequestBuilder {
|
||||
GenerateVideoRequestBuilder {
|
||||
model: CommonVideoModel::Kling16Pro,
|
||||
provider: Provider::Fal,
|
||||
model: RouterVideoModel::Kling16Pro,
|
||||
provider: RouterProvider::Fal,
|
||||
prompt: Some("test".to_string()),
|
||||
start_frame: Some(ImageRef::Url("https://example.com/a.png".to_string())),
|
||||
..Default::default()
|
||||
@@ -144,7 +144,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn full_combinatorial_pass() {
|
||||
let aspect_ratios = [None, Some(CommonAspectRatio::Square), Some(CommonAspectRatio::WideSixteenByNine), Some(CommonAspectRatio::TallNineBySixteen), Some(CommonAspectRatio::Auto)];
|
||||
let aspect_ratios = [None, Some(RouterAspectRatio::Square), Some(RouterAspectRatio::WideSixteenByNine), Some(RouterAspectRatio::TallNineBySixteen), Some(RouterAspectRatio::Auto)];
|
||||
let durations = [None, Some(5u16), Some(10)];
|
||||
let mut combos = 0;
|
||||
for &aspect_ratio in &aspect_ratios {
|
||||
|
||||
+4
-4
@@ -33,15 +33,15 @@ impl FalKling16ProCostState {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::api::common_video_model::CommonVideoModel;
|
||||
use crate::api::router_video_model::RouterVideoModel;
|
||||
use crate::api::image_ref::ImageRef;
|
||||
use crate::api::provider::Provider;
|
||||
use crate::api::router_provider::RouterProvider;
|
||||
use crate::generate::generate_video::generate_video_request_builder::GenerateVideoRequestBuilder;
|
||||
|
||||
fn cost_cents(duration_seconds: Option<u16>) -> u64 {
|
||||
let b = GenerateVideoRequestBuilder {
|
||||
model: CommonVideoModel::Kling16Pro,
|
||||
provider: Provider::Fal,
|
||||
model: RouterVideoModel::Kling16Pro,
|
||||
provider: RouterProvider::Fal,
|
||||
prompt: Some("test".to_string()),
|
||||
start_frame: Some(ImageRef::Url("https://example.com/a.png".to_string())),
|
||||
duration_seconds,
|
||||
|
||||
+12
-12
@@ -2,7 +2,7 @@ use fal_client::requests::webhook::video::image::enqueue_kling_v2p1_master_image
|
||||
Kling2p1MasterAspectRatio, Kling2p1MasterDuration, Kling2p1MasterRequest,
|
||||
};
|
||||
|
||||
use crate::api::common_aspect_ratio::CommonAspectRatio;
|
||||
use crate::api::router_aspect_ratio::RouterAspectRatio;
|
||||
use crate::client::request_mismatch_mitigation_strategy::RequestMismatchMitigationStrategy;
|
||||
use crate::errors::artcraft_router_error::ArtcraftRouterError;
|
||||
use crate::errors::client_error::ClientError;
|
||||
@@ -41,20 +41,20 @@ pub fn build_fal_kling_2_1_master(
|
||||
}
|
||||
|
||||
fn plan_aspect_ratio(
|
||||
aspect_ratio: Option<CommonAspectRatio>,
|
||||
aspect_ratio: Option<RouterAspectRatio>,
|
||||
strategy: RequestMismatchMitigationStrategy,
|
||||
) -> Result<Kling2p1MasterAspectRatio, ArtcraftRouterError> {
|
||||
use Kling2p1MasterAspectRatio as Ar;
|
||||
match aspect_ratio {
|
||||
None => Ok(Ar::WideSixteenNine),
|
||||
|
||||
Some(CommonAspectRatio::Square) | Some(CommonAspectRatio::SquareHd) => Ok(Ar::Square),
|
||||
Some(CommonAspectRatio::WideSixteenByNine) | Some(CommonAspectRatio::Wide) => Ok(Ar::WideSixteenNine),
|
||||
Some(CommonAspectRatio::TallNineBySixteen) | Some(CommonAspectRatio::Tall) => Ok(Ar::TallNineSixteen),
|
||||
Some(RouterAspectRatio::Square) | Some(RouterAspectRatio::SquareHd) => Ok(Ar::Square),
|
||||
Some(RouterAspectRatio::WideSixteenByNine) | Some(RouterAspectRatio::Wide) => Ok(Ar::WideSixteenNine),
|
||||
Some(RouterAspectRatio::TallNineBySixteen) | Some(RouterAspectRatio::Tall) => Ok(Ar::TallNineSixteen),
|
||||
|
||||
Some(CommonAspectRatio::Auto)
|
||||
| Some(CommonAspectRatio::Auto2k)
|
||||
| Some(CommonAspectRatio::Auto4k) => Ok(Ar::WideSixteenNine),
|
||||
Some(RouterAspectRatio::Auto)
|
||||
| Some(RouterAspectRatio::Auto2k)
|
||||
| Some(RouterAspectRatio::Auto4k) => Ok(Ar::WideSixteenNine),
|
||||
|
||||
Some(other) => match strategy {
|
||||
RequestMismatchMitigationStrategy::ErrorOut => {
|
||||
@@ -91,16 +91,16 @@ fn plan_duration(
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::api::common_video_model::CommonVideoModel;
|
||||
use crate::api::router_video_model::RouterVideoModel;
|
||||
use crate::api::image_ref::ImageRef;
|
||||
use crate::api::provider::Provider;
|
||||
use crate::api::router_provider::RouterProvider;
|
||||
|
||||
use super::*;
|
||||
|
||||
fn base_builder() -> GenerateVideoRequestBuilder {
|
||||
GenerateVideoRequestBuilder {
|
||||
model: CommonVideoModel::Kling21Master,
|
||||
provider: Provider::Fal,
|
||||
model: RouterVideoModel::Kling21Master,
|
||||
provider: RouterProvider::Fal,
|
||||
prompt: Some("test".to_string()),
|
||||
start_frame: Some(ImageRef::Url("https://example.com/a.png".to_string())),
|
||||
..Default::default()
|
||||
|
||||
+4
-4
@@ -33,15 +33,15 @@ impl FalKling21MasterCostState {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::api::common_video_model::CommonVideoModel;
|
||||
use crate::api::router_video_model::RouterVideoModel;
|
||||
use crate::api::image_ref::ImageRef;
|
||||
use crate::api::provider::Provider;
|
||||
use crate::api::router_provider::RouterProvider;
|
||||
use crate::generate::generate_video::generate_video_request_builder::GenerateVideoRequestBuilder;
|
||||
|
||||
fn cost_cents(duration_seconds: Option<u16>) -> u64 {
|
||||
let b = GenerateVideoRequestBuilder {
|
||||
model: CommonVideoModel::Kling21Master,
|
||||
provider: Provider::Fal,
|
||||
model: RouterVideoModel::Kling21Master,
|
||||
provider: RouterProvider::Fal,
|
||||
prompt: Some("test".to_string()),
|
||||
start_frame: Some(ImageRef::Url("https://example.com/a.png".to_string())),
|
||||
duration_seconds,
|
||||
|
||||
+8
-8
@@ -2,7 +2,7 @@ use fal_client::requests::webhook::video::image::enqueue_kling_v2p1_pro_image_to
|
||||
Kling2p1ProAspectRatio, Kling2p1ProDuration, Kling2p1ProRequest,
|
||||
};
|
||||
|
||||
use crate::api::common_aspect_ratio::CommonAspectRatio;
|
||||
use crate::api::router_aspect_ratio::RouterAspectRatio;
|
||||
use crate::client::request_mismatch_mitigation_strategy::RequestMismatchMitigationStrategy;
|
||||
use crate::errors::artcraft_router_error::ArtcraftRouterError;
|
||||
use crate::errors::client_error::ClientError;
|
||||
@@ -36,20 +36,20 @@ pub fn build_fal_kling_2_1_pro(
|
||||
}
|
||||
|
||||
fn plan_aspect_ratio(
|
||||
aspect_ratio: Option<CommonAspectRatio>,
|
||||
aspect_ratio: Option<RouterAspectRatio>,
|
||||
strategy: RequestMismatchMitigationStrategy,
|
||||
) -> Result<Kling2p1ProAspectRatio, ArtcraftRouterError> {
|
||||
use Kling2p1ProAspectRatio as Ar;
|
||||
match aspect_ratio {
|
||||
None => Ok(Ar::WideSixteenNine),
|
||||
|
||||
Some(CommonAspectRatio::Square) | Some(CommonAspectRatio::SquareHd) => Ok(Ar::Square),
|
||||
Some(CommonAspectRatio::WideSixteenByNine) | Some(CommonAspectRatio::Wide) => Ok(Ar::WideSixteenNine),
|
||||
Some(CommonAspectRatio::TallNineBySixteen) | Some(CommonAspectRatio::Tall) => Ok(Ar::TallNineSixteen),
|
||||
Some(RouterAspectRatio::Square) | Some(RouterAspectRatio::SquareHd) => Ok(Ar::Square),
|
||||
Some(RouterAspectRatio::WideSixteenByNine) | Some(RouterAspectRatio::Wide) => Ok(Ar::WideSixteenNine),
|
||||
Some(RouterAspectRatio::TallNineBySixteen) | Some(RouterAspectRatio::Tall) => Ok(Ar::TallNineSixteen),
|
||||
|
||||
Some(CommonAspectRatio::Auto)
|
||||
| Some(CommonAspectRatio::Auto2k)
|
||||
| Some(CommonAspectRatio::Auto4k) => Ok(Ar::WideSixteenNine),
|
||||
Some(RouterAspectRatio::Auto)
|
||||
| Some(RouterAspectRatio::Auto2k)
|
||||
| Some(RouterAspectRatio::Auto4k) => Ok(Ar::WideSixteenNine),
|
||||
|
||||
Some(other) => match strategy {
|
||||
RequestMismatchMitigationStrategy::ErrorOut => {
|
||||
|
||||
+4
-4
@@ -33,15 +33,15 @@ impl FalKling21ProCostState {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::api::common_video_model::CommonVideoModel;
|
||||
use crate::api::router_video_model::RouterVideoModel;
|
||||
use crate::api::image_ref::ImageRef;
|
||||
use crate::api::provider::Provider;
|
||||
use crate::api::router_provider::RouterProvider;
|
||||
use crate::generate::generate_video::generate_video_request_builder::GenerateVideoRequestBuilder;
|
||||
|
||||
fn cost_cents(duration_seconds: Option<u16>) -> u64 {
|
||||
let b = GenerateVideoRequestBuilder {
|
||||
model: CommonVideoModel::Kling21Pro,
|
||||
provider: Provider::Fal,
|
||||
model: RouterVideoModel::Kling21Pro,
|
||||
provider: RouterProvider::Fal,
|
||||
prompt: Some("test".to_string()),
|
||||
start_frame: Some(ImageRef::Url("https://example.com/a.png".to_string())),
|
||||
duration_seconds,
|
||||
|
||||
+12
-12
@@ -6,7 +6,7 @@ use fal_client::requests::webhook::video::text::enqueue_kling_v2p5_turbo_pro_tex
|
||||
EnqueueKlingV2p5TurboProTextToVideoRequest,
|
||||
};
|
||||
|
||||
use crate::api::common_aspect_ratio::CommonAspectRatio;
|
||||
use crate::api::router_aspect_ratio::RouterAspectRatio;
|
||||
use crate::client::request_mismatch_mitigation_strategy::RequestMismatchMitigationStrategy;
|
||||
use crate::errors::artcraft_router_error::ArtcraftRouterError;
|
||||
use crate::errors::client_error::ClientError;
|
||||
@@ -71,20 +71,20 @@ pub fn build_fal_kling_2_5_turbo_pro(
|
||||
}
|
||||
|
||||
fn plan_aspect_ratio(
|
||||
aspect_ratio: Option<CommonAspectRatio>,
|
||||
aspect_ratio: Option<RouterAspectRatio>,
|
||||
strategy: RequestMismatchMitigationStrategy,
|
||||
) -> Result<Option<PlanAspectRatio>, ArtcraftRouterError> {
|
||||
use PlanAspectRatio as Ar;
|
||||
match aspect_ratio {
|
||||
None => Ok(None),
|
||||
|
||||
Some(CommonAspectRatio::Square) | Some(CommonAspectRatio::SquareHd) => Ok(Some(Ar::Square)),
|
||||
Some(CommonAspectRatio::WideSixteenByNine) | Some(CommonAspectRatio::Wide) => Ok(Some(Ar::SixteenByNine)),
|
||||
Some(CommonAspectRatio::TallNineBySixteen) | Some(CommonAspectRatio::Tall) => Ok(Some(Ar::NineBySixteen)),
|
||||
Some(RouterAspectRatio::Square) | Some(RouterAspectRatio::SquareHd) => Ok(Some(Ar::Square)),
|
||||
Some(RouterAspectRatio::WideSixteenByNine) | Some(RouterAspectRatio::Wide) => Ok(Some(Ar::SixteenByNine)),
|
||||
Some(RouterAspectRatio::TallNineBySixteen) | Some(RouterAspectRatio::Tall) => Ok(Some(Ar::NineBySixteen)),
|
||||
|
||||
Some(CommonAspectRatio::Auto)
|
||||
| Some(CommonAspectRatio::Auto2k)
|
||||
| Some(CommonAspectRatio::Auto4k) => Ok(Some(Ar::SixteenByNine)),
|
||||
Some(RouterAspectRatio::Auto)
|
||||
| Some(RouterAspectRatio::Auto2k)
|
||||
| Some(RouterAspectRatio::Auto4k) => Ok(Some(Ar::SixteenByNine)),
|
||||
|
||||
Some(other) => match strategy {
|
||||
RequestMismatchMitigationStrategy::ErrorOut => {
|
||||
@@ -143,16 +143,16 @@ fn to_i2v_duration(d: PlanDuration) -> EnqueueKlingV2p5TurboProImageToVideoDurat
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::api::common_video_model::CommonVideoModel;
|
||||
use crate::api::router_video_model::RouterVideoModel;
|
||||
use crate::api::image_ref::ImageRef;
|
||||
use crate::api::provider::Provider;
|
||||
use crate::api::router_provider::RouterProvider;
|
||||
|
||||
use super::*;
|
||||
|
||||
fn base_builder() -> GenerateVideoRequestBuilder {
|
||||
GenerateVideoRequestBuilder {
|
||||
model: CommonVideoModel::Kling2p5TurboPro,
|
||||
provider: Provider::Fal,
|
||||
model: RouterVideoModel::Kling2p5TurboPro,
|
||||
provider: RouterProvider::Fal,
|
||||
prompt: Some("test".to_string()),
|
||||
..Default::default()
|
||||
}
|
||||
|
||||
+4
-4
@@ -42,15 +42,15 @@ impl FalKling2p5TurboProCostState {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::api::common_video_model::CommonVideoModel;
|
||||
use crate::api::router_video_model::RouterVideoModel;
|
||||
use crate::api::image_ref::ImageRef;
|
||||
use crate::api::provider::Provider;
|
||||
use crate::api::router_provider::RouterProvider;
|
||||
use crate::generate::generate_video::generate_video_request_builder::GenerateVideoRequestBuilder;
|
||||
|
||||
fn cost_cents(duration_seconds: Option<u16>, has_start: bool) -> u64 {
|
||||
let mut b = GenerateVideoRequestBuilder {
|
||||
model: CommonVideoModel::Kling2p5TurboPro,
|
||||
provider: Provider::Fal,
|
||||
model: RouterVideoModel::Kling2p5TurboPro,
|
||||
provider: RouterProvider::Fal,
|
||||
prompt: Some("test".to_string()),
|
||||
duration_seconds,
|
||||
..Default::default()
|
||||
|
||||
+12
-12
@@ -6,7 +6,7 @@ use fal_client::requests::webhook::video::text::enqueue_kling_v2p6_pro_text_to_v
|
||||
EnqueueKlingV2p6ProTextToVideoRequest,
|
||||
};
|
||||
|
||||
use crate::api::common_aspect_ratio::CommonAspectRatio;
|
||||
use crate::api::router_aspect_ratio::RouterAspectRatio;
|
||||
use crate::client::request_mismatch_mitigation_strategy::RequestMismatchMitigationStrategy;
|
||||
use crate::errors::artcraft_router_error::ArtcraftRouterError;
|
||||
use crate::errors::client_error::ClientError;
|
||||
@@ -72,20 +72,20 @@ pub fn build_fal_kling_2_6_pro(
|
||||
}
|
||||
|
||||
fn plan_aspect_ratio(
|
||||
aspect_ratio: Option<CommonAspectRatio>,
|
||||
aspect_ratio: Option<RouterAspectRatio>,
|
||||
strategy: RequestMismatchMitigationStrategy,
|
||||
) -> Result<Option<PlanAspectRatio>, ArtcraftRouterError> {
|
||||
use PlanAspectRatio as Ar;
|
||||
match aspect_ratio {
|
||||
None => Ok(None),
|
||||
|
||||
Some(CommonAspectRatio::Square) | Some(CommonAspectRatio::SquareHd) => Ok(Some(Ar::Square)),
|
||||
Some(CommonAspectRatio::WideSixteenByNine) | Some(CommonAspectRatio::Wide) => Ok(Some(Ar::SixteenByNine)),
|
||||
Some(CommonAspectRatio::TallNineBySixteen) | Some(CommonAspectRatio::Tall) => Ok(Some(Ar::NineBySixteen)),
|
||||
Some(RouterAspectRatio::Square) | Some(RouterAspectRatio::SquareHd) => Ok(Some(Ar::Square)),
|
||||
Some(RouterAspectRatio::WideSixteenByNine) | Some(RouterAspectRatio::Wide) => Ok(Some(Ar::SixteenByNine)),
|
||||
Some(RouterAspectRatio::TallNineBySixteen) | Some(RouterAspectRatio::Tall) => Ok(Some(Ar::NineBySixteen)),
|
||||
|
||||
Some(CommonAspectRatio::Auto)
|
||||
| Some(CommonAspectRatio::Auto2k)
|
||||
| Some(CommonAspectRatio::Auto4k) => Ok(Some(Ar::SixteenByNine)),
|
||||
Some(RouterAspectRatio::Auto)
|
||||
| Some(RouterAspectRatio::Auto2k)
|
||||
| Some(RouterAspectRatio::Auto4k) => Ok(Some(Ar::SixteenByNine)),
|
||||
|
||||
Some(other) => match strategy {
|
||||
RequestMismatchMitigationStrategy::ErrorOut => {
|
||||
@@ -144,16 +144,16 @@ fn to_i2v_duration(d: PlanDuration) -> EnqueueKlingV2p6ProImageToVideoDurationSe
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::api::common_video_model::CommonVideoModel;
|
||||
use crate::api::router_video_model::RouterVideoModel;
|
||||
use crate::api::image_ref::ImageRef;
|
||||
use crate::api::provider::Provider;
|
||||
use crate::api::router_provider::RouterProvider;
|
||||
|
||||
use super::*;
|
||||
|
||||
fn base_builder() -> GenerateVideoRequestBuilder {
|
||||
GenerateVideoRequestBuilder {
|
||||
model: CommonVideoModel::Kling2p6Pro,
|
||||
provider: Provider::Fal,
|
||||
model: RouterVideoModel::Kling2p6Pro,
|
||||
provider: RouterProvider::Fal,
|
||||
prompt: Some("test".to_string()),
|
||||
..Default::default()
|
||||
}
|
||||
|
||||
+4
-4
@@ -52,14 +52,14 @@ impl FalKling2p6ProCostState {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::api::common_video_model::CommonVideoModel;
|
||||
use crate::api::provider::Provider;
|
||||
use crate::api::router_video_model::RouterVideoModel;
|
||||
use crate::api::router_provider::RouterProvider;
|
||||
use crate::generate::generate_video::generate_video_request_builder::GenerateVideoRequestBuilder;
|
||||
|
||||
fn cost_cents(duration_seconds: Option<u16>, generate_audio: Option<bool>) -> u64 {
|
||||
let b = GenerateVideoRequestBuilder {
|
||||
model: CommonVideoModel::Kling2p6Pro,
|
||||
provider: Provider::Fal,
|
||||
model: RouterVideoModel::Kling2p6Pro,
|
||||
provider: RouterProvider::Fal,
|
||||
prompt: Some("test".to_string()),
|
||||
duration_seconds,
|
||||
generate_audio,
|
||||
|
||||
+12
-12
@@ -7,7 +7,7 @@ use fal_client::requests::webhook::video::text::enqueue_kling_3p0_pro_text_to_vi
|
||||
EnqueueKling3p0ProTextToVideoRequest,
|
||||
};
|
||||
|
||||
use crate::api::common_aspect_ratio::CommonAspectRatio;
|
||||
use crate::api::router_aspect_ratio::RouterAspectRatio;
|
||||
use crate::client::request_mismatch_mitigation_strategy::RequestMismatchMitigationStrategy;
|
||||
use crate::errors::artcraft_router_error::ArtcraftRouterError;
|
||||
use crate::errors::client_error::ClientError;
|
||||
@@ -86,20 +86,20 @@ fn build_kling_3p0_pro_state(
|
||||
}
|
||||
|
||||
pub(crate) fn plan_aspect_ratio(
|
||||
aspect_ratio: Option<CommonAspectRatio>,
|
||||
aspect_ratio: Option<RouterAspectRatio>,
|
||||
strategy: RequestMismatchMitigationStrategy,
|
||||
) -> Result<Option<PlanAspectRatio>, ArtcraftRouterError> {
|
||||
use PlanAspectRatio as Ar;
|
||||
match aspect_ratio {
|
||||
None => Ok(None),
|
||||
|
||||
Some(CommonAspectRatio::Square) | Some(CommonAspectRatio::SquareHd) => Ok(Some(Ar::Square)),
|
||||
Some(CommonAspectRatio::WideSixteenByNine) | Some(CommonAspectRatio::Wide) => Ok(Some(Ar::SixteenByNine)),
|
||||
Some(CommonAspectRatio::TallNineBySixteen) | Some(CommonAspectRatio::Tall) => Ok(Some(Ar::NineBySixteen)),
|
||||
Some(RouterAspectRatio::Square) | Some(RouterAspectRatio::SquareHd) => Ok(Some(Ar::Square)),
|
||||
Some(RouterAspectRatio::WideSixteenByNine) | Some(RouterAspectRatio::Wide) => Ok(Some(Ar::SixteenByNine)),
|
||||
Some(RouterAspectRatio::TallNineBySixteen) | Some(RouterAspectRatio::Tall) => Ok(Some(Ar::NineBySixteen)),
|
||||
|
||||
Some(CommonAspectRatio::Auto)
|
||||
| Some(CommonAspectRatio::Auto2k)
|
||||
| Some(CommonAspectRatio::Auto4k) => Ok(Some(Ar::SixteenByNine)),
|
||||
Some(RouterAspectRatio::Auto)
|
||||
| Some(RouterAspectRatio::Auto2k)
|
||||
| Some(RouterAspectRatio::Auto4k) => Ok(Some(Ar::SixteenByNine)),
|
||||
|
||||
Some(other) => match strategy {
|
||||
RequestMismatchMitigationStrategy::ErrorOut => {
|
||||
@@ -188,17 +188,17 @@ fn to_i2v_aspect_ratio(a: PlanAspectRatio) -> EnqueueKling3p0ProImageToVideoAspe
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::api::common_video_model::CommonVideoModel;
|
||||
use crate::api::router_video_model::RouterVideoModel;
|
||||
use crate::api::image_ref::ImageRef;
|
||||
use crate::api::provider::Provider;
|
||||
use crate::api::router_provider::RouterProvider;
|
||||
use crate::client::request_mismatch_mitigation_strategy::RequestMismatchMitigationStrategy;
|
||||
|
||||
use super::*;
|
||||
|
||||
fn base_builder() -> GenerateVideoRequestBuilder {
|
||||
GenerateVideoRequestBuilder {
|
||||
model: CommonVideoModel::Kling3p0Pro,
|
||||
provider: Provider::Fal,
|
||||
model: RouterVideoModel::Kling3p0Pro,
|
||||
provider: RouterProvider::Fal,
|
||||
prompt: Some("test".to_string()),
|
||||
..Default::default()
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user