From 3ac322ca9787f15f5c8cc873b86ab2acbe30d412 Mon Sep 17 00:00:00 2001 From: Brandon Thomas Date: Sun, 28 Dec 2025 23:00:54 -0500 Subject: [PATCH] begin reorganizing library modules --- ..._kling_v1p6_pro_image_to_video_webhook.rs} | 36 +++++++++---------- ...ing_v2p1_master_image_to_video_webhook.rs} | 36 +++++++++---------- .../src/requests/webhook/video/image/mod.rs | 2 ++ .../src/requests/webhook/video/mod.rs | 2 -- .../generate_kling_1_6_pro_video_handler.rs | 23 ++++++------ ...generate_kling_2_1_master_video_handler.rs | 23 ++++++------ 6 files changed, 58 insertions(+), 64 deletions(-) rename crates/api_clients/fal_client/src/requests/webhook/video/{enqueue_kling_16_pro_image_to_video_webhook.rs => image/enqueue_kling_v1p6_pro_image_to_video_webhook.rs} (64%) rename crates/api_clients/fal_client/src/requests/webhook/video/{enqueue_kling_21_master_image_to_video_webhook.rs => image/enqueue_kling_v2p1_master_image_to_video_webhook.rs} (62%) diff --git a/crates/api_clients/fal_client/src/requests/webhook/video/enqueue_kling_16_pro_image_to_video_webhook.rs b/crates/api_clients/fal_client/src/requests/webhook/video/image/enqueue_kling_v1p6_pro_image_to_video_webhook.rs similarity index 64% rename from crates/api_clients/fal_client/src/requests/webhook/video/enqueue_kling_16_pro_image_to_video_webhook.rs rename to crates/api_clients/fal_client/src/requests/webhook/video/image/enqueue_kling_v1p6_pro_image_to_video_webhook.rs index c97ff638e8..5b49544f33 100644 --- a/crates/api_clients/fal_client/src/requests/webhook/video/enqueue_kling_16_pro_image_to_video_webhook.rs +++ b/crates/api_clients/fal_client/src/requests/webhook/video/image/enqueue_kling_v1p6_pro_image_to_video_webhook.rs @@ -5,43 +5,43 @@ use fal::endpoints::fal_ai::kling_video::v1_6::pro::image_to_video::{image_to_vi use fal::webhook::WebhookResponse; use reqwest::IntoUrl; -pub struct Kling16ProArgs<'a, U: IntoUrl, T: IntoUrl, V: IntoUrl> { +pub struct Kling1p6ProArgs<'a, U: IntoUrl, T: IntoUrl, V: IntoUrl> { pub image_url: U, pub end_frame_image_url: Option, pub webhook_url: V, pub prompt: &'a str, pub api_key: &'a FalApiKey, - pub duration: Kling16Duration, - pub aspect_ratio: Kling16ProAspectRatio, + pub duration: Kling1p6ProDuration, + pub aspect_ratio: Kling1p6ProAspectRatio, } #[derive(Copy, Clone, Debug)] -pub enum Kling16Duration { +pub enum Kling1p6ProDuration { Default, FiveSeconds, TenSeconds, } #[derive(Copy, Clone, Debug)] -pub enum Kling16ProAspectRatio { +pub enum Kling1p6ProAspectRatio { Square, // 1:1 WideSixteenNine, // 16:9 TallNineSixteen, // 9:16 } -pub async fn enqueue_kling_16_pro_image_to_video_webhook( - args: Kling16ProArgs<'_, U, T, V> +pub async fn enqueue_kling_v1p6_pro_image_to_video_webhook( + args: Kling1p6ProArgs<'_, U, T, V> ) -> Result { let duration = match args.duration { - Kling16Duration::Default => None, - Kling16Duration::FiveSeconds => Some("5".to_string()), // Gross... - Kling16Duration::TenSeconds => Some("10".to_string()), + Kling1p6ProDuration::Default => None, + Kling1p6ProDuration::FiveSeconds => Some("5".to_string()), // Gross... + Kling1p6ProDuration::TenSeconds => Some("10".to_string()), }; let aspect_ratio = match args.aspect_ratio { - Kling16ProAspectRatio::Square => Some("1:1".to_string()), - Kling16ProAspectRatio::WideSixteenNine => Some("16:9".to_string()), - Kling16ProAspectRatio::TallNineSixteen => Some("9:16".to_string()), + Kling1p6ProAspectRatio::Square => Some("1:1".to_string()), + Kling1p6ProAspectRatio::WideSixteenNine => Some("16:9".to_string()), + Kling1p6ProAspectRatio::TallNineSixteen => Some("9:16".to_string()), }; let image_url = args.image_url.as_str().to_string(); @@ -71,7 +71,7 @@ pub async fn enqueue_kling_16_pro_image_to_video_webhook { +pub struct Kling2p1MasterArgs<'a, U: IntoUrl, V: IntoUrl> { pub image_url: U, pub webhook_url: V, pub prompt: &'a str, pub api_key: &'a FalApiKey, - pub duration: Kling21MasterDuration, - pub aspect_ratio: Kling21MasterAspectRatio, + pub duration: Kling2p1MasterDuration, + pub aspect_ratio: Kling2p1MasterAspectRatio, } #[derive(Copy, Clone, Debug)] -pub enum Kling21MasterDuration { +pub enum Kling2p1MasterDuration { Default, FiveSeconds, TenSeconds, } #[derive(Copy, Clone, Debug)] -pub enum Kling21MasterAspectRatio { +pub enum Kling2p1MasterAspectRatio { Square, // 1:1 WideSixteenNine, // 16:9 TallNineSixteen, // 9:16 } -pub async fn enqueue_kling_21_master_image_to_video_webhook( - args: Kling21MasterArgs<'_, U, V> +pub async fn enqueue_kling_v2p1_master_image_to_video_webhook( + args: Kling2p1MasterArgs<'_, U, V> ) -> Result { let duration = match args.duration { - Kling21MasterDuration::Default => None, - Kling21MasterDuration::FiveSeconds => Some("5".to_string()), // Gross... - Kling21MasterDuration::TenSeconds => Some("10".to_string()), + Kling2p1MasterDuration::Default => None, + Kling2p1MasterDuration::FiveSeconds => Some("5".to_string()), // Gross... + Kling2p1MasterDuration::TenSeconds => Some("10".to_string()), }; let aspect_ratio = match args.aspect_ratio { - Kling21MasterAspectRatio::Square => Some("1:1".to_string()), - Kling21MasterAspectRatio::WideSixteenNine => Some("16:9".to_string()), - Kling21MasterAspectRatio::TallNineSixteen => Some("9:16".to_string()), + Kling2p1MasterAspectRatio::Square => Some("1:1".to_string()), + Kling2p1MasterAspectRatio::WideSixteenNine => Some("16:9".to_string()), + Kling2p1MasterAspectRatio::TallNineSixteen => Some("9:16".to_string()), }; let image_url = args.image_url.as_str().to_string(); @@ -68,7 +68,7 @@ pub async fn enqueue_kling_21_master_image_to_video_webhook Kling16ProAspectRatio::Square, - Some(GenerateKling16ProAspectRatio::WideSixteenNine) => Kling16ProAspectRatio::WideSixteenNine, - Some(GenerateKling16ProAspectRatio::TallNineSixteen) => Kling16ProAspectRatio::TallNineSixteen, - None => Kling16ProAspectRatio::WideSixteenNine, // Default to 16:9 + Some(GenerateKling16ProAspectRatio::Square) => Kling1p6ProAspectRatio::Square, + Some(GenerateKling16ProAspectRatio::WideSixteenNine) => Kling1p6ProAspectRatio::WideSixteenNine, + Some(GenerateKling16ProAspectRatio::TallNineSixteen) => Kling1p6ProAspectRatio::TallNineSixteen, + None => Kling1p6ProAspectRatio::WideSixteenNine, // Default to 16:9 }; let duration = match &request.duration { - Some(GenerateKling16ProDuration::FiveSeconds) => Kling16Duration::FiveSeconds, - Some(GenerateKling16ProDuration::TenSeconds) => Kling16Duration::TenSeconds, - None => Kling16Duration::FiveSeconds, + Some(GenerateKling16ProDuration::FiveSeconds) => Kling1p6ProDuration::FiveSeconds, + Some(GenerateKling16ProDuration::TenSeconds) => Kling1p6ProDuration::TenSeconds, + None => Kling1p6ProDuration::FiveSeconds, }; - let args = Kling16ProArgs { + let args = Kling1p6ProArgs { image_url: start_frame_url, end_frame_image_url: maybe_end_frame_url, webhook_url: &server_state.fal.webhook_url, @@ -173,7 +170,7 @@ pub async fn generate_kling_1_6_pro_video_handler( api_key: &server_state.fal.api_key, }; - let fal_result = enqueue_kling_16_pro_image_to_video_webhook(args) + let fal_result = enqueue_kling_v1p6_pro_image_to_video_webhook(args) .await .map_err(|err| { warn!("Error calling enqueue_kling_16_pro_image_to_video_webhook: {:?}", err); diff --git a/crates/service/web/storyteller_web/src/http_server/endpoints/generate/video/generate_kling_2_1_master_video_handler.rs b/crates/service/web/storyteller_web/src/http_server/endpoints/generate/video/generate_kling_2_1_master_video_handler.rs index 829447d490..18f8d9f08c 100644 --- a/crates/service/web/storyteller_web/src/http_server/endpoints/generate/video/generate_kling_2_1_master_video_handler.rs +++ b/crates/service/web/storyteller_web/src/http_server/endpoints/generate/video/generate_kling_2_1_master_video_handler.rs @@ -15,10 +15,7 @@ use enums::by_table::prompts::prompt_type::PromptType; use enums::common::generation_provider::GenerationProvider; use enums::common::model_type::ModelType; use enums::common::visibility::Visibility; -use fal_client::requests::webhook::video::enqueue_kling_21_master_image_to_video_webhook::enqueue_kling_21_master_image_to_video_webhook; -use fal_client::requests::webhook::video::enqueue_kling_21_master_image_to_video_webhook::Kling21MasterArgs; -use fal_client::requests::webhook::video::enqueue_kling_21_master_image_to_video_webhook::Kling21MasterAspectRatio; -use fal_client::requests::webhook::video::enqueue_kling_21_master_image_to_video_webhook::Kling21MasterDuration; +use fal_client::requests::webhook::video::image::enqueue_kling_v2p1_master_image_to_video_webhook::{enqueue_kling_v2p1_master_image_to_video_webhook, Kling2p1MasterArgs, Kling2p1MasterAspectRatio, Kling2p1MasterDuration}; use http_server_common::request::get_request_ip::get_request_ip; use log::{error, info, warn}; use mysql_queries::queries::generic_inference::fal::insert_generic_inference_job_for_fal_queue::insert_generic_inference_job_for_fal_queue; @@ -139,19 +136,19 @@ pub async fn generate_kling_2_1_master_video_handler( .unwrap_or_else(|| ""); let aspect_ratio = match &request.aspect_ratio { - Some(GenerateKling21MasterAspectRatio::Square) => Kling21MasterAspectRatio::Square, - Some(GenerateKling21MasterAspectRatio::WideSixteenNine) => Kling21MasterAspectRatio::WideSixteenNine, - Some(GenerateKling21MasterAspectRatio::TallNineSixteen) => Kling21MasterAspectRatio::TallNineSixteen, - None => Kling21MasterAspectRatio::WideSixteenNine, // Default to 16:9 + Some(GenerateKling21MasterAspectRatio::Square) => Kling2p1MasterAspectRatio::Square, + Some(GenerateKling21MasterAspectRatio::WideSixteenNine) => Kling2p1MasterAspectRatio::WideSixteenNine, + Some(GenerateKling21MasterAspectRatio::TallNineSixteen) => Kling2p1MasterAspectRatio::TallNineSixteen, + None => Kling2p1MasterAspectRatio::WideSixteenNine, // Default to 16:9 }; let duration = match &request.duration { - Some(GenerateKling21MasterDuration::FiveSeconds) => Kling21MasterDuration::FiveSeconds, - Some(GenerateKling21MasterDuration::TenSeconds) => Kling21MasterDuration::TenSeconds, - None => Kling21MasterDuration::FiveSeconds, + Some(GenerateKling21MasterDuration::FiveSeconds) => Kling2p1MasterDuration::FiveSeconds, + Some(GenerateKling21MasterDuration::TenSeconds) => Kling2p1MasterDuration::TenSeconds, + None => Kling2p1MasterDuration::FiveSeconds, }; - let args = Kling21MasterArgs { + let args = Kling2p1MasterArgs { image_url: media_links.cdn_url, webhook_url: &server_state.fal.webhook_url, duration, @@ -160,7 +157,7 @@ pub async fn generate_kling_2_1_master_video_handler( api_key: &server_state.fal.api_key, }; - let fal_result = enqueue_kling_21_master_image_to_video_webhook(args) + let fal_result = enqueue_kling_v2p1_master_image_to_video_webhook(args) .await .map_err(|err| { warn!("Error calling enqueue_kling_21_master_image_to_video_webhook: {:?}", err);