@@ -35,6 +35,7 @@ class ChatGPTServiceTests: XCTestCase {
3535 . partialText( " " ) ,
3636 . partialText( " world " ) ,
3737 . partialText( " ! " ) ,
38+ . usage( promptTokens: 0 , completionTokens: 0 , cachedTokens: 0 , otherUsage: [ : ] ) ,
3839 ] )
3940
4041 let history = await memory. history
@@ -86,6 +87,7 @@ class ChatGPTServiceTests: XCTestCase {
8687
8788 let response = try await stream. asArray ( )
8889 XCTAssertEqual ( response, [
90+ . usage( promptTokens: 0 , completionTokens: 0 , cachedTokens: 0 , otherUsage: [ : ] ) ,
8991 . toolCalls( [
9092 . init(
9193 id: " 1 " ,
@@ -179,6 +181,7 @@ class ChatGPTServiceTests: XCTestCase {
179181 . status( [ " start bar 1 " , " start foo 3 " ] ) ,
180182 . status( [ " start bar 2 " , " start foo 3 " ] ) ,
181183 . status( [ " start bar 3 " , " start foo 3 " ] ) ,
184+ . usage( promptTokens: 0 , completionTokens: 0 , cachedTokens: 0 , otherUsage: [ : ] ) ,
182185 . status( [ " foo hi " ] ) ,
183186 . status( [ ] ) ,
184187 . status( [ " bar bye " ] ) ,
@@ -187,6 +190,7 @@ class ChatGPTServiceTests: XCTestCase {
187190 . partialText( " " ) ,
188191 . partialText( " world " ) ,
189192 . partialText( " ! " ) ,
193+ . usage( promptTokens: 0 , completionTokens: 0 , cachedTokens: 0 , otherUsage: [ : ] ) ,
190194 ] )
191195
192196 let history = await memory. history
@@ -272,10 +276,12 @@ class ChatGPTServiceTests: XCTestCase {
272276
273277 let response = try await stream. asArray ( )
274278 XCTAssertEqual ( response, [
279+ . usage( promptTokens: 0 , completionTokens: 0 , cachedTokens: 0 , otherUsage: [ : ] ) ,
275280 . partialText( " hello " ) ,
276281 . partialText( " " ) ,
277282 . partialText( " world " ) ,
278283 . partialText( " ! " ) ,
284+ . usage( promptTokens: 0 , completionTokens: 0 , cachedTokens: 0 , otherUsage: [ : ] ) ,
279285 ] )
280286
281287 let history = await memory. history
@@ -306,15 +312,15 @@ class ChatGPTServiceTests: XCTestCase {
306312 ) ,
307313 ] )
308314 }
309-
315+
310316 func test_send_memory_and_handles_error( ) async throws {
311317 struct E : Error , LocalizedError {
312318 var errorDescription : String ? { " error happens " }
313319 }
314320 let api = ChunksChatCompletionsStreamAPI ( chunks: [
315321 . token( " hello " ) ,
316322 . token( " " ) ,
317- . failure( E ( ) )
323+ . failure( E ( ) ) ,
318324 ] )
319325 let builder = APIBuilder ( api: api)
320326 let memory = EmptyChatGPTMemory ( )
@@ -357,12 +363,12 @@ class ChatGPTServiceTests: XCTestCase {
357363 ) ,
358364 ] )
359365 }
360-
366+
361367 func test_send_memory_and_handles_cancellation( ) async throws {
362368 let api = ChunksChatCompletionsStreamAPI ( chunks: [
363369 . token( " hello " ) ,
364370 . token( " " ) ,
365- . failure( CancellationError ( ) )
371+ . failure( CancellationError ( ) ) ,
366372 ] )
367373 let builder = APIBuilder ( api: api)
368374 let memory = EmptyChatGPTMemory ( )
@@ -517,6 +523,7 @@ private struct FunctionProvider: ChatGPTFunctionProvider {
517523 }
518524
519525 struct Result : ChatGPTFunctionResult {
526+ var userReadableContent : ChatBasic . ChatGPTFunctionResultUserReadableContent = . text( " " )
520527 var result : String
521528 var botReadableContent : String { result }
522529 }
@@ -548,6 +555,8 @@ private struct FunctionProvider: ChatGPTFunctionProvider {
548555 }
549556
550557 struct Result : ChatGPTFunctionResult {
558+ var userReadableContent : ChatBasic . ChatGPTFunctionResultUserReadableContent = . text( " " )
559+
551560 var result : String
552561 var botReadableContent : String { result }
553562 }
0 commit comments