Auto-open draft result after foundation completes
This commit is contained in:
@@ -82,7 +82,11 @@ pub struct AppConfig {
|
||||
pub llm_retry_backoff_ms: u64,
|
||||
pub dashscope_base_url: String,
|
||||
pub dashscope_api_key: Option<String>,
|
||||
pub dashscope_scene_image_model: String,
|
||||
pub dashscope_reference_image_model: String,
|
||||
pub dashscope_cover_image_model: String,
|
||||
pub dashscope_image_request_timeout_ms: u64,
|
||||
pub draft_asset_generation_max_concurrent_requests: usize,
|
||||
pub ark_character_video_base_url: String,
|
||||
pub ark_character_video_api_key: Option<String>,
|
||||
pub ark_character_video_request_timeout_ms: u64,
|
||||
@@ -166,7 +170,11 @@ impl Default for AppConfig {
|
||||
llm_retry_backoff_ms: DEFAULT_RETRY_BACKOFF_MS,
|
||||
dashscope_base_url: "https://dashscope.aliyuncs.com/api/v1".to_string(),
|
||||
dashscope_api_key: None,
|
||||
dashscope_scene_image_model: "wan2.2-t2i-flash".to_string(),
|
||||
dashscope_reference_image_model: "qwen-image-2.0".to_string(),
|
||||
dashscope_cover_image_model: "wan2.2-t2i-flash".to_string(),
|
||||
dashscope_image_request_timeout_ms: 150_000,
|
||||
draft_asset_generation_max_concurrent_requests: 4,
|
||||
ark_character_video_base_url: DEFAULT_ARK_BASE_URL.to_string(),
|
||||
ark_character_video_api_key: None,
|
||||
ark_character_video_request_timeout_ms: 420_000,
|
||||
@@ -397,16 +405,14 @@ impl AppConfig {
|
||||
if let Some(spacetime_server_url) = read_first_non_empty_env(&[
|
||||
"GENARRATIVE_SPACETIME_SERVER_URL",
|
||||
"GENARRATIVE_SPACETIME_MAINCLOUD_SERVER_URL",
|
||||
])
|
||||
{
|
||||
]) {
|
||||
config.spacetime_server_url = spacetime_server_url;
|
||||
}
|
||||
|
||||
if let Some(spacetime_database) = read_first_non_empty_env(&[
|
||||
"GENARRATIVE_SPACETIME_DATABASE",
|
||||
"GENARRATIVE_SPACETIME_MAINCLOUD_DATABASE",
|
||||
])
|
||||
{
|
||||
]) {
|
||||
config.spacetime_database = spacetime_database;
|
||||
}
|
||||
|
||||
@@ -466,12 +472,38 @@ impl AppConfig {
|
||||
|
||||
config.dashscope_api_key = read_first_non_empty_env(&["DASHSCOPE_API_KEY"]);
|
||||
|
||||
if let Some(dashscope_scene_image_model) =
|
||||
read_first_non_empty_env(&["DASHSCOPE_SCENE_IMAGE_MODEL", "DASHSCOPE_IMAGE_MODEL"])
|
||||
{
|
||||
config.dashscope_scene_image_model = dashscope_scene_image_model;
|
||||
}
|
||||
|
||||
if let Some(dashscope_reference_image_model) = read_first_non_empty_env(&[
|
||||
"DASHSCOPE_REFERENCE_IMAGE_MODEL",
|
||||
"DASHSCOPE_IMAGE_EDIT_MODEL",
|
||||
]) {
|
||||
config.dashscope_reference_image_model = dashscope_reference_image_model;
|
||||
}
|
||||
|
||||
if let Some(dashscope_cover_image_model) =
|
||||
read_first_non_empty_env(&["DASHSCOPE_COVER_IMAGE_MODEL", "DASHSCOPE_IMAGE_MODEL"])
|
||||
{
|
||||
config.dashscope_cover_image_model = dashscope_cover_image_model;
|
||||
}
|
||||
|
||||
if let Some(dashscope_image_request_timeout_ms) =
|
||||
read_first_positive_u64_env(&["DASHSCOPE_IMAGE_REQUEST_TIMEOUT_MS"])
|
||||
{
|
||||
config.dashscope_image_request_timeout_ms = dashscope_image_request_timeout_ms;
|
||||
}
|
||||
|
||||
if let Some(max_concurrent_requests) = read_first_usize_env(&[
|
||||
"GENARRATIVE_DRAFT_ASSET_GENERATION_MAX_CONCURRENT_REQUESTS",
|
||||
"DRAFT_ASSET_GENERATION_MAX_CONCURRENT_REQUESTS",
|
||||
]) {
|
||||
config.draft_asset_generation_max_concurrent_requests = max_concurrent_requests;
|
||||
}
|
||||
|
||||
if let Some(ark_character_video_base_url) = read_first_non_empty_env(&[
|
||||
"ARK_CHARACTER_VIDEO_BASE_URL",
|
||||
"ARK_BASE_URL",
|
||||
@@ -625,6 +657,14 @@ fn read_first_u64_env(keys: &[&str]) -> Option<u64> {
|
||||
.find_map(|key| env::var(key).ok().and_then(|value| parse_u64(&value)))
|
||||
}
|
||||
|
||||
fn read_first_usize_env(keys: &[&str]) -> Option<usize> {
|
||||
keys.iter().find_map(|key| {
|
||||
env::var(key)
|
||||
.ok()
|
||||
.and_then(|value| parse_positive_usize(&value))
|
||||
})
|
||||
}
|
||||
|
||||
fn read_first_u8_env(keys: &[&str]) -> Option<u8> {
|
||||
keys.iter()
|
||||
.find_map(|key| env::var(key).ok().and_then(|value| parse_u8(&value)))
|
||||
@@ -706,6 +746,15 @@ fn parse_u64(raw: &str) -> Option<u64> {
|
||||
raw.trim().parse::<u64>().ok()
|
||||
}
|
||||
|
||||
fn parse_positive_usize(raw: &str) -> Option<usize> {
|
||||
let value = raw.trim().parse::<usize>().ok()?;
|
||||
if value == 0 {
|
||||
return None;
|
||||
}
|
||||
|
||||
Some(value)
|
||||
}
|
||||
|
||||
fn parse_u8(raw: &str) -> Option<u8> {
|
||||
raw.trim().parse::<u8>().ok()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user