Skip to content

Commit

Permalink
disable AWS Bedrock support temporarily (#479)
Browse files Browse the repository at this point in the history
  • Loading branch information
jairad26 authored Oct 18, 2024
1 parent 4e7af97 commit 468a15b
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 33 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ In previous releases, the name "Hypermode" was used for all three._
- Enable GraphQL endpoints to be defined in the manifest [#464](https://github.com/hypermodeinc/modus/pull/464)
- Publish SDKs and templates via release workflows [#465](https://github.com/hypermodeinc/modus/pull/465)
- Fix AssemblyScript build failure when no Git repo is present [#475](https://github.com/hypermodeinc/modus/pull/475)
- Disable AWS Bedrock support temporarily [#479](https://github.com/hypermodeinc/modus/pull/479)

## 2024-10-02 - Version 0.12.7

Expand Down
60 changes: 30 additions & 30 deletions runtime/models/bedrock.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,44 +9,44 @@

package models

import (
"context"
"fmt"
// import (
// "context"
// "fmt"

"github.com/hypermodeinc/modus/lib/manifest"
hyp_aws "github.com/hypermodeinc/modus/runtime/aws"
"github.com/hypermodeinc/modus/runtime/db"
"github.com/hypermodeinc/modus/runtime/utils"
// "github.com/hypermodeinc/modus/lib/manifest"
// hyp_aws "github.com/hypermodeinc/modus/runtime/aws"
// "github.com/hypermodeinc/modus/runtime/db"
// "github.com/hypermodeinc/modus/runtime/utils"

"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/service/bedrockruntime"
)
// "github.com/aws/aws-sdk-go-v2/aws"
// "github.com/aws/aws-sdk-go-v2/service/bedrockruntime"
// )

func invokeAwsBedrockModel(ctx context.Context, model *manifest.ModelInfo, input string) (output string, err error) {
// func invokeAwsBedrockModel(ctx context.Context, model *manifest.ModelInfo, input string) (output string, err error) {

span, ctx := utils.NewSentrySpanForCurrentFunc(ctx)
defer span.Finish()
// span, ctx := utils.NewSentrySpanForCurrentFunc(ctx)
// defer span.Finish()

// NOTE: Bedrock support is experimental, and not advertised to users.
// It currently uses the same AWS credentials as the Runtime.
// In the future, we will support user-provided credentials for Bedrock.
// // NOTE: Bedrock support is experimental, and not advertised to users.
// // It currently uses the same AWS credentials as the Runtime.
// // In the future, we will support user-provided credentials for Bedrock.

cfg := hyp_aws.GetAwsConfig() // TODO, connect to AWS using the user-provided credentials
client := bedrockruntime.NewFromConfig(cfg)
// cfg := hyp_aws.GetAwsConfig() // TODO, connect to AWS using the user-provided credentials
// client := bedrockruntime.NewFromConfig(cfg)

modelId := fmt.Sprintf("%s.%s", model.Provider, model.SourceModel)
// modelId := fmt.Sprintf("%s.%s", model.Provider, model.SourceModel)

startTime := utils.GetTime()
result, err := client.InvokeModel(ctx, &bedrockruntime.InvokeModelInput{
ModelId: &modelId,
ContentType: aws.String("application/json"),
Body: []byte(input),
})
endTime := utils.GetTime()
// startTime := utils.GetTime()
// result, err := client.InvokeModel(ctx, &bedrockruntime.InvokeModelInput{
// ModelId: &modelId,
// ContentType: aws.String("application/json"),
// Body: []byte(input),
// })
// endTime := utils.GetTime()

output = string(result.Body)
// output = string(result.Body)

db.WriteInferenceHistory(ctx, model, input, output, startTime, endTime)
// db.WriteInferenceHistory(ctx, model, input, output, startTime, endTime)

return output, err
}
// return output, err
// }
7 changes: 4 additions & 3 deletions runtime/models/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,11 @@ func InvokeModel(ctx context.Context, modelName string, input string) (string, e
return "", err
}

// NOTE: Bedrock support is temporarily disabled
// TODO: use the provider pattern instead of branching
if model.Connection == "aws-bedrock" {
return invokeAwsBedrockModel(ctx, model, input)
}
// if model.Connection == "aws-bedrock" {
// return invokeAwsBedrockModel(ctx, model, input)
// }

return PostToModelEndpoint[string](ctx, model, input)
}
Expand Down

0 comments on commit 468a15b

Please sign in to comment.