修复bug

This commit is contained in:
2026-05-26 16:30:28 +08:00
parent 1063369d96
commit a08bc809bb
3 changed files with 44 additions and 7 deletions

View File

@@ -242,8 +242,21 @@ impl KimiClient {
result.choices
.into_iter()
.next()
.map(|c| c.message.content.trim().to_string())
.ok_or_else(|| anyhow::anyhow!("No response from Kimi"))
.map(|c| {
let content = c.message.content.trim().to_string();
if content.is_empty() {
c.reasoning_content
.map(|r| r.trim().to_string())
.unwrap_or_default()
} else {
content
}
})
.filter(|s| !s.is_empty())
.ok_or_else(|| anyhow::anyhow!(
"No response from Kimi. \
If thinking mode is enabled, try disabling it or ensure the model supports it."
))
}
}