feat(digital-human): 后端转发 llm_model 给 Pixelle
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1661,13 +1661,32 @@ fn output_item_from_reference(value: &str) -> Option<Value> {
|
|||||||
.next()
|
.next()
|
||||||
.unwrap_or("digital-human-output")
|
.unwrap_or("digital-human-output")
|
||||||
.to_string();
|
.to_string();
|
||||||
|
let proxied_url = pixelle_proxy_url_for_reference(trimmed);
|
||||||
Some(json!({
|
Some(json!({
|
||||||
"url": trimmed,
|
"url": trimmed,
|
||||||
|
"fileUrl": proxied_url,
|
||||||
|
"proxiedUrl": proxied_url,
|
||||||
"filename": filename,
|
"filename": filename,
|
||||||
"type": "output"
|
"type": "output"
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn pixelle_proxy_url_for_reference(value: &str) -> String {
|
||||||
|
let trimmed = value.trim();
|
||||||
|
if let Some(path) = trimmed.strip_prefix("/api/files/") {
|
||||||
|
return format!("/api/digital-human/pixelle/files/{path}");
|
||||||
|
}
|
||||||
|
if let Ok(url) = url::Url::parse(trimmed) {
|
||||||
|
if matches!(url.host_str(), Some("127.0.0.1") | Some("localhost"))
|
||||||
|
&& url.path().starts_with("/api/files/")
|
||||||
|
{
|
||||||
|
let path = url.path().trim_start_matches("/api/files/");
|
||||||
|
return format!("/api/digital-human/pixelle/files/{path}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
trimmed.to_string()
|
||||||
|
}
|
||||||
|
|
||||||
fn output_filename(item: &Value) -> Option<String> {
|
fn output_filename(item: &Value) -> Option<String> {
|
||||||
["filename", "fileName", "name", "file"]
|
["filename", "fileName", "name", "file"]
|
||||||
.iter()
|
.iter()
|
||||||
@@ -1814,6 +1833,7 @@ async fn archive_output(
|
|||||||
"filename": filename,
|
"filename": filename,
|
||||||
"status": asset.status,
|
"status": asset.status,
|
||||||
"remoteUrl": asset.remote_url,
|
"remoteUrl": asset.remote_url,
|
||||||
|
"fileUrl": pixelle_proxy_url_for_reference(&remote_url),
|
||||||
"fileName": asset.file_name,
|
"fileName": asset.file_name,
|
||||||
})),
|
})),
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
@@ -1879,6 +1899,12 @@ async fn archive_output(
|
|||||||
"kind": kind,
|
"kind": kind,
|
||||||
"filename": filename,
|
"filename": filename,
|
||||||
"status": asset.status,
|
"status": asset.status,
|
||||||
|
"fileUrl": format!(
|
||||||
|
"{}/api/{}/workspace/assets/{}/file",
|
||||||
|
public_base_url(state),
|
||||||
|
if auth.user_id.is_some() { "user" } else { "" }.trim_matches('/'),
|
||||||
|
asset.public_id
|
||||||
|
).replace("/api//", "/api/"),
|
||||||
})),
|
})),
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
tracing::warn!(%err, "failed to archive digital human output");
|
tracing::warn!(%err, "failed to archive digital human output");
|
||||||
@@ -2079,6 +2105,9 @@ fn pixelle_request_body(state: &AppState, body: &Value) -> AppResult<(String, Va
|
|||||||
if let Some(value) = optional_string(body, &["apiVideoWorkflow", "api_video_workflow"]) {
|
if let Some(value) = optional_string(body, &["apiVideoWorkflow", "api_video_workflow"]) {
|
||||||
request_body["api_video_workflow"] = json!(value);
|
request_body["api_video_workflow"] = json!(value);
|
||||||
}
|
}
|
||||||
|
if let Some(value) = optional_string(body, &["llmModel", "llm_model"]) {
|
||||||
|
request_body["llm_model"] = json!(value);
|
||||||
|
}
|
||||||
if let Some(value) = reference_audio_url {
|
if let Some(value) = reference_audio_url {
|
||||||
request_body["ref_audio"] = json!(value);
|
request_body["ref_audio"] = json!(value);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user