Generate MoneyPrinter Comfy prompts from form

This commit is contained in:
boos
2026-06-02 17:18:23 +08:00
parent d0f26118ff
commit fe0e3faa22
2 changed files with 106 additions and 28 deletions
+30 -3
View File
@@ -687,6 +687,35 @@ fn workflow_prompt_from_graph(graph: &Value) -> Value {
.unwrap_or_else(|| graph.clone())
}
fn generated_comfy_prompt_from_request(body: &Value) -> Value {
let model = string_from(body, &["videoModel", "video_model", "model"])
.unwrap_or_else(|| "seedance-1-0-lite-t2v".to_string());
let ratio = string_from(body, &["ratio", "aspectRatio", "aspect_ratio"]).unwrap_or_else(|| "9:16".to_string());
let resolution = string_from(body, &["resolution", "size"]).unwrap_or_else(|| "1080p".to_string());
let duration = body
.get("duration")
.cloned()
.unwrap_or_else(|| json!(30));
json!({
"1": {
"class_type": "BoosAPITextToVideo",
"inputs": {
"model": model,
"prompt": "",
"ratio": ratio,
"resolution": resolution,
"duration": duration
}
},
"2": {
"class_type": "output.preview_video",
"inputs": {
"video": ["1", 0]
}
}
})
}
async fn workflow_prompt_from_body(
state: &AppState,
auth: &MoneyPrinterAuth,
@@ -711,9 +740,7 @@ async fn workflow_prompt_from_body(
.await?;
return Ok(workflow_prompt_from_graph(&workflow.graph));
}
Err(AppError::BadRequest(
"Comfy API 模式需要选择工作流模板,或传入 comfyPrompt/promptWorkflow 和节点映射".into(),
))
Ok(generated_comfy_prompt_from_request(body))
}
fn apply_node_input(prompt: &mut Value, node_id: &str, field: &str, value: Value) -> AppResult<()> {