fix: 编译错误 (\b 转义 + 临时变量生命周期)
This commit is contained in:
@@ -337,16 +337,16 @@ fn parse_llama_output(raw: &str) -> String {
|
|||||||
// 清理进度动画字符 |/-\ 和转义序列 \b
|
// 清理进度动画字符 |/-\ 和转义序列 \b
|
||||||
// llama-cli 的进度动画用 \b(退格)刷新,stdout 捕获后变成字面 \b
|
// llama-cli 的进度动画用 \b(退格)刷新,stdout 捕获后变成字面 \b
|
||||||
let cleaned: String = trimmed
|
let cleaned: String = trimmed
|
||||||
.replace("\\b", "") // 退格转义
|
.replace("\\b", "")
|
||||||
.chars()
|
.chars()
|
||||||
.filter(|c| !"|\\-/".contains(*c))
|
.filter(|c| !"|\\-/".contains(*c))
|
||||||
.collect();
|
.collect::<String>();
|
||||||
let cleaned = cleaned.trim();
|
let cleaned_str = cleaned.trim();
|
||||||
if cleaned.is_empty() {
|
if cleaned_str.is_empty() {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
reply_lines.push(cleaned);
|
reply_lines.push(cleaned_str.to_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
reply_lines.join("\n").trim().to_string()
|
reply_lines.join("\n").trim().to_string()
|
||||||
@@ -359,12 +359,12 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test_parse_llama_output() {
|
fn test_parse_llama_output() {
|
||||||
// 进度动画和回复在同一行,用 \b 分隔
|
// 进度动画和回复在同一行,用 \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\
|
model : model_store/llm/qwen2.5-0.5b-q4_k_m.gguf\n\
|
||||||
\n\
|
\n\
|
||||||
> hello\n\
|
> hello\n\
|
||||||
\n\
|
\n\
|
||||||
\\b-\\b\\\\\\b|\\b/\\b-\\b\\\\\\b|\\b/\\b \b汪!\n\
|
\\b-\\b\\\\\\b|\\b/\\b-\\b\\\\\\b|\\b/\\b 汪!\n\
|
||||||
\n\
|
\n\
|
||||||
[ Prompt: 31.1 t/s | Generation: 26.3 t/s ]\n\
|
[ Prompt: 31.1 t/s | Generation: 26.3 t/s ]\n\
|
||||||
\n\
|
\n\
|
||||||
|
|||||||
Reference in New Issue
Block a user