Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lib/async-openai/src/types/chat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1157,6 +1157,10 @@ pub struct ChatChoice {
/// Log probability information for the choice.
#[serde(skip_serializing_if = "Option::is_none")]
pub logprobs: Option<ChatChoiceLogprobs>,
/// Flag indicating whether this choice includes reasoning content.
/// Set to `true` when `message.reasoning_content` is present.
#[serde(skip_serializing_if = "Option::is_none")]
pub has_reasoning: Option<bool>,
}

/// Represents a chat completion response returned by model, based on the provided input.
Expand Down Expand Up @@ -1256,6 +1260,10 @@ pub struct ChatChoiceStream {
/// Log probability information for the choice.
#[serde(skip_serializing_if = "Option::is_none")]
pub logprobs: Option<ChatChoiceLogprobs>,
/// Flag indicating whether this choice includes reasoning content.
/// Set to `true` when `delta.reasoning_content` is present.
#[serde(skip_serializing_if = "Option::is_none")]
pub has_reasoning: Option<bool>,
}

#[derive(ToSchema, Debug, Deserialize, Clone, PartialEq, Serialize)]
Expand Down
4 changes: 4 additions & 0 deletions lib/llm/src/audit/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ pub fn final_response_to_one_chunk_stream(
finish_reason: ch.finish_reason,
stop_reason: ch.stop_reason.clone(),
logprobs: ch.logprobs.clone(),
has_reasoning: ch.has_reasoning,
};
choices.push(choice);
}
Expand Down Expand Up @@ -272,6 +273,7 @@ mod tests {
finish_reason: None,
stop_reason: None,
logprobs: None,
has_reasoning: None,
};

let response = NvCreateChatCompletionStreamResponse {
Expand Down Expand Up @@ -311,6 +313,7 @@ mod tests {
finish_reason: Some(FinishReason::Stop),
stop_reason: None,
logprobs: None,
has_reasoning: None,
};

let response = NvCreateChatCompletionStreamResponse {
Expand Down Expand Up @@ -441,6 +444,7 @@ mod tests {
finish_reason: None,
stop_reason: None,
logprobs: None,
has_reasoning: None,
}
}],
created: 1234567890,
Expand Down
6 changes: 6 additions & 0 deletions lib/llm/src/protocols/openai/chat_completions/aggregator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,11 @@ impl From<DeltaChoice> for dynamo_async_openai::types::ChatChoice {
None
};

let has_reasoning = delta
.reasoning_content
.as_ref()
.is_some_and(|r| !r.is_empty());

dynamo_async_openai::types::ChatChoice {
message: dynamo_async_openai::types::ChatCompletionResponseMessage {
role: delta.role.expect("delta should have a Role"),
Expand All @@ -325,6 +330,7 @@ impl From<DeltaChoice> for dynamo_async_openai::types::ChatChoice {
finish_reason,
stop_reason: delta.stop_reason,
logprobs: delta.logprobs,
has_reasoning: if has_reasoning { Some(true) } else { None },
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions lib/llm/src/protocols/openai/chat_completions/delta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,9 @@ impl DeltaGenerator {
finish_reason,
stop_reason,
logprobs,
// Note: reasoning_content is not available in the streaming delta path.
// has_reasoning is only set in the aggregated response path (aggregator.rs).
has_reasoning: None,
};

let choices = vec![choice];
Expand Down
2 changes: 2 additions & 0 deletions lib/llm/src/protocols/openai/chat_completions/jail.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ fn create_choice_stream(
finish_reason,
stop_reason,
logprobs,
has_reasoning: None,
}
}

Expand Down Expand Up @@ -598,6 +599,7 @@ impl JailedStream {
finish_reason: choice.finish_reason,
stop_reason: choice.stop_reason.clone(),
logprobs: choice.logprobs.clone(),
has_reasoning: choice.has_reasoning,
};
all_emissions.push(ChoiceEmission::PassThrough(pass_through_choice));
}
Expand Down
Loading