LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
  • Overview
    • Overview
    • Graphs
    • Functional API
    • Pregel
    • Checkpointing
    • Storage
    • Caching
    • Types
    • Runtime
    • Config
    • Errors
    • Constants
    • Channels
    • Agents
    LangGraph CLI
    LangGraph SDK
    LangGraph Supervisor
    LangGraph Swarm
    ⌘I

    LangChain Assistant

    Ask a question to get started

    Enter to send•Shift+Enter new line

    Menu

    OverviewGraphsFunctional APIPregelCheckpointingStorageCachingTypesRuntimeConfigErrorsConstantsChannelsAgents
    LangGraph CLI
    LangGraph SDK
    LangGraph Supervisor
    LangGraph Swarm
    Language
    Theme
    PythonlanggraphtypesStreamPart
    Attribute●Since v1.1

    StreamPart

    A discriminated union of all v2 stream part types.

    Use part["type"] to narrow the type:

    async for part in graph.astream(input, version="v2"):
        if part["type"] == "values":
            part["data"]  # OutputT — full state (pydantic/dataclass/dict)
        elif part["type"] == "messages":
            part["data"]  # tuple[BaseMessage, dict] — (message, metadata)
        elif part["type"] == "custom":
            part["data"]  # Any — user-defined
    Copy
    StreamPart = TypeAliasType(
      'StreamPart',
      ValuesStreamPart[OutputT] | UpdatesStreamPart | MessagesStreamPart | CustomStreamPart | CheckpointStreamPart[StateT] | TasksStreamPart | DebugStreamPart[StateT],
      type_params=(StateT, OutputT)
    )
    View source on GitHub