mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-08 11:01:35 +00:00
upload worked
This commit is contained in:
1 parent
cb4294967e
commit
d2cf59d2be
3 files changed
+34
-11
No files matched your search
+30
-9
@@ -31,6 +31,7 @@ use std::io::Write;
|
||||
use std::path::PathBuf;
|
||||
use storyteller_client::credentials::storyteller_credential_set::StorytellerCredentialSet;
|
||||
use storyteller_client::endpoints::media_files::upload_image_media_file_from_file::{upload_image_media_file_from_file, UploadImageFromFileArgs};
|
||||
use storyteller_client::endpoints::media_files::upload_video_media_file_from_file::upload_video_media_file_from_file;
|
||||
use storyteller_client::endpoints::prompts::create_prompt::create_prompt;
|
||||
use tauri::AppHandle;
|
||||
use tempdir::TempDir;
|
||||
@@ -43,6 +44,13 @@ pub struct SuccessfulGeneration {
|
||||
pub struct GenerationItem {
|
||||
pub item_id: String,
|
||||
pub url: String,
|
||||
pub generation_type: GenerationType,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
pub enum GenerationType {
|
||||
Image,
|
||||
Video,
|
||||
}
|
||||
|
||||
pub async fn handle_classic_successful_generations(
|
||||
@@ -84,16 +92,29 @@ pub async fn handle_classic_successful_generations(
|
||||
|
||||
info!("Uploading to backend...");
|
||||
|
||||
let result = upload_image_media_file_from_file(UploadImageFromFileArgs {
|
||||
api_host: &app_env_configs.storyteller_host,
|
||||
maybe_creds: Some(&storyteller_creds),
|
||||
path: download_path,
|
||||
is_intermediate_system_file: false,
|
||||
maybe_prompt_token: Some(&prompt_response.prompt_token),
|
||||
maybe_batch_token: None, // TODO: This should be added soon.
|
||||
}).await?;
|
||||
match generation.generation_type {
|
||||
GenerationType::Image => {
|
||||
let result = upload_image_media_file_from_file(UploadImageFromFileArgs {
|
||||
api_host: &app_env_configs.storyteller_host,
|
||||
maybe_creds: Some(&storyteller_creds),
|
||||
path: download_path,
|
||||
is_intermediate_system_file: false,
|
||||
maybe_prompt_token: Some(&prompt_response.prompt_token),
|
||||
maybe_batch_token: None, // TODO: This should be added soon.
|
||||
}).await?;
|
||||
|
||||
info!("Uploaded to API backend: {:?}", result.media_file_token);
|
||||
info!("Uploaded image to API backend: {:?}", result.media_file_token);
|
||||
}
|
||||
GenerationType::Video => {
|
||||
let result = upload_video_media_file_from_file(
|
||||
&app_env_configs.storyteller_host,
|
||||
Some(&storyteller_creds),
|
||||
download_path,
|
||||
).await?;
|
||||
|
||||
info!("Uploaded video to API backend: {:?}", result.media_file_token);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Clear from SQLite task database.
|
||||
|
||||
+2
-1
@@ -11,7 +11,7 @@ use crate::core::utils::task_database_pending_statuses::TASK_DATABASE_PENDING_ST
|
||||
use crate::services::sora::state::sora_credential_manager::SoraCredentialManager;
|
||||
use crate::services::sora::state::sora_task_queue::SoraTaskQueue;
|
||||
use crate::services::sora::threads::sora_task_polling::helpers::handle_failed_generations::{handle_classic_failed_generations, FailedGeneration};
|
||||
use crate::services::sora::threads::sora_task_polling::helpers::handle_successful_generations::{handle_classic_successful_generations, GenerationItem, SuccessfulGeneration};
|
||||
use crate::services::sora::threads::sora_task_polling::helpers::handle_successful_generations::{handle_classic_successful_generations, GenerationItem, GenerationType, SuccessfulGeneration};
|
||||
use crate::services::storyteller::state::storyteller_credential_manager::StorytellerCredentialManager;
|
||||
use artcraft_api_defs::prompts::create_prompt::CreatePromptRequest;
|
||||
use enums::common::generation_provider::GenerationProvider;
|
||||
@@ -77,6 +77,7 @@ pub async fn poll_classic_sora_tasks(
|
||||
GenerationItem {
|
||||
item_id: gen.id.clone(),
|
||||
url: gen.url.clone(),
|
||||
generation_type: GenerationType::Image, // TODO: Support video
|
||||
}
|
||||
})
|
||||
.collect()
|
||||
|
||||
+2
-1
@@ -11,7 +11,7 @@ use crate::core::utils::task_database_pending_statuses::TASK_DATABASE_PENDING_ST
|
||||
use crate::services::sora::state::sora_credential_manager::SoraCredentialManager;
|
||||
use crate::services::sora::state::sora_task_queue::SoraTaskQueue;
|
||||
use crate::services::sora::threads::sora_task_polling::helpers::handle_failed_generations::{handle_classic_failed_generations, FailedGeneration};
|
||||
use crate::services::sora::threads::sora_task_polling::helpers::handle_successful_generations::{handle_classic_successful_generations, GenerationItem, SuccessfulGeneration};
|
||||
use crate::services::sora::threads::sora_task_polling::helpers::handle_successful_generations::{handle_classic_successful_generations, GenerationItem, GenerationType, SuccessfulGeneration};
|
||||
use crate::services::storyteller::state::storyteller_credential_manager::StorytellerCredentialManager;
|
||||
use artcraft_api_defs::prompts::create_prompt::CreatePromptRequest;
|
||||
use enums::common::generation_provider::GenerationProvider;
|
||||
@@ -76,6 +76,7 @@ pub async fn poll_sora_2_tasks(
|
||||
items: vec![GenerationItem {
|
||||
item_id: success_draft.id,
|
||||
url: success_draft.url,
|
||||
generation_type: GenerationType::Video,
|
||||
}]
|
||||
});
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user