Background story
Hello, AWS team. 👋🏻
Currently, the Go SDK v2 gov2/bedrock-runtime only includes a converse api example for claude. Adding the Amazon Nova example will bring Go into parity with the other SDKs and make it much easier for devs to start building with Amazon Nova.
What does this example accomplish?
I would like to provide a PR demonstrating amazon.nova-lite-v1:0 via Bedrock's converse API using the Go v2 SDK, and return the model's text response. The update includes the core action method, unit tests, scenario integration, and metadata.
Which AWS service(s)?
AWS bedrock runtime - Converse API.
Which AWS SDKs or tools?
Are there existing code examples to leverage?
sources and samples:
Do you have any reference code?
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
}
Background story
Hello, AWS team. 👋🏻
Currently, the Go SDK v2
gov2/bedrock-runtimeonly includes a converse api example for claude. Adding the Amazon Nova example will bring Go into parity with the other SDKs and make it much easier for devs to start building with Amazon Nova.What does this example accomplish?
I would like to provide a PR demonstrating
amazon.nova-lite-v1:0via Bedrock's converse API using the Go v2 SDK, and return the model's text response. The update includes the core action method, unit tests, scenario integration, and metadata.Which AWS service(s)?
AWS bedrock runtime - Converse API.
Which AWS SDKs or tools?
Are there existing code examples to leverage?
sources and samples:
https://docs.aws.amazon.com/code-library/latest/ug/bedrock-runtime_example_bedrock-runtime_Converse_AnthropicClaude_section.html
gov2/bedrock-runtime/actions/converse.go
bedrock-runtime_Converse_AmazonNovaText
Do you have any reference code?
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 }