修复kimi返回信息的读取错误

This commit is contained in:
2026-05-27 14:50:47 +08:00
parent 4331b9306e
commit b8182e7538
2 changed files with 13 additions and 3 deletions

View File

@@ -346,7 +346,17 @@ impl KimiClient {
.choices
.into_iter()
.next()
.map(|c| c.message.content.trim().to_string())
.map(|c| {
let content = c.message.content.trim().to_string();
if content.is_empty() {
c.reasoning_content
.or(c.message.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"))
}