Skip to content

Commit

Permalink
fixed compatibility issues
Browse files Browse the repository at this point in the history
  • Loading branch information
spikelu2016 committed Sep 13, 2024
1 parent 8682f5e commit 0750ef8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.36.2 - 2024-09-13
### Fixed
- Fixed compatibility issues between Anthropic SDK and AWS Bedrock

## 1.36.1 - 2024-09-10
### Fixed
- Fixed provider selection issue when a key is associated with multiple providers
Expand Down
10 changes: 9 additions & 1 deletion internal/server/web/proxy/bedrock.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ import (
"go.uber.org/zap/zapcore"
)

func setAnthropicVersionIfExists(version string, req *anthropic.BedrockMessageRequest) {
if req != nil && len(version) > 0 {
req.AnthropicVersion = version
}
}

func getBedrockCompletionHandler(prod bool, e anthropicEstimator, timeOut time.Duration) gin.HandlerFunc {
return func(c *gin.Context) {
log := util.GetLogFromCtx(c)
Expand Down Expand Up @@ -309,6 +315,8 @@ func getBedrockMessagesHandler(prod bool, e anthropicEstimator, timeOut time.Dur
return
}

setAnthropicVersionIfExists(c.GetHeader("anthropic-version"), req)

bs, err := json.Marshal(req)
if err != nil {
telemetry.Incr("bricksllm.proxy.get_bedrock_messages_handler.marshal_error", nil, 1)
Expand Down Expand Up @@ -410,6 +418,7 @@ func getBedrockMessagesHandler(prod bool, e anthropicEstimator, timeOut time.Dur
streamOutput, err := client.InvokeModelWithResponseStream(ctx, &bedrockruntime.InvokeModelWithResponseStreamInput{
ModelId: &anthropicReq.Model,
ContentType: aws.String("application/json"),
Accept: aws.String("application/json"),
Body: bs,
})

Expand Down Expand Up @@ -500,7 +509,6 @@ func getBedrockMessagesHandler(prod bool, e anthropicEstimator, timeOut time.Dur
return false
}
default:

telemetry.Timing("bricksllm.proxy.get_bedrock_messages_handler.streaming_latency", time.Since(start), nil, 1)
return false
}
Expand Down

0 comments on commit 0750ef8

Please sign in to comment.