diff --git a/libs/partners/openai/langchain_openai/chat_models/base.py b/libs/partners/openai/langchain_openai/chat_models/base.py index 624e465ded9c5..3e77e6463391a 100644 --- a/libs/partners/openai/langchain_openai/chat_models/base.py +++ b/libs/partners/openai/langchain_openai/chat_models/base.py @@ -562,6 +562,15 @@ def validate_temperature(cls, values: Dict[str, Any]) -> Any: 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."""