MCPcopy Create free account
hub / github.com/coder/aibridge / withAWSBedrockOptions

Method withAWSBedrockOptions

intercept/messages/base.go:267–312  ·  view source on GitHub ↗
(ctx context.Context, cfg *aibconfig.AWSBedrock)

Source from the content-addressed store, hash-verified

265}
266
267func (*interceptionBase) withAWSBedrockOptions(ctx context.Context, cfg *aibconfig.AWSBedrock) ([]option.RequestOption, error) {
268 if cfg == nil {
269 return nil, xerrors.New("nil config given")
270 }
271 if cfg.Region == "" && cfg.BaseURL == "" {
272 return nil, xerrors.New("region or base url required")
273 }
274 if cfg.AccessKey == "" {
275 return nil, xerrors.New("access key required")
276 }
277 if cfg.AccessKeySecret == "" {
278 return nil, xerrors.New("access key secret required")
279 }
280 if cfg.Model == "" {
281 return nil, xerrors.New("model required")
282 }
283 if cfg.SmallFastModel == "" {
284 return nil, xerrors.New("small fast model required")
285 }
286
287 opts := []func(*config.LoadOptions) error{
288 config.WithRegion(cfg.Region),
289 config.WithCredentialsProvider(
290 credentials.NewStaticCredentialsProvider(
291 cfg.AccessKey,
292 cfg.AccessKeySecret,
293 "",
294 ),
295 ),
296 }
297
298 awsCfg, err := config.LoadDefaultConfig(ctx, opts...)
299 if err != nil {
300 return nil, xerrors.Errorf("failed to load AWS Bedrock config: %w", err)
301 }
302
303 var out []option.RequestOption
304 out = append(out, bedrock.WithConfig(awsCfg))
305
306 // If a custom base URL is set, override the default endpoint constructed by the bedrock middleware.
307 if cfg.BaseURL != "" {
308 out = append(out, option.WithBaseURL(cfg.BaseURL))
309 }
310
311 return out, nil
312}
313
314// augmentRequestForBedrock will change the model used for the request since AWS Bedrock doesn't support
315// Anthropics' model names. It also converts adaptive thinking to enabled with a budget for models that

Callers 2

newMessagesServiceMethod · 0.95
TestAWSBedrockValidationFunction · 0.95

Calls

no outgoing calls

Tested by 1

TestAWSBedrockValidationFunction · 0.76