Skip to content

Commit 12ac796

Browse files
committed
fix failed tests and lint
1 parent 3fe9528 commit 12ac796

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

src/agents/models/openai_chatcompletions.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -570,18 +570,25 @@ def _get_client(self) -> AsyncOpenAI:
570570

571571

572572
class _Converter:
573+
574+
@classmethod
575+
def is_openai(cls, client: AsyncOpenAI):
576+
return str(client.base_url).startswith("https://api.openai.com")
577+
573578
@classmethod
574579
def get_store_param(cls, client: AsyncOpenAI, model_settings: ModelSettings) -> bool | None:
575580
# Match the behavior of Responses where store is True when not given
576-
default_store = True if str(client.base_url).startswith("https://api.openai.com") else None
581+
default_store = True if cls.is_openai(client) else None
577582
return model_settings.store if model_settings.store is not None else default_store
578583

579584
@classmethod
580-
def get_stream_options_param(cls, client: AsyncOpenAI, model_settings: ModelSettings) -> dict | None:
581-
default_include_usage = True if str(client.base_url).startswith("https://api.openai.com") else None
585+
def get_stream_options_param(
586+
cls, client: AsyncOpenAI, model_settings: ModelSettings
587+
) -> dict[str, bool] | None:
588+
default_include_usage = True if cls.is_openai(client) else None
582589
include_usage = model_settings.include_usage if model_settings.include_usage is not None \
583590
else default_include_usage
584-
stream_options = {"include_usage": include_usage} if include_usage is not None else NOT_GIVEN
591+
stream_options = {"include_usage": include_usage} if include_usage is not None else None
585592
return stream_options
586593

587594
@classmethod

tests/test_openai_chatcompletions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ def __init__(self, completions: DummyCompletions) -> None:
282282
# Check OpenAI client was called for streaming
283283
assert completions.kwargs["stream"] is True
284284
assert completions.kwargs["store"] is NOT_GIVEN
285-
assert completions.kwargs["stream_options"] == {"include_usage": True}
285+
assert completions.kwargs["stream_options"] is NOT_GIVEN
286286
# Response is a proper openai Response
287287
assert isinstance(response, Response)
288288
assert response.id == FAKE_RESPONSES_ID

0 commit comments

Comments
 (0)