Skip to content

Commit

Permalink
chore: allows an environmental override of the default AWS region and… (
Browse files Browse the repository at this point in the history
#1025)

* chore: allows an environmental override of the default AWS region and using it for bedrock

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

* chore: missing provider region

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

---------

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
  • Loading branch information
AlexsJones committed Mar 22, 2024
1 parent 3c1c055 commit 8f8f5c6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cmd/auth/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ var addCmd = &cobra.Command{
_ = cmd.MarkFlagRequired("endpointname")
_ = cmd.MarkFlagRequired("providerRegion")
}
if strings.ToLower(backend) == "amazonbedrock" {
_ = cmd.MarkFlagRequired("providerRegion")
}
},
Run: func(cmd *cobra.Command, args []string) {

Expand Down
4 changes: 4 additions & 0 deletions pkg/ai/amazonbedrock.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"encoding/json"
"fmt"
"os"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
Expand Down Expand Up @@ -76,6 +77,9 @@ func GetModelOrDefault(model string) string {
// GetModelOrDefault check config region
func GetRegionOrDefault(region string) string {

if os.Getenv("AWS_DEFAULT_REGION") != "" {
region = os.Getenv("AWS_DEFAULT_REGION")
}
// Check if the provided model is in the list
for _, m := range BEDROCKER_SUPPORTED_REGION {
if m == region {
Expand Down

0 comments on commit 8f8f5c6

Please sign in to comment.