AWS code-library documentation change
Summary
Added Go SDK V2 code example for sending messages to Amazon Nova using Bedrock's Converse API
Security assessment
The change adds a routine code example for using a new model (Amazon Nova) with Bedrock's Converse API. There is no evidence of security vulnerability fixes, security configurations, or security-related documentation. The code focuses on basic API usage without security-specific handling.
Diff
diff --git a/code-library/latest/ug/bedrock-runtime_example_bedrock-runtime_Converse_AmazonNovaText_section.md b/code-library/latest/ug/bedrock-runtime_example_bedrock-runtime_Converse_AmazonNovaText_section.md index e2a92e448..1a9bdd27b 100644 --- a//code-library/latest/ug/bedrock-runtime_example_bedrock-runtime_Converse_AmazonNovaText_section.md +++ b//code-library/latest/ug/bedrock-runtime_example_bedrock-runtime_Converse_AmazonNovaText_section.md @@ -161,0 +162,45 @@ Send a conversation of messages to Amazon Nova using Bedrock's Converse API with +Go + + +**SDK for Go V2** + + +###### Note + +There's more on GitHub. Find the complete example and learn how to set up and run in the [AWS Code Examples Repository](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/gov2/bedrock-runtime#code-examples). + +Send a text message to Amazon Nova, using Bedrock's Converse API. + + + func (wrapper ConverseWrapper) ConverseNova(ctx context.Context, prompt string) (string, error) { + var content = types.ContentBlockMemberText{ + Value: prompt, + } + var message = types.Message{ + Content: []types.ContentBlock{&content}, + Role: "user", + } + modelId := "amazon.nova-lite-v1:0" + var converseInput = bedrockruntime.ConverseInput{ + ModelId: aws.String(modelId), + Messages: []types.Message{message}, + } + response, err := wrapper.BedrockRuntimeClient.Converse(ctx, &converseInput) + if err != nil { + ProcessError(err, modelId) + } + + responseText, _ := response.Output.(*types.ConverseOutputMemberMessage) + responseContentBlock := responseText.Value.Content[0] + text, _ := responseContentBlock.(*types.ContentBlockMemberText) + return text.Value, nil + } + + + + + * For API details, see [Converse](https://pkg.go.dev/github.com/aws/aws-sdk-go-v2/service/bedrockruntime#Client.Converse) in _AWS SDK for Go API Reference_. + + + +