Skip to content

Commit

Permalink
openai: disable streaming for o1 by default
Browse files Browse the repository at this point in the history
  • Loading branch information
efriis committed Jan 11, 2025
1 parent 62074ba commit c5350ea
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions libs/partners/openai/langchain_openai/chat_models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down

0 comments on commit c5350ea

Please sign in to comment.