LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
  • Overview
    • Overview
    • Caches
    • Callbacks
    • Documents
    • Document loaders
    • Embeddings
    • Exceptions
    • Language models
    • Serialization
    • Output parsers
    • Prompts
    • Rate limiters
    • Retrievers
    • Runnables
    • Utilities
    • Vector stores
    MCP Adapters
    Standard Tests
    Text Splitters
    ⌘I

    LangChain Assistant

    Ask a question to get started

    Enter to send•Shift+Enter new line

    Menu

    OverviewCachesCallbacksDocumentsDocument loadersEmbeddingsExceptionsLanguage modelsSerializationOutput parsersPromptsRate limitersRetrieversRunnablesUtilitiesVector stores
    MCP Adapters
    Standard Tests
    Text Splitters
    Language
    Theme
    Pythonlangchain-corelanguage_models_compat_bridgechunks_to_events
    Functionā—Since v1.3

    chunks_to_events

    Copy
    chunks_to_events(
      chunks: Iterator[ChatGenerationChunk],
      *,
      message_id: str | None = None
    View source on GitHub
    )
    ->
    Iterator
    [
    MessagesData
    ]

    Parameters

    NameTypeDescription
    chunks*Iterator[ChatGenerationChunk]
    message_idstr | None
    Default:None

    Convert a stream of ChatGenerationChunk to protocol events.

    Blocks stream one at a time: when a chunk carries a different block identifier than the currently-open one, the open block is finished before the new block starts, matching the protocol's no-interleave rule. Source-side identifiers (from the block's index field, which may be int or string) are translated to sequential uint wire indices.

    Iterator of ChatGenerationChunk from _stream().

    Optional stable message ID.