Home / Function/ _stream() — langchain Function Reference

_stream() — langchain Function Reference

Architecture documentation for the _stream() function in test_base.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  0cde1f99_9131_e33d_43b3_4c705000e434["_stream()"]
  8ea7f6d9_a8b2_f386_2f14_d177fd70e5b2["ModelWithSyncStream"]
  0cde1f99_9131_e33d_43b3_4c705000e434 -->|defined in| 8ea7f6d9_a8b2_f386_2f14_d177fd70e5b2
  e786625b_2e9d_16b6_815a_e49f305aa644["test_astream_implementation_fallback_to_stream()"]
  e786625b_2e9d_16b6_815a_e49f305aa644 -->|calls| 0cde1f99_9131_e33d_43b3_4c705000e434
  c2aa9f76_ba04_7686_5375_7926aadc7064["test_get_ls_params()"]
  c2aa9f76_ba04_7686_5375_7926aadc7064 -->|calls| 0cde1f99_9131_e33d_43b3_4c705000e434
  style 0cde1f99_9131_e33d_43b3_4c705000e434 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/tests/unit_tests/language_models/chat_models/test_base.py lines 232–243

        def _stream(
            self,
            messages: list[BaseMessage],
            stop: list[str] | None = None,
            run_manager: CallbackManagerForLLMRun | None = None,
            **kwargs: Any,
        ) -> Iterator[ChatGenerationChunk]:
            """Stream the output of the model."""
            yield ChatGenerationChunk(message=AIMessageChunk(content="a"))
            yield ChatGenerationChunk(
                message=AIMessageChunk(content="b", chunk_position="last")
            )

Domain

Subdomains

Frequently Asked Questions

What does _stream() do?
_stream() is a function in the langchain codebase, defined in libs/core/tests/unit_tests/language_models/chat_models/test_base.py.
Where is _stream() defined?
_stream() is defined in libs/core/tests/unit_tests/language_models/chat_models/test_base.py at line 232.
What calls _stream()?
_stream() is called by 2 function(s): test_astream_implementation_fallback_to_stream, test_get_ls_params.

Analyze Your Own Codebase

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

Try Supermodel Free