From 002ab1111213344cb5e9f662f7efef3429fa1039 Mon Sep 17 00:00:00 2001 From: Rob Emanuele Date: Wed, 25 Sep 2024 10:54:49 -0400 Subject: [PATCH] Fix conditions to avoid token fetch in completions --- .../ai/open_ai/services/azure_text_completion.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/python/semantic_kernel/connectors/ai/open_ai/services/azure_text_completion.py b/python/semantic_kernel/connectors/ai/open_ai/services/azure_text_completion.py index 046476c786d7..85022d020779 100644 --- a/python/semantic_kernel/connectors/ai/open_ai/services/azure_text_completion.py +++ b/python/semantic_kernel/connectors/ai/open_ai/services/azure_text_completion.py @@ -72,7 +72,13 @@ def __init__( # If the api_key is none, and the ad_token is none, and the ad_token_provider is none, # then we will attempt to get the ad_token using the default endpoint specified in the Azure OpenAI settings. - if api_key is None and ad_token_provider is None and azure_openai_settings.token_endpoint and ad_token is None: + if ( + azure_openai_settings.api_key is None + and ad_token_provider is None + and azure_openai_settings.token_endpoint + and ad_token is None + and async_client is None + ): ad_token = azure_openai_settings.get_azure_openai_auth_token( token_endpoint=azure_openai_settings.token_endpoint )