Skip to content

Commit

Permalink
Returned data with failed model decoding
Browse files Browse the repository at this point in the history
Signed-off-by: ActuallyTaylor <[email protected]>
  • Loading branch information
ActuallyTaylor committed Jan 19, 2024
1 parent 835b817 commit 590ea49
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Sources/SLlama/Client.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
2 changes: 1 addition & 1 deletion Sources/SLlama/ClientError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ import Foundation
public enum SLlamaClientError: LocalizedError {
case invalidBaseURL
case invalidURLResponse
case invalidModel(error: Error)
case invalidModel(error: Error, content: Data)
}

28 changes: 14 additions & 14 deletions Tests/SLlamaTests/SLlamaTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,17 +75,17 @@ final class SLlamaTests: XCTestCase {
// }
}

extension SLlamaTests: ClientStreamDelegate {
func didReceiveModel<Model>(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: 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")
// }
// }
//}

0 comments on commit 590ea49

Please sign in to comment.