From 9492277feaa21be042c9be52bd684d6b1a35c403 Mon Sep 17 00:00:00 2001 From: Ognjen Francuski Date: Tue, 20 Aug 2024 10:29:37 +0200 Subject: [PATCH] Fix using sync 'litellm.client_session' for async calls in azure.py --- litellm/llms/azure.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/litellm/llms/azure.py b/litellm/llms/azure.py index 876d3b899a..cd99f3f75d 100644 --- a/litellm/llms/azure.py +++ b/litellm/llms/azure.py @@ -692,7 +692,7 @@ class AzureChatCompletion(BaseLLM): "api_version": api_version, "azure_endpoint": api_base, "azure_deployment": model, - "http_client": litellm.client_session, + "http_client": litellm.aclient_session, "max_retries": max_retries, "timeout": timeout, } @@ -860,7 +860,7 @@ class AzureChatCompletion(BaseLLM): "api_version": api_version, "azure_endpoint": api_base, "azure_deployment": model, - "http_client": litellm.client_session, + "http_client": litellm.aclient_session, "max_retries": data.pop("max_retries", 2), "timeout": timeout, } @@ -989,13 +989,16 @@ class AzureChatCompletion(BaseLLM): "api_version": api_version, "azure_endpoint": api_base, "azure_deployment": model, - "http_client": litellm.client_session, "max_retries": max_retries, "timeout": timeout, } azure_client_params = select_azure_base_url_or_endpoint( azure_client_params=azure_client_params ) + if aembedding: + azure_client_params["http_client"] = litellm.aclient_session + else: + azure_client_params["http_client"] = litellm.client_session if api_key is not None: azure_client_params["api_key"] = api_key elif azure_ad_token is not None: