-
Notifications
You must be signed in to change notification settings - Fork 1.5k
feat: add AWS Bedrock mantle endpoint to AI Gateway #26745
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
Changes from all commits
f953c8c
bc6ba36
28bfd2a
989e298
d20f41e
6cd6d58
00e8b76
7419630
4db66ee
0db20ff
d941a12
be4c152
3912b98
e46723d
f1bc953
5b0ebfb
7a807a3
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,113 @@ | ||
| package config_test | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| "github.com/stretchr/testify/require" | ||
|
|
||
| "github.com/coder/coder/v2/aibridge/config" | ||
| ) | ||
|
|
||
| func TestAWSBedrockValidate(t *testing.T) { | ||
| t.Parallel() | ||
|
|
||
| tests := []struct { | ||
| name string | ||
| cfg config.AWSBedrock | ||
| errorMsg string | ||
| }{ | ||
| { | ||
| name: "invoke model valid", | ||
| cfg: config.AWSBedrock{ | ||
| Region: "us-east-1", | ||
| Model: "anthropic.claude-sonnet", | ||
| SmallFastModel: "anthropic.claude-haiku", | ||
| }, | ||
| }, | ||
| { | ||
| name: "invoke model valid with base url instead of region", | ||
| cfg: config.AWSBedrock{ | ||
| BaseURL: "https://bedrock-runtime.example.com", | ||
| Model: "anthropic.claude-sonnet", | ||
| SmallFastModel: "anthropic.claude-haiku", | ||
| }, | ||
| }, | ||
| { | ||
| name: "invoke model missing region and base url", | ||
| cfg: config.AWSBedrock{ | ||
| Model: "anthropic.claude-sonnet", | ||
| SmallFastModel: "anthropic.claude-haiku", | ||
| }, | ||
| errorMsg: "region or base url required", | ||
| }, | ||
| { | ||
| name: "invoke model missing model", | ||
| cfg: config.AWSBedrock{ | ||
| Region: "us-east-1", | ||
| SmallFastModel: "anthropic.claude-haiku", | ||
| }, | ||
| errorMsg: "model required", | ||
| }, | ||
| { | ||
| name: "invoke model missing small fast model", | ||
| cfg: config.AWSBedrock{ | ||
| Region: "us-east-1", | ||
| Model: "anthropic.claude-sonnet", | ||
| }, | ||
| errorMsg: "small fast model required", | ||
| }, | ||
| { | ||
| name: "unknown protocol rejected", | ||
| cfg: config.AWSBedrock{ | ||
| Protocol: config.BedrockProtocol("unknown"), | ||
| }, | ||
| errorMsg: "unknown bedrock protocol", | ||
| }, | ||
| { | ||
| name: "mantle valid official api prefix", | ||
| cfg: config.AWSBedrock{ | ||
| Region: "us-east-1", | ||
| BaseURL: "https://bedrock-mantle.us-east-1.api.aws/anthropic", | ||
| Protocol: config.BedrockProtocolMantle, | ||
| }, | ||
| }, | ||
| { | ||
| name: "mantle valid proxy api prefix", | ||
|
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 [CRF-26] The two "mantle valid" rows ( (Bisky)
|
||
| cfg: config.AWSBedrock{ | ||
| Region: "us-east-1", | ||
| BaseURL: "https://proxy.internal/proxy", | ||
| Protocol: config.BedrockProtocolMantle, | ||
| }, | ||
| }, | ||
| { | ||
| name: "mantle missing region", | ||
| cfg: config.AWSBedrock{ | ||
| BaseURL: "https://bedrock-mantle.us-east-1.api.aws", | ||
| Protocol: config.BedrockProtocolMantle, | ||
| }, | ||
| errorMsg: "region required", | ||
| }, | ||
| { | ||
| name: "mantle missing base url", | ||
| cfg: config.AWSBedrock{ | ||
| Region: "us-east-1", | ||
| Protocol: config.BedrockProtocolMantle, | ||
| }, | ||
| errorMsg: "base_url required", | ||
| }, | ||
| } | ||
|
|
||
| for _, tt := range tests { | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| t.Parallel() | ||
|
|
||
| err := tt.cfg.Validate() | ||
| if tt.errorMsg != "" { | ||
| require.Error(t, err) | ||
| require.Contains(t, err.Error(), tt.errorMsg) | ||
| return | ||
| } | ||
| require.NoError(t, err) | ||
| }) | ||
| } | ||
| } | ||
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 [CRF-27] The same
Validate()function names one field two ways: the InvokeModel branch returns"region or base url required"(space, prose) and the new mantle branch returns"base_url required"(underscore, field form). Onlybase_urlmatches what the operator types in settings. Thebase urlstring is pre-existing, but the mantle branch is new and sits a few lines away, so aligning them is this PR's to make. Suggest"region or base_url required"so both point at the field the operator edits.(Leorio)