Skip to content

Commit c591718

Browse files
committed
Make every field of CompletionStreamDataTrunk optional
1 parent 7b61ab8 commit c591718

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

Tool/Sources/OpenAIService/ChatGPTService.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ extension ChatGPTService {
238238
cancelTask = cancel
239239
let proposedId = UUID().uuidString
240240
for try await trunk in trunks {
241-
guard let delta = trunk.choices.first?.delta else { continue }
241+
guard let delta = trunk.choices?.first?.delta else { continue }
242242

243243
// The api will always return a function call with JSON object.
244244
// The first round will contain the function name and an empty argument.

Tool/Sources/OpenAIService/CompletionStreamAPI.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,13 +130,13 @@ struct CompletionRequestBody: Encodable, Equatable {
130130

131131
struct CompletionStreamDataTrunk: Codable {
132132
var id: String?
133-
var object: String
134-
var model: String
135-
var choices: [Choice]
133+
var object: String?
134+
var model: String?
135+
var choices: [Choice]?
136136

137137
struct Choice: Codable {
138-
var delta: Delta
139-
var index: Int
138+
var delta: Delta?
139+
var index: Int?
140140
var finish_reason: String?
141141

142142
struct Delta: Codable {

0 commit comments

Comments
 (0)