1515
1616@preconcurrency import AWSBedrockRuntime
1717import Foundation
18+ import Logging
1819
1920public struct InvokeModelResponse {
2021 let model : BedrockModel
@@ -50,9 +51,10 @@ public struct InvokeModelResponse {
5051 /// - model: The Bedrock model that generated the response
5152 /// - Throws: BedrockLibraryError.invalidModel if the model is not supported
5253 /// BedrockLibraryError.invalidResponseBody if the response cannot be decoded
53- static func createTextResponse( body data: Data , model: BedrockModel ) throws -> Self {
54+ static func createTextResponse( body data: Data , model: BedrockModel , logger : Logger ) throws -> Self {
5455 do {
5556 let textModality = try model. getTextModality ( )
57+ logger. trace ( " Raw response data: \n \( String ( data: data, encoding: . utf8) ?? " " ) \n " )
5658 return self . init ( model: model, textCompletionBody: try textModality. getTextResponseBody ( from: data) )
5759 } catch {
5860 throw BedrockLibraryError . invalidSDKResponseBody ( data)
@@ -65,9 +67,10 @@ public struct InvokeModelResponse {
6567 /// - model: The Bedrock model that generated the response
6668 /// - Throws: BedrockLibraryError.invalidModel if the model is not supported
6769 /// BedrockLibraryError.invalidResponseBody if the response cannot be decoded
68- static func createImageResponse( body data: Data , model: BedrockModel ) throws -> Self {
70+ static func createImageResponse( body data: Data , model: BedrockModel , logger : Logger ) throws -> Self {
6971 do {
7072 let imageModality = try model. getImageModality ( )
73+ logger. trace ( " Raw response " , metadata: [ " Data " : " \( String ( data: data, encoding: . utf8) ?? " " ) " ] )
7174 return self . init ( model: model, imageGenerationBody: try imageModality. getImageResponseBody ( from: data) )
7275 } catch {
7376 throw BedrockLibraryError . invalidSDKResponseBody ( data)
0 commit comments