diff --git a/libs/partners/openai/langchain_openai/chat_models/azure.py b/libs/partners/openai/langchain_openai/chat_models/azure.py index df634cedec874..0bfd220888eff 100644 --- a/libs/partners/openai/langchain_openai/chat_models/azure.py +++ b/libs/partners/openai/langchain_openai/chat_models/azure.py @@ -527,6 +527,28 @@ class Joke(BaseModel): Used for tracing and token counting. Does NOT affect completion. """ + disabled_params: Optional[Dict[str, Any]] = Field(default=None) + """Parameters of the OpenAI client or chat.completions endpoint that should be + disabled for the given model. + + Should be specified as ``{"param": None | ['val1', 'val2']}`` where the key is the + parameter and the value is either None, meaning that parameter should never be + used, or it's a list of disabled values for the parameter. + + For example, older models may not support the 'parallel_tool_calls' parameter at + all, in which case ``disabled_params={"parallel_tool_calls: None}`` can ben passed + in. + + If a parameter is disabled then it will not be used by default in any methods, e.g. + in + :meth:`~langchain_openai.chat_models.azure.AzureChatOpenAI.with_structured_output`. + However this does not prevent a user from directly passed in the parameter during + invocation. + + By default, unless ``model_name="gpt-4o"`` is specified, then + 'parallel_tools_calls' will be disabled. + """ + @classmethod def get_lc_namespace(cls) -> List[str]: """Get the namespace of the langchain object.""" diff --git a/libs/partners/openai/langchain_openai/chat_models/base.py b/libs/partners/openai/langchain_openai/chat_models/base.py index 3bc8e990699a6..b9c19ea8f98ae 100644 --- a/libs/partners/openai/langchain_openai/chat_models/base.py +++ b/libs/partners/openai/langchain_openai/chat_models/base.py @@ -455,6 +455,22 @@ class BaseChatOpenAI(BaseChatModel): include_response_headers: bool = False """Whether to include response headers in the output message response_metadata.""" disabled_params: Optional[Dict[str, Any]] = Field(default=None) + """Parameters of the OpenAI client or chat.completions endpoint that should be + disabled for the given model. + + Should be specified as ``{"param": None | ['val1', 'val2']}`` where the key is the + parameter and the value is either None, meaning that parameter should never be + used, or it's a list of disabled values for the parameter. + + For example, older models may not support the 'parallel_tool_calls' parameter at + all, in which case ``disabled_params={"parallel_tool_calls: None}`` can ben passed + in. + + If a parameter is disabled then it will not be used by default in any methods, e.g. + in :meth:`~langchain_openai.chat_models.base.ChatOpenAI.with_structured_output`. + However this does not prevent a user from directly passed in the parameter during + invocation. + """ model_config = ConfigDict(populate_by_name=True)