_chat_stream_with_aggregation() — langchain Function Reference
Architecture documentation for the _chat_stream_with_aggregation() function in chat_models.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD a9bec111_57fc_1b0b_ba6f_432ebeb29556["_chat_stream_with_aggregation()"] 19e4be00_71fb_5390_6768_f6e6158f49b4["ChatOllama"] a9bec111_57fc_1b0b_ba6f_432ebeb29556 -->|defined in| 19e4be00_71fb_5390_6768_f6e6158f49b4 907cc29e_96a8_c0ba_194e_95ac0fa628fb["_generate()"] 907cc29e_96a8_c0ba_194e_95ac0fa628fb -->|calls| a9bec111_57fc_1b0b_ba6f_432ebeb29556 3b4a8d88_e271_d530_a2cc_d47df386a668["_iterate_over_stream()"] a9bec111_57fc_1b0b_ba6f_432ebeb29556 -->|calls| 3b4a8d88_e271_d530_a2cc_d47df386a668 style a9bec111_57fc_1b0b_ba6f_432ebeb29556 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/partners/ollama/langchain_ollama/chat_models.py lines 959–983
def _chat_stream_with_aggregation(
self,
messages: list[BaseMessage],
stop: list[str] | None = None,
run_manager: CallbackManagerForLLMRun | None = None,
verbose: bool = False, # noqa: FBT002
**kwargs: Any,
) -> ChatGenerationChunk:
final_chunk = None
for chunk in self._iterate_over_stream(messages, stop, **kwargs):
if final_chunk is None:
final_chunk = chunk
else:
final_chunk += chunk
if run_manager:
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
Calls
Called By
Source
Frequently Asked Questions
What does _chat_stream_with_aggregation() do?
_chat_stream_with_aggregation() is a function in the langchain codebase, defined in libs/partners/ollama/langchain_ollama/chat_models.py.
Where is _chat_stream_with_aggregation() defined?
_chat_stream_with_aggregation() is defined in libs/partners/ollama/langchain_ollama/chat_models.py at line 959.
What does _chat_stream_with_aggregation() call?
_chat_stream_with_aggregation() calls 1 function(s): _iterate_over_stream.
What calls _chat_stream_with_aggregation()?
_chat_stream_with_aggregation() is called by 1 function(s): _generate.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free