bedrockConfigFromRow returns nil when the settings have no Bedrock discriminator or when the Bedrock fields are not actually configured. The provider row's BaseUrl is the generic upstream endpoint and is always non-empty, so it cannot serve as a Bedrock detection signal; gate on the settings blob al
(row database.AIProvider, settings codersdk.AIProviderSettings)
| 328 | // always non-empty, so it cannot serve as a Bedrock detection signal; |
| 329 | // gate on the settings blob alone via [codersdk.AIProviderBedrockSettings.IsConfigured]. |
| 330 | func bedrockConfigFromRow(row database.AIProvider, settings codersdk.AIProviderSettings) *aibridge.AWSBedrockConfig { |
| 331 | if settings.Bedrock == nil { |
| 332 | return nil |
| 333 | } |
| 334 | bedrockSettings := *settings.Bedrock |
| 335 | if !bedrockSettings.IsConfigured() { |
| 336 | return nil |
| 337 | } |
| 338 | accessKey := ptr.NilToEmpty(bedrockSettings.AccessKey) |
| 339 | accessKeySecret := ptr.NilToEmpty(bedrockSettings.AccessKeySecret) |
| 340 | return &aibridge.AWSBedrockConfig{ |
| 341 | BaseURL: row.BaseUrl, |
| 342 | Region: bedrockSettings.Region, |
| 343 | AccessKey: accessKey, |
| 344 | AccessKeySecret: accessKeySecret, |
| 345 | Model: bedrockSettings.Model, |
| 346 | SmallFastModel: bedrockSettings.SmallFastModel, |
| 347 | } |
| 348 | } |
| 349 | |
| 350 | // circuitBreakerConfig returns nil when the breaker is disabled. |
| 351 | func circuitBreakerConfig(cfg codersdk.AIBridgeConfig) *config.CircuitBreaker { |