From 590ea49c549df64d414ed5915c52e58cb015ba88 Mon Sep 17 00:00:00 2001 From: ActuallyTaylor Date: Thu, 18 Jan 2024 20:41:02 -0500 Subject: [PATCH] Returned data with failed model decoding Signed-off-by: ActuallyTaylor --- Sources/SLlama/Client.swift | 2 +- Sources/SLlama/ClientError.swift | 2 +- Tests/SLlamaTests/SLlamaTests.swift | 28 ++++++++++++++-------------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Sources/SLlama/Client.swift b/Sources/SLlama/Client.swift index 3008ba9..be30dd9 100644 --- a/Sources/SLlama/Client.swift +++ b/Sources/SLlama/Client.swift @@ -78,7 +78,7 @@ public struct Client { do { return try Model.decode(data: taskData) } catch { - throw SLlamaClientError.invalidModel(error: error) + throw SLlamaClientError.invalidModel(error: error, content: taskData) } } } diff --git a/Sources/SLlama/ClientError.swift b/Sources/SLlama/ClientError.swift index b632c64..e5ae5bb 100644 --- a/Sources/SLlama/ClientError.swift +++ b/Sources/SLlama/ClientError.swift @@ -10,6 +10,6 @@ import Foundation public enum SLlamaClientError: LocalizedError { case invalidBaseURL case invalidURLResponse - case invalidModel(error: Error) + case invalidModel(error: Error, content: Data) } diff --git a/Tests/SLlamaTests/SLlamaTests.swift b/Tests/SLlamaTests/SLlamaTests.swift index b269fc0..2ad7d81 100644 --- a/Tests/SLlamaTests/SLlamaTests.swift +++ b/Tests/SLlamaTests/SLlamaTests.swift @@ -75,17 +75,17 @@ final class SLlamaTests: XCTestCase { // } } -extension SLlamaTests: ClientStreamDelegate { - func didReceiveModel(model: Model) where Model : Codable { - guard let model = model as? CompletionResult else { return } - print(model.content, terminator: "") - } - - func didFinish(error: Error?) { - if let error { - print("Finished with error: \(error)") - } else { - print("Finished with no error") - } - } -} +//extension SLlamaTests: ClientStreamDelegate { +// func didReceiveModel(model: Model) where Model : Codable { +// guard let model = model as? CompletionResult else { return } +// print(model.content, terminator: "") +// } +// +// func didFinish(error: Error?) { +// if let error { +// print("Finished with error: \(error)") +// } else { +// print("Finished with no error") +// } +// } +//}