Skip to content

Commit

Permalink
fix: Added _create_base_url
Browse files Browse the repository at this point in the history
  • Loading branch information
Josephasafg committed Jun 21, 2024
1 parent bd49dbc commit 1299bb2
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions ai21/clients/azure/ai21_azure_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__(
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 1299bb2

Please sign in to comment.