Skip to content

Commit c0e8aa0

Browse files
committed
Handle errors from azure openai
1 parent 4f1a60b commit c0e8aa0

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

Tool/Sources/OpenAIService/ChatGPTService.swift

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,16 @@ public struct ChatGPTError: Error, Codable, LocalizedError {
4141

4242
public struct ErrorContent: Codable {
4343
public var message: String
44-
public var type: String
44+
public var type: String?
4545
public var param: String?
4646
public var code: String?
4747

48-
public init(message: String, type: String, param: String? = nil, code: String? = nil) {
48+
public init(
49+
message: String,
50+
type: String? = nil,
51+
param: String? = nil,
52+
code: String? = nil
53+
) {
4954
self.message = message
5055
self.type = type
5156
self.param = param
@@ -80,7 +85,7 @@ public class ChatGPTService: ChatGPTServiceType {
8085
self.configuration = configuration
8186
self.functionProvider = functionProvider
8287
}
83-
88+
8489
@Dependency(\.uuid) var uuid
8590
@Dependency(\.date) var date
8691

@@ -279,7 +284,7 @@ extension ChatGPTService {
279284
#if DEBUG
280285
Debugger.didSendRequestBody(body: requestBody)
281286
#endif
282-
287+
283288
let proposedId = uuid().uuidString + String(date().timeIntervalSince1970)
284289

285290
return AsyncThrowingStream<StreamContent, Error> { continuation in

0 commit comments

Comments
 (0)