bedrock: Support global endpoints and new regional endpoints (#44103)
Closes #43598 Release Notes: - bedrock: Added opt-in `allow_global` which enables global endpoints - bedrock: Updated cross-region-inference endpoint and model list - bedrock: Fixed Opus 4.5 access on Bedrock, now only accessible through the `allow_global` setting
This commit is contained in:
@@ -71,6 +71,7 @@ pub struct AmazonBedrockSettings {
|
||||
pub profile_name: Option<String>,
|
||||
pub role_arn: Option<String>,
|
||||
pub authentication_method: Option<BedrockAuthMethod>,
|
||||
pub allow_global: Option<bool>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, EnumIter, IntoStaticStr, JsonSchema)]
|
||||
@@ -239,6 +240,13 @@ impl State {
|
||||
.or(settings_region)
|
||||
.unwrap_or(String::from("us-east-1"))
|
||||
}
|
||||
|
||||
fn get_allow_global(&self) -> bool {
|
||||
self.settings
|
||||
.as_ref()
|
||||
.and_then(|s| s.allow_global)
|
||||
.unwrap_or(false)
|
||||
}
|
||||
}
|
||||
|
||||
pub struct BedrockLanguageModelProvider {
|
||||
@@ -545,11 +553,13 @@ impl LanguageModel for BedrockModel {
|
||||
LanguageModelCompletionError,
|
||||
>,
|
||||
> {
|
||||
let Ok(region) = cx.read_entity(&self.state, |state, _cx| state.get_region()) else {
|
||||
let Ok((region, allow_global)) = cx.read_entity(&self.state, |state, _cx| {
|
||||
(state.get_region(), state.get_allow_global())
|
||||
}) else {
|
||||
return async move { Err(anyhow::anyhow!("App State Dropped").into()) }.boxed();
|
||||
};
|
||||
|
||||
let model_id = match self.model.cross_region_inference_id(®ion) {
|
||||
let model_id = match self.model.cross_region_inference_id(®ion, allow_global) {
|
||||
Ok(s) => s,
|
||||
Err(e) => {
|
||||
return async move { Err(e.into()) }.boxed();
|
||||
|
||||
@@ -58,6 +58,7 @@ impl settings::Settings for AllLanguageModelSettings {
|
||||
profile_name: bedrock.profile,
|
||||
role_arn: None, // todo(was never a setting for this...)
|
||||
authentication_method: bedrock.authentication_method.map(Into::into),
|
||||
allow_global: bedrock.allow_global,
|
||||
},
|
||||
deepseek: DeepSeekSettings {
|
||||
api_url: deepseek.api_url.unwrap(),
|
||||
|
||||
Reference in New Issue
Block a user