Skip to content

[Enhancement]: Add Amazon Nova Converse API example for Go SDK v2 (bedrock-runtime) #7812

@haidargit

Description

@haidargit

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?

  • All languages
  • .NET
  • C++
  • Go (v2)
  • Java
  • Java (v2)
  • JavaScript
  • JavaScript (v3)
  • Kotlin
  • PHP
  • Python
  • Ruby
  • Rust
  • Swift
  • Not applicable

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  
}

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions