Skip to content

Commit eec4881

Browse files
committed
Update
1 parent 4281a6a commit eec4881

File tree

2 files changed

+6
-18
lines changed

2 files changed

+6
-18
lines changed

Tool/Sources/OpenAIService/ChatGPTService.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,9 @@ public class ChatGPTService: ChatGPTServiceType {
146146
#endif
147147
}
148148

149+
#if DEBUG
149150
Debugger.didFinish()
151+
#endif
150152
continuation.finish()
151153
} catch {
152154
continuation.finish(throwing: error)
@@ -185,8 +187,10 @@ public class ChatGPTService: ChatGPTServiceType {
185187
functionCall = nextMessage.functionCall
186188
}
187189

190+
#if DEBUG
188191
Debugger.didReceiveResponse(content: finalResult ?? "N/A")
189192
Debugger.didFinish()
193+
#endif
190194

191195
return finalResult
192196
}

Tool/Sources/OpenAIService/Debug/Debug.swift

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,11 @@ import AppKit
22
import Foundation
33

44
enum Debugger {
5-
#if DEBUG
65
@TaskLocal
76
static var id: UUID?
8-
#endif
97

8+
#if DEBUG
109
static func didSendRequestBody(body: CompletionRequestBody) {
11-
#if DEBUG
12-
1310
do {
1411
let json = try JSONEncoder().encode(body)
1512
let center = NSWorkspace.shared.notificationCenter
@@ -24,13 +21,9 @@ enum Debugger {
2421
} catch {
2522
print("Failed to encode request body: \(error)")
2623
}
27-
28-
#endif
2924
}
3025

3126
static func didReceiveFunction(name: String, arguments: String) {
32-
#if DEBUG
33-
3427
let center = NSWorkspace.shared.notificationCenter
3528
center.post(
3629
name: .init("ServiceDebugger.ChatRequestDebug.receivedFunctionCall"),
@@ -41,13 +34,9 @@ enum Debugger {
4134
"arguments": arguments,
4235
]
4336
)
44-
45-
#endif
4637
}
4738

4839
static func didReceiveFunctionResult(result: String) {
49-
#if DEBUG
50-
5140
let center = NSWorkspace.shared.notificationCenter
5241
center.post(
5342
name: .init("ServiceDebugger.ChatRequestDebug.receivedFunctionResult"),
@@ -57,13 +46,9 @@ enum Debugger {
5746
"result": result,
5847
]
5948
)
60-
61-
#endif
6249
}
6350

6451
static func didReceiveResponse(content: String) {
65-
#if DEBUG
66-
6752
let center = NSWorkspace.shared.notificationCenter
6853
center.post(
6954
name: .init("ServiceDebugger.ChatRequestDebug.responseReceived"),
@@ -73,8 +58,6 @@ enum Debugger {
7358
"response": content,
7459
]
7560
)
76-
77-
#endif
7861
}
7962

8063
static func didFinish() {
@@ -87,5 +70,6 @@ enum Debugger {
8770
]
8871
)
8972
}
73+
#endif
9074
}
9175

0 commit comments

Comments
 (0)