mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-05 01:38:44 +00:00
landscape
This commit is contained in:
1 parent
d3c7145090
commit
ef419e5646
5 files changed
+66
-8
No files matched your search
+3
-1
@@ -27,7 +27,7 @@ pub async fn generate_sora2_video_with_session_auto_renew(
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::recipes::generate_sora2_video::generate_sora2_video_with_session_auto_renew::generate_sora2_video_with_session_auto_renew;
|
||||
use crate::requests::generate_sora2_video::generate_sora2_video::GenerateSora2VideoArgs;
|
||||
use crate::requests::generate_sora2_video::generate_sora2_video::{GenerateSora2VideoArgs, Orientation};
|
||||
use crate::test_utils::get_test_credentials::get_test_credentials;
|
||||
use errors::AnyhowResult;
|
||||
|
||||
@@ -40,6 +40,8 @@ mod tests {
|
||||
prompt: "a dog playing tennis",
|
||||
credentials: &creds,
|
||||
request_timeout: None,
|
||||
orientation: Orientation::Landscape,
|
||||
image_reference_media_ids: None,
|
||||
};
|
||||
|
||||
let (result , creds) =
|
||||
|
||||
+33
-5
@@ -4,7 +4,7 @@ use crate::error::sora_client_error::SoraClientError;
|
||||
use crate::error::sora_error::SoraError;
|
||||
use crate::error::sora_generic_api_error::SoraGenericApiError;
|
||||
use crate::requests::common::task_id::TaskId;
|
||||
use crate::requests::generate_sora2_video::http_request::HttpCreateRequest;
|
||||
use crate::requests::generate_sora2_video::http_request::{HttpCreateRequest, InpaintItem};
|
||||
use crate::requests::generate_sora2_video::http_response::HttpCreateResponse;
|
||||
use crate::requests::image_gen::image_gen_http_request::{RawSoraImageGenRequest, RawSoraResponse};
|
||||
use log::error;
|
||||
@@ -19,6 +19,14 @@ pub struct GenerateSora2VideoArgs<'a> {
|
||||
pub prompt: &'a str,
|
||||
pub credentials: &'a SoraCredentialSet,
|
||||
pub request_timeout: Option<Duration>,
|
||||
pub orientation: Orientation,
|
||||
pub image_reference_media_ids: Option<&'a Vec<String>>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
pub enum Orientation {
|
||||
Portrait,
|
||||
Landscape,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
@@ -68,14 +76,32 @@ pub (crate) async fn generate_sora2_video(
|
||||
http_request = http_request.timeout(timeout);
|
||||
}
|
||||
|
||||
let orientation = match args.orientation {
|
||||
Orientation::Portrait => "portrait",
|
||||
Orientation::Landscape => "landscape",
|
||||
};
|
||||
|
||||
let inpaint_items;
|
||||
|
||||
if let Some(media_ids) = args.image_reference_media_ids {
|
||||
inpaint_items = media_ids.iter()
|
||||
.map(|item_id| InpaintItem {
|
||||
kind: "upload".to_string(),
|
||||
upload_id: item_id.to_string(),
|
||||
})
|
||||
.collect();
|
||||
} else {
|
||||
inpaint_items = Vec::new();
|
||||
}
|
||||
|
||||
let request_body = HttpCreateRequest {
|
||||
kind: "video".to_string(),
|
||||
prompt: args.prompt.to_string(),
|
||||
title: None,
|
||||
orientation: "portrait".to_string(),
|
||||
orientation: orientation.to_string(),
|
||||
size: "small".to_string(),
|
||||
n_frames: 300,
|
||||
inpaint_items: vec![],
|
||||
inpaint_items,
|
||||
cameo_ids: None,
|
||||
cameo_replacements: None,
|
||||
model: "sy_8".to_string(),
|
||||
@@ -126,7 +152,7 @@ pub (crate) async fn generate_sora2_video(
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::requests::generate_sora2_video::generate_sora2_video::{generate_sora2_video, GenerateSora2VideoArgs};
|
||||
use crate::requests::generate_sora2_video::generate_sora2_video::{generate_sora2_video, GenerateSora2VideoArgs, Orientation};
|
||||
use crate::test_utils::get_test_credentials::get_test_credentials;
|
||||
use errors::AnyhowResult;
|
||||
|
||||
@@ -135,9 +161,11 @@ mod tests {
|
||||
pub async fn manual_test() -> AnyhowResult<()> {
|
||||
let creds = get_test_credentials()?;
|
||||
let request = GenerateSora2VideoArgs {
|
||||
prompt: "A cute baby sea otter wearing a beret and glasses, sitting on a rock and reading a book, digital art",
|
||||
prompt: "A cute corgi wearing glasses, sitting on a picnic blanket and reading a book, digital art",
|
||||
credentials: &creds,
|
||||
request_timeout: None,
|
||||
orientation: Orientation::Landscape,
|
||||
image_reference_media_ids: None,
|
||||
};
|
||||
let result = generate_sora2_video(request).await?;
|
||||
println!("result: {:#?}", result);
|
||||
|
||||
+11
-1
@@ -22,7 +22,7 @@ pub (super) struct HttpCreateRequest {
|
||||
pub n_frames: u16,
|
||||
|
||||
// NB: sent as empty array
|
||||
pub inpaint_items: Vec<String>,
|
||||
pub inpaint_items: Vec<InpaintItem>,
|
||||
|
||||
// NB: Sent as null
|
||||
pub cameo_ids: Option<String>,
|
||||
@@ -48,3 +48,13 @@ pub (super) struct HttpCreateRequest {
|
||||
// NB: Sent as null
|
||||
pub storyboard_id: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub (super) struct InpaintItem {
|
||||
// eg. "upload"
|
||||
pub kind: String,
|
||||
|
||||
// eg. "media_01abc..."
|
||||
pub upload_id: String,
|
||||
}
|
||||
@@ -212,6 +212,22 @@ export const GalleryModal = React.memo(
|
||||
}
|
||||
};
|
||||
|
||||
const getLabel = (item: any) => {
|
||||
if (!!item.maybe_title) {
|
||||
return item.maybe_title;
|
||||
}
|
||||
switch (item.media_class) {
|
||||
case "image":
|
||||
return "Image Generation";
|
||||
case "video":
|
||||
return "Video Generation";
|
||||
case "dimensional":
|
||||
return "3D Object Generation";
|
||||
default:
|
||||
return "Generation";
|
||||
}
|
||||
};
|
||||
|
||||
const loadItems = async (reset = false) => {
|
||||
if (!username) return;
|
||||
setLoading(true);
|
||||
@@ -240,7 +256,7 @@ export const GalleryModal = React.memo(
|
||||
)
|
||||
.map((item: any) => ({
|
||||
id: item.token,
|
||||
label: item.maybe_title || "Image Generation",
|
||||
label: getLabel(item),
|
||||
thumbnail:
|
||||
item.media_class === "video"
|
||||
? item.media_links.maybe_video_previews.animated
|
||||
|
||||
@@ -13,6 +13,7 @@ export const MODEL_TYPE_TO_CREATOR: Record<string, ModelCreator> = {
|
||||
kling_2p1_pro: ModelCreator.Kling,
|
||||
kling_2p1_master: ModelCreator.Kling,
|
||||
seedance_1p0_lite: ModelCreator.Bytedance,
|
||||
sora_2: ModelCreator.OpenAi,
|
||||
veo_2: ModelCreator.Google,
|
||||
recraft_3: ModelCreator.Recraft,
|
||||
hunyuan_3d: ModelCreator.Tencent,
|
||||
@@ -96,6 +97,7 @@ export const getModelDisplayName = (modelType: string): string => {
|
||||
kling_2p1_master: "Kling 2.1 Master",
|
||||
seedance_1p0_lite: "Seedance 1.0 Lite",
|
||||
veo_2: "Veo 2",
|
||||
sora_2: "Sora 2",
|
||||
recraft_3: "Recraft 3",
|
||||
hunyuan_3d_2p0: "Hunyuan 3D 2.0",
|
||||
hunyuan_3d_2p1: "Hunyuan 3D 2.1",
|
||||
|
||||
Reference in new issue
Block a user