From 1299bb2faecdbb42980b4c268fad2294619d2688 Mon Sep 17 00:00:00 2001 From: Josephasafg Date: Fri, 21 Jun 2024 18:34:03 +0300 Subject: [PATCH] fix: Added _create_base_url --- ai21/clients/azure/ai21_azure_client.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/ai21/clients/azure/ai21_azure_client.py b/ai21/clients/azure/ai21_azure_client.py index a802afa4..39f45ee4 100644 --- a/ai21/clients/azure/ai21_azure_client.py +++ b/ai21/clients/azure/ai21_azure_client.py @@ -43,6 +43,12 @@ def _get_azure_ad_token(self) -> Optional[str]: return None + def _add_version_to_url(self, base_url: str, api_version: str) -> str: + if api_version: + return f"{base_url}/{api_version}" + + return f"{base_url}/{_DEFAULT_AZURE_VERSION}" + class AsyncAI21AzureClient(BaseAzureClient, AsyncAI21HTTPClient): def __init__( @@ -64,9 +70,7 @@ def __init__( raise ValueError("Must provide either api_key or azure_ad_token_provider or azure_ad_token") headers = self._prepare_headers(headers=default_headers or {}) - - if api_version: - base_url += f"/{api_version}" + base_url = self._add_version_to_url(base_url=base_url, api_version=api_version) super().__init__( api_key=api_key, @@ -102,9 +106,7 @@ def __init__( raise ValueError("Must provide either api_key or azure_ad_token_provider or azure_ad_token") headers = self._prepare_headers(headers=default_headers or {}) - - if api_version: - base_url += f"/{api_version}" + base_url = self._add_version_to_url(base_url=base_url, api_version=api_version) super().__init__( api_key=api_key,