Skip to content

Commit

Permalink
save
Browse files Browse the repository at this point in the history
  • Loading branch information
nsthorat committed Feb 2, 2024
1 parent 1b700ab commit 4f4984e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
13 changes: 6 additions & 7 deletions lilac/embeddings/openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,14 @@ def setup(self) -> None:
azure_api_endpoint = env('AZURE_OPENAI_ENDPOINT')

if not api_key and not azure_api_key:
raise ValueError('`OPENAI_API_KEY` or `AZURE_OPENAI_KEY` '
'environment variables not set, please set one.')
raise ValueError(
'`OPENAI_API_KEY` or `AZURE_OPENAI_KEY` ' 'environment variables not set, please set one.'
)
if api_key and azure_api_key:
raise ValueError(
'Both `OPENAI_API_KEY` and `AZURE_OPENAI_KEY` '
'environment variables are set, please set only one.')
'environment variables are set, please set only one.'
)

try:
import openai
Expand All @@ -61,16 +63,13 @@ def setup(self) -> None:
)

else:

if api_key:
self._client = openai.OpenAI(api_key=api_key)
self._azure = False

elif azure_api_key:
self._client = openai.AzureOpenAI(
api_key=azure_api_key,
api_version=azure_api_version,
azure_endpoint=azure_api_endpoint
api_key=azure_api_key, api_version=azure_api_version, azure_endpoint=azure_api_endpoint
)
self._azure = True
OpenAIEmbedding.local_batch_size = AZURE_OPENAI_BATCH_SIZE
Expand Down
2 changes: 1 addition & 1 deletion lilac/project_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ async def test_create_project_and_set_env(tmp_path_factory: pytest.TempPathFacto


async def test_create_project_and_set_env_from_env(
tmp_path_factory: pytest.TempPathFactory
tmp_path_factory: pytest.TempPathFactory,
) -> None:
tmp_path = str(tmp_path_factory.mktemp('test_project'))

Expand Down

0 comments on commit 4f4984e

Please sign in to comment.