feat(ai): add comprehensive AI streaming and non-streaming processing services
Some checks are pending
CI / Rust Lint & Check (push) Waiting to run
CI / Rust Tests (push) Waiting to run
CI / Frontend Lint & Type Check (push) Waiting to run
CI / Frontend Build (push) Blocked by required conditions

This commit is contained in:
ZhenYi 2026-05-01 00:54:24 +08:00
parent 96b92fe487
commit fdca1fbf86
5 changed files with 10 additions and 10 deletions

View File

@ -188,8 +188,8 @@ pub async fn run_mode_streaming(
let (final_content, err_msg) = match result {
Ok((content, _input, _output)) => (content, None),
Err(e) => {
let msg = "[AI 处理发生错误,请稍后再试]".to_string();
tracing::error!(error = %e, "{} streaming failed", mode_name);
let msg = format!("AI 处理失败: {}", e);
tracing::error!(error = ?e, "{} streaming failed", mode_name);
(String::new(), Some(msg))
}
};

View File

@ -66,7 +66,7 @@ pub async fn process_message_ai_nonstreaming(
}
}
Err(e) => {
tracing::error!(error = %e, "AI processing failed");
tracing::error!(error = ?e, "AI processing failed");
let _ = create_and_publish_ai_message(
&db,
&cache,
@ -75,7 +75,7 @@ pub async fn process_message_ai_nonstreaming(
room_id,
project_id,
Uuid::now_v7(),
"[AI 处理发生错误,请稍后再试]".to_string(),
format!("AI 处理失败: {}", e),
model_id,
Some(model_display_name),
)

View File

@ -68,7 +68,7 @@ pub async fn process_message_ai_react_nonstreaming(
}
}
Err(e) => {
tracing::error!(error = %e, "ReAct agent failed");
tracing::error!(error = ?e, "ReAct agent failed");
let _ = create_and_publish_ai_message(
&db,
&cache,
@ -77,7 +77,7 @@ pub async fn process_message_ai_react_nonstreaming(
room_id,
project_id,
Uuid::now_v7(),
"[AI 处理发生错误,请稍后再试]".to_string(),
format!("AI 处理失败: {}", e),
model_id,
Some(model_display_name),
)

View File

@ -196,8 +196,8 @@ pub async fn process_message_ai_react_streaming(
let (final_content, _input_tokens, _output_tokens, err_msg, _should_log) = match result {
Ok((content, input, output)) => (content, input, output, None, false),
Err(e) => {
let msg = "[AI 处理发生错误,请稍后再试]".to_string();
tracing::error!(error = %e, "ReAct streaming failed");
let msg = format!("AI 处理失败: {}", e);
tracing::error!(error = ?e, "ReAct streaming failed");
(String::new(), 0, 0, Some(msg), true)
}
};

View File

@ -247,7 +247,7 @@ pub async fn process_message_ai_streaming(
}
}
Err(e) => {
tracing::error!(error = %e, "AI streaming failed");
tracing::error!(error = ?e, "AI streaming failed");
let _ = typing_cancel_tx.send(());
typing_renew_handle.abort();
let typing_stop = queue::TypingEvent {
@ -266,7 +266,7 @@ pub async fn process_message_ai_streaming(
seq: 0,
content: String::new(),
done: true,
error: Some("AI 处理发生错误,请稍后再试".to_string()),
error: Some(format!("AI 处理失败: {}", e)),
display_name: Some(ai_display_name.clone()),
chunk_type: None,
};