openai[patch]: default to invoke on o1 stream() (#27983)

This commit is contained in:
Bagatur
2024-11-08 19:12:59 -08:00
committed by GitHub
parent 503f2487a5
commit 33dbfba08b
2 changed files with 46 additions and 36 deletions

View File

@@ -1061,3 +1061,27 @@ def test_prediction_tokens() -> None:
]
assert output_token_details["accepted_prediction_tokens"] > 0
assert output_token_details["rejected_prediction_tokens"] > 0
def test_stream_o1() -> None:
list(ChatOpenAI(model="o1-mini").stream("how are you"))
async def test_astream_o1() -> None:
async for _ in ChatOpenAI(model="o1-mini").astream("how are you"):
pass
class Foo(BaseModel):
response: str
def test_stream_response_format() -> None:
list(ChatOpenAI(model="gpt-4o-mini").stream("how are ya", response_format=Foo))
async def test_astream_response_format() -> None:
async for _ in ChatOpenAI(model="gpt-4o-mini").astream(
"how are ya", response_format=Foo
):
pass