Skip to content

Commit 3b9faed

Browse files
committed
Fix more CI issues
1 parent b9053c1 commit 3b9faed

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

sentry_sdk/integrations/openai.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from sentry_sdk._types import TYPE_CHECKING
44

55
if TYPE_CHECKING:
6-
from typing import Iterator, Any, Iterable, List, Optional, Callable
6+
from typing import Any, Iterable, List, Optional, Callable, Iterator
77
from sentry_sdk.tracing import Span
88

99
from sentry_sdk._functools import wraps
@@ -146,9 +146,11 @@ def new_chat_completion(*args, **kwargs):
146146
elif hasattr(res, "_iterator"):
147147
data_buf: list[list[str]] = [] # one for each choice
148148

149-
old_iterator: Iterator[ChatCompletionChunk] = res._iterator
149+
# type: Iterator[ChatCompletionChunk]
150+
old_iterator = res._iterator
150151

151-
def new_iterator() -> Iterator[ChatCompletionChunk]:
152+
def new_iterator():
153+
# type: () -> Iterator[ChatCompletionChunk]
152154
with capture_internal_exceptions():
153155
for x in old_iterator:
154156
if hasattr(x, "choices"):

tests/integrations/openai/test_openai.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
from openai import OpenAI, Stream
22
from openai.types import CompletionUsage, CreateEmbeddingResponse, Embedding
33
from openai.types.chat import ChatCompletion, ChatCompletionMessage, ChatCompletionChunk
4-
from openai.types.chat.chat_completion_chunk import ChoiceDelta, Choice
4+
from openai.types.chat.chat_completion import Choice
5+
from openai.types.chat.chat_completion_chunk import ChoiceDelta, Choice as DeltaChoice
56
from openai.types.create_embedding_response import Usage as EmbeddingTokenUsage
67

78
from sentry_sdk import start_transaction
@@ -72,22 +73,22 @@ def test_streaming_chat_completion(sentry_init, capture_events):
7273
returned_stream._iterator = [
7374
ChatCompletionChunk(
7475
id="1",
75-
choices=[Choice(index=0, delta=ChoiceDelta(content="hel"))],
76+
choices=[DeltaChoice(index=0, delta=ChoiceDelta(content="hel"))],
7677
created=100000,
7778
model="model-id",
7879
object="chat.completion.chunk",
7980
),
8081
ChatCompletionChunk(
8182
id="1",
82-
choices=[Choice(index=1, delta=ChoiceDelta(content="lo "))],
83+
choices=[DeltaChoice(index=1, delta=ChoiceDelta(content="lo "))],
8384
created=100000,
8485
model="model-id",
8586
object="chat.completion.chunk",
8687
),
8788
ChatCompletionChunk(
8889
id="1",
8990
choices=[
90-
Choice(
91+
DeltaChoice(
9192
index=2, delta=ChoiceDelta(content="world"), finish_reason="stop"
9293
)
9394
],

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ envlist =
147147
{py3.5,py3.11,py3.12}-loguru-latest
148148

149149
# OpenAI
150-
{py3.5,py3.7,py3.9,py3.11,py3.12}-openai-latest
150+
{py3.9,py3.11,py3.12}-openai-latest
151151

152152
# OpenTelemetry (OTel)
153153
{py3.7,py3.9,py3.11,py3.12}-opentelemetry

0 commit comments

Comments
 (0)