Add built-in Cloud video template fallback

This commit is contained in:
boos
2026-06-06 02:58:16 +08:00
parent 598b2f48d6
commit 2b836b3e1e
2 changed files with 76 additions and 7 deletions
+57 -1
View File
@@ -723,6 +723,25 @@ fn workflow_prompt_from_graph(graph: &Value) -> Value {
.unwrap_or_else(|| graph.clone())
}
fn default_cloud_seedance_prompt() -> Value {
json!({
"1": {
"class_type": "ByteDanceTextToVideoNode",
"inputs": {
"model": "seedance-1-0-lite-t2v-250428",
"prompt": "A clean vertical product demo video, minimal futuristic interface, smooth camera movement, bright studio lighting",
"resolution": "480p",
"aspect_ratio": "9:16",
"duration": 5,
"seed": 0,
"camera_fixed": false,
"watermark": false,
"generate_audio": false
}
}
})
}
async fn workflow_prompt_from_body(
state: &AppState,
auth: &MoneyPrinterAuth,
@@ -747,8 +766,11 @@ async fn workflow_prompt_from_body(
.await?;
return Ok(workflow_prompt_from_graph(&workflow.graph));
}
if state.config.comfyui.uses_cloud_backend() {
return Ok(default_cloud_seedance_prompt());
}
Err(AppError::BadRequest(
"Comfy API 模式需要选择真实 Comfy/Cloud 视频工作流模板,不能使用 BoosAPI 自定义节点".into(),
"Comfy API 模式需要选择真实 Comfy/Cloud 视频工作流模板;Cloud 模式可使用内置 Seedance 兜底模板".into(),
))
}
@@ -856,11 +878,45 @@ fn inject_comfy_video_inputs(prompt: &mut Value, mapping: &Value, body: &Value,
}
fn repair_money_printer_comfy_prompt(prompt: &mut Value) {
repair_bytedance_video_nodes(prompt);
repair_resize_image_mask_nodes(prompt);
repair_text_generate_ltx2_prompt_nodes(prompt);
repair_wan2_api_nodes(prompt);
}
fn repair_bytedance_video_nodes(prompt: &mut Value) {
let Some(nodes) = prompt.as_object_mut() else {
return;
};
for (_node_id, node) in nodes.iter_mut() {
let class_type = node.get("class_type").and_then(Value::as_str).unwrap_or_default();
if !matches!(class_type, "ByteDanceTextToVideoNode" | "ByteDance2TextToVideoNode") {
continue;
}
let Some(inputs) = node.get_mut("inputs").and_then(Value::as_object_mut) else {
continue;
};
if let Some(duration) = inputs.get("duration").and_then(value_to_duration_seconds) {
inputs.insert("duration".to_string(), json!(duration.clamp(3, 12)));
}
if let Some(duration) = inputs.get("model.duration").and_then(value_to_duration_seconds) {
inputs.insert("model.duration".to_string(), json!(duration.clamp(4, 15)));
}
if inputs
.get("resolution")
.is_some_and(|value| !matches!(value.as_str(), Some("480p" | "720p" | "1080p")))
{
inputs.insert("resolution".to_string(), json!("480p"));
}
if inputs
.get("aspect_ratio")
.is_some_and(|value| !matches!(value.as_str(), Some("16:9" | "4:3" | "1:1" | "3:4" | "9:16" | "21:9")))
{
inputs.insert("aspect_ratio".to_string(), json!("9:16"));
}
}
}
fn repair_resize_image_mask_nodes(prompt: &mut Value) {
let Some(nodes) = prompt.as_object_mut() else {
return;