Skip to content

Commit

Permalink
chore: formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelrince committed Aug 23, 2024
1 parent 1376714 commit 858137d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion ecologits/tracers/openai_tracer.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def openai_chat_wrapper_stream(
token_count = 0
for i, chunk in enumerate(stream):
# azure openai has an empty first chunk so we skip it
if i==0 and chunk.model=="":
if i == 0 and chunk.model == "":
continue
if i > 0 and chunk.choices[0].finish_reason is None:
token_count += 1
Expand Down
6 changes: 4 additions & 2 deletions tests/test_openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import pytest
from openai import OpenAI, AsyncOpenAI, AzureOpenAI, AsyncAzureOpenAI


@pytest.mark.vcr
def test_openai_chat(tracer_init):
client = OpenAI()
Expand Down Expand Up @@ -60,7 +61,8 @@ def test_azure_openai_chat(tracer_init):
)
assert len(response.choices) > 0
assert response.impacts.energy.value > 0



@pytest.mark.vcr
@pytest.mark.asyncio
async def test_azure_openai_async_chat(tracer_init):
Expand All @@ -72,6 +74,7 @@ async def test_azure_openai_async_chat(tracer_init):
assert len(response.choices) > 0
assert response.impacts.energy.value > 0


@pytest.mark.vcr
def test_azure_openai_stream_chat(tracer_init):
client = AzureOpenAI(azure_endpoint=os.getenv("AZURE_OPENAI_ENDPOINT"),
Expand All @@ -83,4 +86,3 @@ def test_azure_openai_stream_chat(tracer_init):
)
for chunk in stream:
assert chunk.impacts.energy.value >= 0

0 comments on commit 858137d

Please sign in to comment.