mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-03 02:22:24 +00:00
fix(bedrock): safely handle None credentials when extracting from aws_bedrock_client (#38579)
This commit is contained in:
parent
e55dbaf347
commit
de8802e1a0
1 changed files with 9 additions and 7 deletions
|
|
@ -4016,14 +4016,16 @@ def _complete_bedrock(ctx: _CompletionDispatchContext) -> _CompletionDispatchRes
|
|||
)
|
||||
# Extract credentials for legacy boto3 client and pass thru to httpx
|
||||
aws_bedrock_client: Final = optional_params.pop("aws_bedrock_client")
|
||||
creds: Final = aws_bedrock_client._get_credentials().get_frozen_credentials()
|
||||
creds_obj = aws_bedrock_client._get_credentials()
|
||||
creds = creds_obj.get_frozen_credentials() if creds_obj is not None else None
|
||||
|
||||
if creds.access_key:
|
||||
optional_params["aws_access_key_id"] = creds.access_key
|
||||
if creds.secret_key:
|
||||
optional_params["aws_secret_access_key"] = creds.secret_key
|
||||
if creds.token:
|
||||
optional_params["aws_session_token"] = creds.token
|
||||
if creds is not None:
|
||||
if creds.access_key:
|
||||
optional_params["aws_access_key_id"] = creds.access_key
|
||||
if creds.secret_key:
|
||||
optional_params["aws_secret_access_key"] = creds.secret_key
|
||||
if creds.token:
|
||||
optional_params["aws_session_token"] = creds.token
|
||||
if "aws_region_name" not in optional_params or optional_params["aws_region_name"] is None:
|
||||
optional_params["aws_region_name"] = aws_bedrock_client.meta.region_name
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue