openai[patch]: add explicit attribute for service tier (#31005)

This commit is contained in:
ccurme
2025-04-25 14:38:23 -04:00
committed by GitHub
parent ab871a7b39
commit 629b7a5a43
4 changed files with 18 additions and 3 deletions

View File

@@ -215,12 +215,15 @@ async def test_openai_abatch_tags(use_responses_api: bool) -> None:
assert isinstance(token.text(), str)
@pytest.mark.scheduled
@pytest.mark.flaky(retries=3, delay=1)
def test_openai_invoke() -> None:
"""Test invoke tokens from ChatOpenAI."""
llm = ChatOpenAI(max_tokens=MAX_TOKEN_COUNT) # type: ignore[call-arg]
llm = ChatOpenAI(
model="o4-mini",
service_tier="flex", # Also test service_tier
)
result = llm.invoke("I'm Pickle Rick", config=dict(tags=["foo"]))
result = llm.invoke("Hello", config=dict(tags=["foo"]))
assert isinstance(result.content, str)
# assert no response headers if include_response_headers is not set

View File

@@ -1732,3 +1732,9 @@ def test__construct_responses_api_input_multiple_message_types() -> None:
# assert no mutation has occurred
assert messages_copy == messages
def test_service_tier() -> None:
llm = ChatOpenAI(model="o4-mini", service_tier="flex")
payload = llm._get_request_payload([HumanMessage("Hello")])
assert payload["service_tier"] == "flex"