fix: handle both reasoning_content and reasoning fields for NVIDIA API
All checks were successful
BotServer CI/CD / build (push) Successful in 3m12s
All checks were successful
BotServer CI/CD / build (push) Successful in 3m12s
This commit is contained in:
parent
8ddcde4830
commit
60fd3dbbc4
1 changed files with 7 additions and 5 deletions
|
|
@ -461,12 +461,14 @@ impl LLMProvider for OpenAIClient {
|
||||||
let chunk_str = String::from_utf8_lossy(&chunk);
|
let chunk_str = String::from_utf8_lossy(&chunk);
|
||||||
for line in chunk_str.lines() {
|
for line in chunk_str.lines() {
|
||||||
if line.starts_with("data: ") && !line.contains("[DONE]") {
|
if line.starts_with("data: ") && !line.contains("[DONE]") {
|
||||||
if let Ok(data) = serde_json::from_str::<Value>(&line[6..]) {
|
if let Ok(data) = serde_json::from_str::<Value>(&line[6..]) {
|
||||||
let content = data["choices"][0]["delta"]["content"].as_str();
|
let content = data["choices"][0]["delta"]["content"].as_str();
|
||||||
let reasoning = data["choices"][0]["delta"]["reasoning_content"].as_str();
|
// Handle both reasoning_content (GLM4.7) and reasoning (Kimi K2.5)
|
||||||
|
let reasoning = data["choices"][0]["delta"]["reasoning_content"].as_str()
|
||||||
|
.or_else(|| data["choices"][0]["delta"]["reasoning"].as_str());
|
||||||
|
|
||||||
// Detect reasoning phase (GLM4.7, Kimi K2.5)
|
// Detect reasoning phase (GLM4.7, Kimi K2.5)
|
||||||
if reasoning.is_some() && content.is_none() {
|
if reasoning.is_some() && content.is_none() {
|
||||||
if !in_reasoning {
|
if !in_reasoning {
|
||||||
trace!("[LLM] Entering reasoning/thinking mode");
|
trace!("[LLM] Entering reasoning/thinking mode");
|
||||||
in_reasoning = true;
|
in_reasoning = true;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue