mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-10 03:28:53 +00:00
fix bedrock embeddings - validate env
This commit is contained in:
parent
92b72fc759
commit
d9794f0811
1 changed files with 12 additions and 8 deletions
|
|
@ -21,14 +21,18 @@ from .v1_transformation import CohereEmbeddingConfig
|
|||
|
||||
|
||||
def validate_environment(api_key, headers: dict):
|
||||
headers.update(
|
||||
{
|
||||
"Request-Source": "unspecified:litellm",
|
||||
"accept": "application/json",
|
||||
"content-type": "application/json",
|
||||
}
|
||||
)
|
||||
if api_key:
|
||||
# Create a lowercase key lookup to avoid duplicate headers with different cases
|
||||
# This is important when headers come from AWS signed requests (which use Title-Case)
|
||||
existing_keys_lower = {k.lower(): k for k in headers.keys()}
|
||||
|
||||
# Only add headers if they don't already exist (case-insensitive check)
|
||||
if "request-source" not in existing_keys_lower:
|
||||
headers["Request-Source"] = "unspecified:litellm"
|
||||
if "accept" not in existing_keys_lower:
|
||||
headers["accept"] = "application/json"
|
||||
if "content-type" not in existing_keys_lower:
|
||||
headers["content-type"] = "application/json"
|
||||
if api_key and "authorization" not in existing_keys_lower:
|
||||
headers["Authorization"] = f"Bearer {api_key}"
|
||||
return headers
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue