Skip to content

Commit f2007f7

Browse files
authored
CompletionTokensDetails can be nil (should be optional) (#20)
* Update ChatCompletionChunk.swift * Update ChatCompletionChunk.swift * Update ChatCompletion.swift
1 parent 3ffffb4 commit f2007f7

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

Sources/LLMChatOpenAI/ChatCompletion.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,14 +162,14 @@ public struct ChatCompletion: Decodable, Sendable {
162162

163163
public struct CompletionTokensDetails: Decodable, Sendable {
164164
/// When using Predicted Outputs, the number of tokens in the prediction that appeared in the completion.
165-
public let acceptedPredictionTokens: Int
165+
public let acceptedPredictionTokens: Int?
166166

167167
/// When using Predicted Outputs, the number of tokens in the prediction that did not appear in the completion.
168168
/// However, like reasoning tokens, these tokens are still counted in the total completion tokens for purposes of billing, output, and context window limits.
169-
public let rejectedPredictionTokens: Int
169+
public let rejectedPredictionTokens: Int?
170170

171171
/// Tokens generated by the model for reasoning.
172-
public let reasoningTokens: Int
172+
public let reasoningTokens: Int?
173173

174174
private enum CodingKeys: String, CodingKey {
175175
case acceptedPredictionTokens = "accepted_prediction_tokens"

Sources/LLMChatOpenAI/ChatCompletionChunk.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,14 +154,14 @@ public struct ChatCompletionChunk: Decodable, Sendable {
154154

155155
public struct CompletionTokensDetails: Decodable, Sendable {
156156
/// When using Predicted Outputs, the number of tokens in the prediction that appeared in the completion.
157-
public let acceptedPredictionTokens: Int
157+
public let acceptedPredictionTokens: Int?
158158

159159
/// When using Predicted Outputs, the number of tokens in the prediction that did not appear in the completion.
160160
/// However, like reasoning tokens, these tokens are still counted in the total completion tokens for purposes of billing, output, and context window limits.
161-
public let rejectedPredictionTokens: Int
161+
public let rejectedPredictionTokens: Int?
162162

163163
/// Tokens generated by the model for reasoning.
164-
public let reasoningTokens: Int
164+
public let reasoningTokens: Int?
165165

166166
private enum CodingKeys: String, CodingKey {
167167
case acceptedPredictionTokens = "accepted_prediction_tokens"

0 commit comments

Comments
 (0)