fix: 修复工作流结果获取逻辑
- 移除响应URL比较条件,总是尝试获取最终结果 - 优化GET请求逻辑,确保能正确获取工作流执行结果 - 解决响应URL相同时无法获取结果的问题 现在无论响应URL是否改变,都会尝试对响应URL进行GET请求来获取包含output_files的完整结果。
This commit is contained in:
parent
07239ee53c
commit
03a87223de
|
|
@ -123,25 +123,19 @@ impl ComfyuiInfrastructureService {
|
||||||
let response_url = response.url().to_string();
|
let response_url = response.url().to_string();
|
||||||
info!("Response URL: {}", response_url);
|
info!("Response URL: {}", response_url);
|
||||||
|
|
||||||
// 尝试解析响应,如果失败则返回基本成功响应
|
|
||||||
let initial_result: Value = response.json().await
|
|
||||||
.unwrap_or_else(|_| serde_json::json!({}));
|
|
||||||
|
|
||||||
info!("Workflow '{}' execution started", request.base_name);
|
info!("Workflow '{}' execution started", request.base_name);
|
||||||
|
|
||||||
// 如果响应URL不同于请求URL,说明需要访问新的URL获取结果
|
// 总是尝试用 GET 请求获取最终结果
|
||||||
if response_url != url {
|
info!("Using GET request to fetch final result from: {}", response_url);
|
||||||
info!("Fetching final result from: {}", response_url);
|
|
||||||
|
|
||||||
// 访问响应URL获取最终结果
|
|
||||||
match self.client.get(&response_url).send().await {
|
match self.client.get(&response_url).send().await {
|
||||||
Ok(final_response) => {
|
Ok(final_response) => {
|
||||||
if final_response.status().is_success() {
|
if final_response.status().is_success() {
|
||||||
match final_response.json::<Value>().await {
|
match final_response.json::<Value>().await {
|
||||||
Ok(final_result) => {
|
Ok(final_result) => {
|
||||||
info!("Successfully retrieved final result");
|
info!("Successfully retrieved final result via GET");
|
||||||
let execute_response = ExecuteWorkflowResponse {
|
let execute_response = ExecuteWorkflowResponse {
|
||||||
task_id: initial_result.get("task_id").and_then(|v| v.as_str()).map(String::from),
|
task_id: None, // GET 请求通常不返回 task_id
|
||||||
status: Some("completed".to_string()),
|
status: Some("completed".to_string()),
|
||||||
message: Some("Workflow execution completed successfully".to_string()),
|
message: Some("Workflow execution completed successfully".to_string()),
|
||||||
result: Some(final_result),
|
result: Some(final_result),
|
||||||
|
|
@ -161,9 +155,11 @@ impl ComfyuiInfrastructureService {
|
||||||
warn!("Failed to request final result: {}", e);
|
warn!("Failed to request final result: {}", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// 如果无法获取最终结果,返回初始响应
|
// 如果无法获取最终结果,解析初始响应
|
||||||
|
let initial_result: Value = response.json().await
|
||||||
|
.unwrap_or_else(|_| serde_json::json!({}));
|
||||||
|
|
||||||
let execute_response = ExecuteWorkflowResponse {
|
let execute_response = ExecuteWorkflowResponse {
|
||||||
task_id: initial_result.get("task_id").and_then(|v| v.as_str()).map(String::from),
|
task_id: initial_result.get("task_id").and_then(|v| v.as_str()).map(String::from),
|
||||||
status: initial_result.get("status").and_then(|v| v.as_str()).map(String::from),
|
status: initial_result.get("status").and_then(|v| v.as_str()).map(String::from),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue