Home / Function/ _should_stream() — langchain Function Reference

_should_stream() — langchain Function Reference

Architecture documentation for the _should_stream() function in chat_models.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  acb01ca3_0bb3_770e_bcbf_a1657257fc54["_should_stream()"]
  d5ca3c3a_3c29_0cb2_a156_35c92a31f5fd["ChatGroq"]
  acb01ca3_0bb3_770e_bcbf_a1657257fc54 -->|defined in| d5ca3c3a_3c29_0cb2_a156_35c92a31f5fd
  style acb01ca3_0bb3_770e_bcbf_a1657257fc54 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/partners/groq/langchain_groq/chat_models.py lines 581–602

    def _should_stream(
        self,
        *,
        async_api: bool,
        run_manager: CallbackManagerForLLMRun
        | AsyncCallbackManagerForLLMRun
        | None = None,
        **kwargs: Any,
    ) -> bool:
        """Determine if a given model call should hit the streaming API."""
        base_should_stream = super()._should_stream(
            async_api=async_api, run_manager=run_manager, **kwargs
        )
        if base_should_stream and ("response_format" in kwargs):
            # Streaming not supported in JSON mode or structured outputs.
            response_format = kwargs["response_format"]
            if isinstance(response_format, dict) and response_format.get("type") in {
                "json_schema",
                "json_object",
            }:
                return False
        return base_should_stream

Domain

Subdomains

Frequently Asked Questions

What does _should_stream() do?
_should_stream() is a function in the langchain codebase, defined in libs/partners/groq/langchain_groq/chat_models.py.
Where is _should_stream() defined?
_should_stream() is defined in libs/partners/groq/langchain_groq/chat_models.py at line 581.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free