Skip to content

Commit 8f863d4

Browse files
authored
Merge pull request #311 from FiveSheepCo/upstream/reasoning-deltas
Support `reasoning` in ChatStreamResult deltas
2 parents bb97662 + a9519b6 commit 8f863d4

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

Sources/OpenAI/Public/Models/ChatStreamResult.swift

+18-4
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,26 @@ public struct ChatStreamResult: Codable, Equatable, Sendable {
1818
public let content: String?
1919
/// If the audio output modality is requested, this object contains data about the audio response from the model.
2020
public let audio: ChoiceDeltaAudio?
21-
/// The reasoning content of the chunk message.
22-
/// Only some model are supported, like DeepSeek-R1.
23-
public let reasoningContent: String?
21+
2422
/// The role of the author of this message.
2523
public let role: Self.Role?
2624
public let toolCalls: [Self.ChoiceDeltaToolCall]?
2725

26+
/// Value for `reasoning` field in response.
27+
///
28+
/// Provided by:
29+
/// - Gemini (in OpenAI compatibility mode)
30+
/// https://github.com/MacPaw/OpenAI/issues/283#issuecomment-2711396735
31+
/// - OpenRouter
32+
public let reasoning: String?
33+
34+
/// Value for `reasoning_content` field.
35+
///
36+
/// Provided by:
37+
/// - Deepseek
38+
/// https://api-docs.deepseek.com/api/create-chat-completion#responses
39+
public let reasoningContent: String?
40+
2841
public struct ChoiceDeltaAudio: Codable, Equatable, Sendable {
2942

3043
/// Unique identifier for this audio response.
@@ -85,9 +98,10 @@ public struct ChatStreamResult: Codable, Equatable, Sendable {
8598
public enum CodingKeys: String, CodingKey {
8699
case content
87100
case audio
88-
case reasoningContent = "reasoning_content"
89101
case role
90102
case toolCalls = "tool_calls"
103+
case reasoning = "reasoning"
104+
case reasoningContent = "reasoning_content"
91105
}
92106
}
93107

0 commit comments

Comments
 (0)