Replies: 5 comments 1 reply
-
Hi @pzierahn , This might be due a deserialization issue. We easily rule that out by inspecting the raw response data via enabling the response logs: cfg, err := config.LoadDefaultConfig(context.TODO(), config.WithRegion("us-east-1"), config.WithClientLogMode(aws.LogResponseWithBody))
if err != nil {
log.Fatalf("unable to load SDK config, %v", err)
} Can you share the output from the logger? Thanks, |
Beta Was this translation helpful? Give feedback.
-
Hi @RanVaknin, thanks for the quick response! Here is my log output: 2024/02/12 23:17:01 main.go:30: Using AWS region: us-east-1
SDK 2024/02/12 23:17:03 DEBUG Response
HTTP/2.0 200 OK
Content-Length: 102
Content-Type: application/json
Date: Mon, 12 Feb 2024 22:17:03 GMT
X-Amzn-Bedrock-Input-Token-Count: 16
X-Amzn-Bedrock-Invocation-Latency: 1717
X-Amzn-Bedrock-Output-Token-Count: 13
X-Amzn-Requestid: 240529a6-3c4c-4c75-8a1b-9e22445f5248
{"completion":" I'm doing well, thanks for asking!","stop_reason":"stop_sequence","stop":"\n\nHuman:"}
2024/02/12 23:17:03 main.go:68: result.ResultMetadata: {map[{}:-707132000 {}:0x1400011a238 {}:240529a6-3c4c-4c75-8a1b-9e22445f5248 {}:{13937167603843070560 2130869501 0x104b59160} {}:{0 63843373023 <nil>} {}:{[{<nil> false false {map[{}:-707132000 {}:0x1400011a238 {}:240529a6-3c4c-4c75-8a1b-9e22445f5248 {}:{13937167603843070560 2130869501 0x104b59160} {}:{0 63843373023 <nil>}]}}]}]} |
Beta Was this translation helpful? Give feedback.
-
The value keys within See: |
Beta Was this translation helpful? Give feedback.
-
Thanks @lucix-aws for the additional context. if you really need something from the metadata that is not exported, you can use a middleware: deserializeMiddleware := middleware.DeserializeMiddlewareFunc("myDeserializeMiddleware",
func(ctx context.Context, input middleware.DeserializeInput, next middleware.DeserializeHandler) (middleware.DeserializeOutput, middleware.Metadata, error) {
output, metadata, err := next.HandleDeserialize(ctx, input)
if resp, ok := output.RawResponse.(*smithyhttp.Response); ok {
fmt.Println(resp.Header) // print or do something else with the headers.
}
return output, metadata, err
})
client := bedrockruntime.NewFromConfig(sdkConfig, func(options *bedrockruntime.Options) {
options.APIOptions = append(options.APIOptions, func(stack *middleware.Stack) error {
return stack.Deserialize.Insert(deserializeMiddleware, "OperationDeserializer", middleware.After)
})
}) Let us know if you need anything else. |
Beta Was this translation helpful? Give feedback.
-
To clarify, a field indexed via an unexported map key (as in, the key's value or type is not exported within its go package) that did not expose a getter API anywhere would be well and truly unretrievable, since that key could not functionally be used by a consumer in a The example above is somewhat unrelated to that distinction, it shows how to inspect the raw transport response from the service via a handwritten middleware, which on a related note isn't actually necessary - there's a GetRawResponse metadata API available in the core module. |
Beta Was this translation helpful? Give feedback.
-
Describe the bug
While working with the AWS SDK Go v2 -
bedrockruntime.InvokeModel()
function, I encountered an issue where theResultMetadata
in the returned results is inaccessible. The map keys always appear as{}
and there is no capacity to iterate over the underlying values map. Therefore, the Get, Set, and Has functions provided by themiddleware.Metadata
are rendered unusable. This is causing issues in handling and processing the result metadata properly.Expected Behavior
The
middleware.Metadata
contained within theResultMetadata
map should be easily accessible and retrievable, allowing appropriate operations on the map like Get, Set, and Check for presence (Has) of specific metadata.Current Behavior
Upon executing the
bedrockruntime.InvokeModel()
function, the following result shows that theResultMetadata
is returning a map with inaccessible keys, and I am unable to retrieve or operate on the stored metadata in a meaningful way.Log Output of
ResultMetadata
:Reproduction Steps
bedrockruntime.InvokeModel()
function with required input parameters.result.ResultMetadata
to observe the inaccessible keys in the map.Source Code Snippet:
Possible Solution
No response
Additional Information/Context
No response
AWS Go SDK V2 Module Versions Used
Compiler and Version used
go version go1.21.7 darwin/arm64
Operating System and version
macOS Sonoma Version 14.3.1
Beta Was this translation helpful? Give feedback.
All reactions