-
Notifications
You must be signed in to change notification settings - Fork 53
feat(payload-processing): add AWS Bedrock OpenAI chat completions sup… #601
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,106 @@ | ||||||||||
| /* | ||||||||||
| Copyright 2026 The opendatahub.io Authors. | ||||||||||
|
|
||||||||||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||||||||||
| you may not use this file except in compliance with the License. | ||||||||||
| You may obtain a copy of the License at | ||||||||||
|
|
||||||||||
| http://www.apache.org/licenses/LICENSE-2.0 | ||||||||||
|
|
||||||||||
| Unless required by applicable law or agreed to in writing, software | ||||||||||
| distributed under the License is distributed on an "AS IS" BASIS, | ||||||||||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||||||||||
| See the License for the specific language governing permissions and | ||||||||||
| limitations under the License. | ||||||||||
| */ | ||||||||||
|
|
||||||||||
| package awsbedrock | ||||||||||
|
|
||||||||||
| import ( | ||||||||||
| "fmt" | ||||||||||
| "os" | ||||||||||
| ) | ||||||||||
|
|
||||||||||
| const ( | ||||||||||
| // AWS environment variables | ||||||||||
| awsRegionEnv = "AWS_REGION" | ||||||||||
| awsDefaultRegion = "us-east-1" | ||||||||||
|
|
||||||||||
| // Bedrock OpenAI-compatible endpoint path | ||||||||||
| bedrockOpenAIPath = "/v1/chat/completions" | ||||||||||
| ) | ||||||||||
|
|
||||||||||
| // BedrockTranslator translates OpenAI Chat Completions to AWS Bedrock's OpenAI-compatible API | ||||||||||
| // This is a simple path rewriter since Bedrock's OpenAI-compatible endpoint uses the same format | ||||||||||
| type BedrockTranslator struct { | ||||||||||
| region string | ||||||||||
| } | ||||||||||
|
|
||||||||||
| // NewBedrockTranslator creates a new AWS Bedrock translator instance | ||||||||||
| func NewBedrockTranslator() *BedrockTranslator { | ||||||||||
| region := os.Getenv(awsRegionEnv) | ||||||||||
| if region == "" { | ||||||||||
| region = awsDefaultRegion | ||||||||||
| } | ||||||||||
|
|
||||||||||
| return &BedrockTranslator{ | ||||||||||
| region: region, | ||||||||||
| } | ||||||||||
| } | ||||||||||
|
|
||||||||||
| // NewBedrockTranslatorWithRegion creates a translator with explicit region | ||||||||||
| func NewBedrockTranslatorWithRegion(region string) *BedrockTranslator { | ||||||||||
| if region == "" { | ||||||||||
| region = awsDefaultRegion | ||||||||||
| } | ||||||||||
|
|
||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is not needed. called should set the region. and in the translator we assume it was set properly. |
||||||||||
| return &BedrockTranslator{ | ||||||||||
| region: region, | ||||||||||
| } | ||||||||||
| } | ||||||||||
|
|
||||||||||
| // TranslateRequest translates an OpenAI request to AWS Bedrock Converse API format | ||||||||||
| // Returns the translated body, headers to set, headers to remove, and any error | ||||||||||
| // TranslateRequest rewrites the path to target Bedrock's OpenAI-compatible endpoint. | ||||||||||
| // The request body is not mutated since Bedrock's OpenAI-compatible API accepts the same schema as OpenAI. | ||||||||||
| func (t *BedrockTranslator) TranslateRequest(body map[string]any) ( | ||||||||||
| translatedBody map[string]any, | ||||||||||
| headersToMutate map[string]string, | ||||||||||
| headersToRemove []string, | ||||||||||
| err error, | ||||||||||
| ) { | ||||||||||
| // Validate required fields | ||||||||||
| model, ok := body["model"].(string) | ||||||||||
| if !ok || model == "" { | ||||||||||
| return nil, nil, nil, fmt.Errorf("model field is required") | ||||||||||
| } | ||||||||||
|
|
||||||||||
| // Validate this is a Chat Completions request | ||||||||||
| if _, hasMessages := body["messages"]; !hasMessages { | ||||||||||
| return nil, nil, nil, fmt.Errorf("only Chat Completions API is supported - 'messages' field required") | ||||||||||
| } | ||||||||||
|
Comment on lines
+78
to
+81
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no need - basic assumptions it only OpenAI chat completions for now.
Suggested change
|
||||||||||
|
|
||||||||||
| // Build headers for Bedrock OpenAI-compatible endpoint | ||||||||||
| headersToMutate = map[string]string{ | ||||||||||
| ":path": bedrockOpenAIPath, | ||||||||||
| "content-type": "application/json", | ||||||||||
| "host": fmt.Sprintf("bedrock-runtime.%s.amazonaws.com", t.region), | ||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we are not supposed to set host here. we should also remove the env var + default region vars. |
||||||||||
| } | ||||||||||
|
|
||||||||||
| // Return nil body — no body mutation needed, Bedrock accepts OpenAI request format as-is | ||||||||||
| return nil, headersToMutate, nil, nil | ||||||||||
| } | ||||||||||
|
|
||||||||||
| // TranslateResponse is a no-op since Bedrock's OpenAI-compatible API returns responses in OpenAI format | ||||||||||
| func (t *BedrockTranslator) TranslateResponse(body map[string]any, model string) ( | ||||||||||
| translatedBody map[string]any, | ||||||||||
| err error, | ||||||||||
| ) { | ||||||||||
| // No translation needed - Bedrock's OpenAI-compatible endpoint returns OpenAI format | ||||||||||
| return nil, nil | ||||||||||
| } | ||||||||||
|
|
||||||||||
| // GetRegion returns the AWS region configured for this translator | ||||||||||
| func (t *BedrockTranslator) GetRegion() string { | ||||||||||
| return t.region | ||||||||||
| } | ||||||||||
|
Comment on lines
+103
to
+106
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no need to get region. |
||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,227 @@ | ||||||||||||||||||||||||||||||||
| /* | ||||||||||||||||||||||||||||||||
| Copyright 2026 The opendatahub.io Authors. | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||||||||||||||||||||||||||||||||
| you may not use this file except in compliance with the License. | ||||||||||||||||||||||||||||||||
| You may obtain a copy of the License at | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| http://www.apache.org/licenses/LICENSE-2.0 | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| Unless required by applicable law or agreed to in writing, software | ||||||||||||||||||||||||||||||||
| distributed under the License is distributed on an "AS IS" BASIS, | ||||||||||||||||||||||||||||||||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||||||||||||||||||||||||||||||||
| See the License for the specific language governing permissions and | ||||||||||||||||||||||||||||||||
| limitations under the License. | ||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| package awsbedrock | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| import ( | ||||||||||||||||||||||||||||||||
| "testing" | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| "github.com/stretchr/testify/assert" | ||||||||||||||||||||||||||||||||
| "github.com/stretchr/testify/require" | ||||||||||||||||||||||||||||||||
| "github.com/opendatahub-io/ai-gateway-payload-processing/pkg/plugins/common/provider" | ||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| func createTestTranslator() *BedrockTranslator { | ||||||||||||||||||||||||||||||||
| return NewBedrockTranslator() | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
Comment on lines
+27
to
+29
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: can we remove this function? |
||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| func TestTranslateRequest_BasicChat(t *testing.T) { | ||||||||||||||||||||||||||||||||
| body := map[string]any{ | ||||||||||||||||||||||||||||||||
| "model": "nvidia.nemotron-nano-12b-v2", | ||||||||||||||||||||||||||||||||
| "messages": []any{ | ||||||||||||||||||||||||||||||||
| map[string]any{"role": "user", "content": "What is 2+2?"}, | ||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| translatedBody, headers, headersToRemove, err := createTestTranslator().TranslateRequest(body) | ||||||||||||||||||||||||||||||||
| require.NoError(t, err) | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| assert.Nil(t, translatedBody, "body should not be mutated for Bedrock OpenAI-compatible API") | ||||||||||||||||||||||||||||||||
| assert.Equal(t, "/v1/chat/completions", headers[":path"]) | ||||||||||||||||||||||||||||||||
| assert.Equal(t, "application/json", headers["content-type"]) | ||||||||||||||||||||||||||||||||
| assert.Equal(t, "bedrock-runtime.us-east-1.amazonaws.com", headers["host"]) | ||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. pls remove:
Suggested change
|
||||||||||||||||||||||||||||||||
| assert.Empty(t, headersToRemove) | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| func TestTranslateRequest_WithRegion(t *testing.T) { | ||||||||||||||||||||||||||||||||
| translator := NewBedrockTranslatorWithRegion("us-west-2") | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| body := map[string]any{ | ||||||||||||||||||||||||||||||||
| "model": "nvidia.nemotron-nano-12b-v2", | ||||||||||||||||||||||||||||||||
| "messages": []any{ | ||||||||||||||||||||||||||||||||
| map[string]any{"role": "user", "content": "Hello"}, | ||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| _, headers, _, err := translator.TranslateRequest(body) | ||||||||||||||||||||||||||||||||
| require.NoError(t, err) | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| assert.Equal(t, "bedrock-runtime.us-west-2.amazonaws.com", headers["host"]) | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
Comment on lines
+49
to
+63
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no need to add host.
Suggested change
|
||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| func TestTranslateRequest_PassthroughAllChatParams(t *testing.T) { | ||||||||||||||||||||||||||||||||
| body := map[string]any{ | ||||||||||||||||||||||||||||||||
| "model": "nvidia.nemotron-nano-12b-v2", | ||||||||||||||||||||||||||||||||
| "messages": []any{ | ||||||||||||||||||||||||||||||||
| map[string]any{"role": "system", "content": "You are helpful."}, | ||||||||||||||||||||||||||||||||
| map[string]any{"role": "user", "content": "Hello"}, | ||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||
| "temperature": 0.7, | ||||||||||||||||||||||||||||||||
| "top_p": 0.9, | ||||||||||||||||||||||||||||||||
| "max_tokens": 1000, | ||||||||||||||||||||||||||||||||
| "stream": true, | ||||||||||||||||||||||||||||||||
| "stop": []any{"END"}, | ||||||||||||||||||||||||||||||||
| "n": 1, | ||||||||||||||||||||||||||||||||
| "presence_penalty": 0.5, | ||||||||||||||||||||||||||||||||
| "frequency_penalty": 0.3, | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
Comment on lines
+66
to
+80
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you just move these fields to the first test and remove duplicated test? |
||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| translatedBody, _, _, err := createTestTranslator().TranslateRequest(body) | ||||||||||||||||||||||||||||||||
| require.NoError(t, err) | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| assert.Nil(t, translatedBody, "Bedrock OpenAI-compatible API should not mutate the request body") | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| func TestTranslateRequest_MissingModel(t *testing.T) { | ||||||||||||||||||||||||||||||||
| body := map[string]any{ | ||||||||||||||||||||||||||||||||
| "messages": []any{map[string]any{"role": "user", "content": "Hi"}}, | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| _, _, _, err := createTestTranslator().TranslateRequest(body) | ||||||||||||||||||||||||||||||||
| assert.Error(t, err) | ||||||||||||||||||||||||||||||||
| assert.Contains(t, err.Error(), "model field is required") | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| func TestTranslateRequest_EmptyModel(t *testing.T) { | ||||||||||||||||||||||||||||||||
| body := map[string]any{ | ||||||||||||||||||||||||||||||||
| "model": "", | ||||||||||||||||||||||||||||||||
| "messages": []any{map[string]any{"role": "user", "content": "Hi"}}, | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| _, _, _, err := createTestTranslator().TranslateRequest(body) | ||||||||||||||||||||||||||||||||
| assert.Error(t, err) | ||||||||||||||||||||||||||||||||
| assert.Contains(t, err.Error(), "model field is required") | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| func TestTranslateRequest_MissingMessages(t *testing.T) { | ||||||||||||||||||||||||||||||||
| body := map[string]any{ | ||||||||||||||||||||||||||||||||
| "model": "nvidia.nemotron-nano-12b-v2", | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| _, _, _, err := createTestTranslator().TranslateRequest(body) | ||||||||||||||||||||||||||||||||
| assert.Error(t, err) | ||||||||||||||||||||||||||||||||
| assert.Contains(t, err.Error(), "only Chat Completions API is supported") | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
Comment on lines
+109
to
+117
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove pls
Suggested change
|
||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| func TestTranslateRequest_LegacyCompletionsNotSupported(t *testing.T) { | ||||||||||||||||||||||||||||||||
| body := map[string]any{ | ||||||||||||||||||||||||||||||||
| "model": "nvidia.nemotron-nano-12b-v2", | ||||||||||||||||||||||||||||||||
| "prompt": "Complete this sentence: The weather today is", | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| _, _, _, err := createTestTranslator().TranslateRequest(body) | ||||||||||||||||||||||||||||||||
| assert.Error(t, err) | ||||||||||||||||||||||||||||||||
| assert.Contains(t, err.Error(), "only Chat Completions API is supported") | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
Comment on lines
+119
to
+128
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove please.
Suggested change
|
||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| func TestTranslateRequest_HeadersSet(t *testing.T) { | ||||||||||||||||||||||||||||||||
| body := map[string]any{ | ||||||||||||||||||||||||||||||||
| "model": "nvidia.nemotron-nano-12b-v2", | ||||||||||||||||||||||||||||||||
| "messages": []any{map[string]any{"role": "user", "content": "Hi"}}, | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| _, headers, _, err := createTestTranslator().TranslateRequest(body) | ||||||||||||||||||||||||||||||||
| require.NoError(t, err) | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| assert.Len(t, headers, 3) | ||||||||||||||||||||||||||||||||
| assert.Contains(t, headers, ":path") | ||||||||||||||||||||||||||||||||
| assert.Contains(t, headers, "content-type") | ||||||||||||||||||||||||||||||||
| assert.Contains(t, headers, "host") | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
Comment on lines
+130
to
+143
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. covered in first test, pls remove:
Suggested change
|
||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| func TestTranslateResponse_Passthrough(t *testing.T) { | ||||||||||||||||||||||||||||||||
| body := map[string]any{ | ||||||||||||||||||||||||||||||||
| "id": "chatcmpl-abc123", | ||||||||||||||||||||||||||||||||
| "object": "chat.completion", | ||||||||||||||||||||||||||||||||
| "created": 1700000000, | ||||||||||||||||||||||||||||||||
| "model": "nvidia.nemotron-nano-12b-v2", | ||||||||||||||||||||||||||||||||
| "choices": []any{ | ||||||||||||||||||||||||||||||||
| map[string]any{ | ||||||||||||||||||||||||||||||||
| "index": 0, | ||||||||||||||||||||||||||||||||
| "message": map[string]any{ | ||||||||||||||||||||||||||||||||
| "role": "assistant", | ||||||||||||||||||||||||||||||||
| "content": "The answer is 4.", | ||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||
| "finish_reason": "stop", | ||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||
| "usage": map[string]any{ | ||||||||||||||||||||||||||||||||
| "prompt_tokens": 10, | ||||||||||||||||||||||||||||||||
| "completion_tokens": 5, | ||||||||||||||||||||||||||||||||
| "total_tokens": 15, | ||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| translatedBody, err := createTestTranslator().TranslateResponse(body, "nvidia.nemotron-nano-12b-v2") | ||||||||||||||||||||||||||||||||
| require.NoError(t, err) | ||||||||||||||||||||||||||||||||
| assert.Nil(t, translatedBody, "Bedrock OpenAI-compatible response should not be mutated") | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| func TestTranslateResponse_StreamingChunk(t *testing.T) { | ||||||||||||||||||||||||||||||||
| body := map[string]any{ | ||||||||||||||||||||||||||||||||
| "id": "chatcmpl-abc123", | ||||||||||||||||||||||||||||||||
| "object": "chat.completion.chunk", | ||||||||||||||||||||||||||||||||
| "created": 1700000000, | ||||||||||||||||||||||||||||||||
| "model": "nvidia.nemotron-nano-12b-v2", | ||||||||||||||||||||||||||||||||
| "choices": []any{ | ||||||||||||||||||||||||||||||||
| map[string]any{ | ||||||||||||||||||||||||||||||||
| "index": 0, | ||||||||||||||||||||||||||||||||
| "delta": map[string]any{ | ||||||||||||||||||||||||||||||||
| "content": "Hello", | ||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||
| "finish_reason": nil, | ||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| translatedBody, err := createTestTranslator().TranslateResponse(body, "nvidia.nemotron-nano-12b-v2") | ||||||||||||||||||||||||||||||||
| require.NoError(t, err) | ||||||||||||||||||||||||||||||||
| assert.Nil(t, translatedBody) | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
Comment on lines
+173
to
+193
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. doesn't seem to be testing something new. can be removed. |
||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| func TestTranslateResponse_Error(t *testing.T) { | ||||||||||||||||||||||||||||||||
| body := map[string]any{ | ||||||||||||||||||||||||||||||||
| "error": map[string]any{ | ||||||||||||||||||||||||||||||||
| "message": "Model not found", | ||||||||||||||||||||||||||||||||
| "type": "invalid_request_error", | ||||||||||||||||||||||||||||||||
| "code": "model_not_found", | ||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| translatedBody, err := createTestTranslator().TranslateResponse(body, "invalid-model") | ||||||||||||||||||||||||||||||||
| require.NoError(t, err) | ||||||||||||||||||||||||||||||||
| assert.Nil(t, translatedBody, "Error responses should pass through unchanged") | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| func TestProviderName(t *testing.T) { | ||||||||||||||||||||||||||||||||
| assert.Equal(t, "awsbedrock-openai", provider.AWSBedrockOpenAI) | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
Comment on lines
+209
to
+211
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove please. not relevant
Suggested change
|
||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| func TestNewBedrockTranslator(t *testing.T) { | ||||||||||||||||||||||||||||||||
| translator := NewBedrockTranslator() | ||||||||||||||||||||||||||||||||
| assert.NotNil(t, translator) | ||||||||||||||||||||||||||||||||
| assert.Equal(t, "us-east-1", translator.GetRegion()) // Default region | ||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove:
Suggested change
|
||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| func TestGetRegion(t *testing.T) { | ||||||||||||||||||||||||||||||||
| translator := NewBedrockTranslatorWithRegion("eu-west-1") | ||||||||||||||||||||||||||||||||
| assert.Equal(t, "eu-west-1", translator.GetRegion()) | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| func TestNewBedrockTranslatorWithRegion_EmptyRegion(t *testing.T) { | ||||||||||||||||||||||||||||||||
| translator := NewBedrockTranslatorWithRegion("") | ||||||||||||||||||||||||||||||||
| assert.Equal(t, "us-east-1", translator.GetRegion()) // Should default | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
Comment on lines
+219
to
+227
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove pls:
Suggested change
|
||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: align with the other files in the repo