openai: disable streaming for o1 by default (#29147)

Currently 400s
https://community.openai.com/t/streaming-support-for-o1-o1-2024-12-17-resulting-in-400-unsupported-value/1085043

o1-mini and o1-preview stream fine
This commit is contained in:
Erick Friis
2025-01-10 18:24:11 -08:00
committed by GitHub
parent 62074bac60
commit bbc3e3b2cf
2 changed files with 25 additions and 0 deletions

View File

@@ -562,6 +562,15 @@ class BaseChatOpenAI(BaseChatModel):
values["temperature"] = 1
return values
@model_validator(mode="before")
@classmethod
def validate_disable_streaming(cls, values: Dict[str, Any]) -> Any:
"""Disable streaming if n > 1."""
model = values.get("model_name") or values.get("model") or ""
if model == "o1" and values.get("disable_streaming") is None:
values["disable_streaming"] = True
return values
@model_validator(mode="after")
def validate_environment(self) -> Self:
"""Validate that api key and python package exists in environment."""