Home / Function/ _achat_stream_with_aggregation() — langchain Function Reference

_achat_stream_with_aggregation() — langchain Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  2e66c349_d5d3_62e8_92b6_0bc2344b7f7b["_achat_stream_with_aggregation()"]
  19e4be00_71fb_5390_6768_f6e6158f49b4["ChatOllama"]
  2e66c349_d5d3_62e8_92b6_0bc2344b7f7b -->|defined in| 19e4be00_71fb_5390_6768_f6e6158f49b4
  c693a2d2_0366_3ee6_c134_76b810abb28a["_agenerate()"]
  c693a2d2_0366_3ee6_c134_76b810abb28a -->|calls| 2e66c349_d5d3_62e8_92b6_0bc2344b7f7b
  99d71779_02a3_5ac1_9f57_f8b40ddef80e["_aiterate_over_stream()"]
  2e66c349_d5d3_62e8_92b6_0bc2344b7f7b -->|calls| 99d71779_02a3_5ac1_9f57_f8b40ddef80e
  style 2e66c349_d5d3_62e8_92b6_0bc2344b7f7b fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/partners/ollama/langchain_ollama/chat_models.py lines 985–1009

    async def _achat_stream_with_aggregation(
        self,
        messages: list[BaseMessage],
        stop: list[str] | None = None,
        run_manager: AsyncCallbackManagerForLLMRun | None = None,
        verbose: bool = False,  # noqa: FBT002
        **kwargs: Any,
    ) -> ChatGenerationChunk:
        final_chunk = None
        async for chunk in self._aiterate_over_stream(messages, stop, **kwargs):
            if final_chunk is None:
                final_chunk = chunk
            else:
                final_chunk += chunk
            if run_manager:
                await run_manager.on_llm_new_token(
                    chunk.text,
                    chunk=chunk,
                    verbose=verbose,
                )
        if final_chunk is None:
            msg = "No data received from Ollama stream."
            raise ValueError(msg)

        return final_chunk

Domain

Subdomains

Called By

Frequently Asked Questions

What does _achat_stream_with_aggregation() do?
_achat_stream_with_aggregation() is a function in the langchain codebase, defined in libs/partners/ollama/langchain_ollama/chat_models.py.
Where is _achat_stream_with_aggregation() defined?
_achat_stream_with_aggregation() is defined in libs/partners/ollama/langchain_ollama/chat_models.py at line 985.
What does _achat_stream_with_aggregation() call?
_achat_stream_with_aggregation() calls 1 function(s): _aiterate_over_stream.
What calls _achat_stream_with_aggregation()?
_achat_stream_with_aggregation() is called by 1 function(s): _agenerate.

Analyze Your Own Codebase

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

Try Supermodel Free