From 9aa75eaef387459ce7e2beaad25c4607ac626d24 Mon Sep 17 00:00:00 2001 From: Mason Daugherty Date: Fri, 27 Jun 2025 11:27:41 -0400 Subject: [PATCH] docs: enhance docstring for `disable_streaming` parameter in BaseChatModel (#31759) Resolves #31758 --- .../core/langchain_core/language_models/chat_models.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/libs/core/langchain_core/language_models/chat_models.py b/libs/core/langchain_core/language_models/chat_models.py index f74270a9ac8..2afa3bafea1 100644 --- a/libs/core/langchain_core/language_models/chat_models.py +++ b/libs/core/langchain_core/language_models/chat_models.py @@ -300,9 +300,15 @@ class BaseChatModel(BaseLanguageModel[BaseMessage], ABC): defer to ``invoke()``/``ainvoke()``. - If True, will always bypass streaming case. - - If "tool_calling", will bypass streaming case only when the model is called - with a ``tools`` keyword argument. + - If ``'tool_calling'``, will bypass streaming case only when the model is called + with a ``tools`` keyword argument. In other words, LangChain will automatically + switch to non-streaming behavior (``invoke()``) only when the tools argument is + provided. This offers the best of both worlds. - If False (default), will always use streaming case if available. + + The main reason for this flag is that code might be written using ``.stream()`` and + a user may want to swap out a given model for another model whose the implementation + does not properly support streaming. """ @model_validator(mode="before")