diff --git a/CHANGELOG.md b/CHANGELOG.md index ab2a2ee..f5cf5df 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/internal/server/web/proxy/bedrock.go b/internal/server/web/proxy/bedrock.go index 37d9669..83ff891 100644 --- a/internal/server/web/proxy/bedrock.go +++ b/internal/server/web/proxy/bedrock.go @@ -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) @@ -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) @@ -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, }) @@ -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 }