Skip to content

Commit

Permalink
'Refactored by Sourcery'
Browse files Browse the repository at this point in the history
  • Loading branch information
Sourcery AI committed Nov 15, 2023
1 parent 0ed89c6 commit 5d54ecb
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions pandasai/llm/azure_openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,11 @@ def __init__(
"Azure endpoint is required. Please add an environment variable "
"`AZURE_OPENAI_API_ENDPOINT` or pass `azure_endpoint` as a named parameter"
)
else:
if self.api_base is None:
raise APIKeyNotFoundError(
"Azure OpenAI base is required. Please add an environment variable "
"`OPENAI_API_BASE` or pass `api_base` as a named parameter"
)
elif self.api_base is None:
raise APIKeyNotFoundError(
"Azure OpenAI base is required. Please add an environment variable "
"`OPENAI_API_BASE` or pass `api_base` as a named parameter"
)
if self.api_version is None:
raise APIKeyNotFoundError(
"Azure OpenAI version is required. Please add an environment variable "
Expand All @@ -129,15 +128,15 @@ def __init__(
self._set_params(**kwargs)
# set the client
if self._is_chat_model:
if is_openai_v1():
self.client = openai.AzureOpenAI(**self._client_params).chat.completions
else:
self.client = openai.ChatCompletion
self.client = (
openai.AzureOpenAI(**self._client_params).chat.completions
if is_openai_v1()
else openai.ChatCompletion
)
elif is_openai_v1():
self.client = openai.AzureOpenAI(**self._client_params).completions
else:
if is_openai_v1():
self.client = openai.AzureOpenAI(**self._client_params).completions
else:
self.client = openai.Completion
self.client = openai.Completion

@property
def _default_params(self) -> Dict[str, Any]:
Expand Down

0 comments on commit 5d54ecb

Please sign in to comment.