From 3507c2698c5674cc1e5c99fa9290e043f4438382 Mon Sep 17 00:00:00 2001 From: Krrish Dholakia Date: Sat, 14 Sep 2024 18:49:33 -0700 Subject: [PATCH] fix(bedrock/embed): fix reordering of headers --- litellm/llms/bedrock/embed/embedding.py | 7 ++++--- .../vertex_ai_endpoints/google_ai_studio_endpoints.py | 2 +- litellm/utils.py | 4 +--- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/litellm/llms/bedrock/embed/embedding.py b/litellm/llms/bedrock/embed/embedding.py index e25fa0dc084..8203eb6e678 100644 --- a/litellm/llms/bedrock/embed/embedding.py +++ b/litellm/llms/bedrock/embed/embedding.py @@ -197,7 +197,7 @@ class BedrockEmbedding(BaseAWSLLM): client=client, timeout=timeout, api_base=prepped.url, - headers=dict(prepped.headers), + headers=prepped.headers, # type: ignore data=data, ) @@ -288,7 +288,7 @@ class BedrockEmbedding(BaseAWSLLM): client=client, timeout=timeout, api_base=prepped.url, - headers=dict(prepped.headers), + headers=prepped.headers, # type: ignore data=data, ) @@ -454,6 +454,7 @@ class BedrockEmbedding(BaseAWSLLM): headers = {"Content-Type": "application/json"} if extra_headers is not None: headers = {"Content-Type": "application/json", **extra_headers} + request = AWSRequest( method="POST", url=endpoint_url, data=json.dumps(data), headers=headers ) @@ -478,5 +479,5 @@ class BedrockEmbedding(BaseAWSLLM): aembedding=aembedding, timeout=timeout, client=client, - headers=dict(prepped.headers), + headers=prepped.headers, # type: ignore ) diff --git a/litellm/proxy/vertex_ai_endpoints/google_ai_studio_endpoints.py b/litellm/proxy/vertex_ai_endpoints/google_ai_studio_endpoints.py index c4c71820b93..6051af37c8b 100644 --- a/litellm/proxy/vertex_ai_endpoints/google_ai_studio_endpoints.py +++ b/litellm/proxy/vertex_ai_endpoints/google_ai_studio_endpoints.py @@ -214,7 +214,7 @@ async def bedrock_proxy_route( endpoint_func = create_pass_through_route( endpoint=endpoint, target=str(prepped.url), - custom_headers=dict(prepped.headers), + custom_headers=prepped.headers, # type: ignore ) # dynamically construct pass-through endpoint based on incoming path received_value = await endpoint_func( request, diff --git a/litellm/utils.py b/litellm/utils.py index d3e757ae814..907839d51ed 100644 --- a/litellm/utils.py +++ b/litellm/utils.py @@ -8153,9 +8153,7 @@ def exception_type( exception_mapping_worked = True if hasattr(original_exception, "request"): raise APIConnectionError( - message="{}\n{}".format( - str(original_exception), traceback.format_exc() - ), + message="{} - {}".format(exception_provider, error_str), llm_provider=custom_llm_provider, model=model, request=original_exception.request,