diff --git a/src/plugins/ai/backend.rs b/src/plugins/ai/backend.rs index ca659da..1b1f3ba 100644 --- a/src/plugins/ai/backend.rs +++ b/src/plugins/ai/backend.rs @@ -337,16 +337,16 @@ fn parse_llama_output(raw: &str) -> String { // 清理进度动画字符 |/-\ 和转义序列 \b // llama-cli 的进度动画用 \b(退格)刷新,stdout 捕获后变成字面 \b let cleaned: String = trimmed - .replace("\\b", "") // 退格转义 + .replace("\\b", "") .chars() .filter(|c| !"|\\-/".contains(*c)) - .collect(); - let cleaned = cleaned.trim(); - if cleaned.is_empty() { + .collect::(); + let cleaned_str = cleaned.trim(); + if cleaned_str.is_empty() { continue; } - reply_lines.push(cleaned); + reply_lines.push(cleaned_str.to_string()); } reply_lines.join("\n").trim().to_string() @@ -359,12 +359,12 @@ mod tests { #[test] fn test_parse_llama_output() { // 进度动画和回复在同一行,用 \b 分隔 - let raw = " █ █ build : b1-fdb1db8\n\ + let raw = " build : b1-fdb1db8\n\ model : model_store/llm/qwen2.5-0.5b-q4_k_m.gguf\n\ \n\ > hello\n\ \n\ -\\b-\\b\\\\\\b|\\b/\\b-\\b\\\\\\b|\\b/\\b \b汪!\n\ +\\b-\\b\\\\\\b|\\b/\\b-\\b\\\\\\b|\\b/\\b 汪!\n\ \n\ [ Prompt: 31.1 t/s | Generation: 26.3 t/s ]\n\ \n\