Home / Class/ TextContentBlock Class — langchain Architecture

TextContentBlock Class — langchain Architecture

Architecture documentation for the TextContentBlock class in content.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  a5e9b60b_d93c_c544_eef5_ee8808a56aec["TextContentBlock"]
  c7f11daf_e104_efbe_7225_f1d6da8e8630["content.py"]
  a5e9b60b_d93c_c544_eef5_ee8808a56aec -->|defined in| c7f11daf_e104_efbe_7225_f1d6da8e8630

Relationship Graph

Source Code

libs/core/langchain_core/messages/content.py lines 207–244

class TextContentBlock(TypedDict):
    """Text output from a LLM.

    This typically represents the main text content of a message, such as the response
    from a language model or the text of a user message.

    !!! note "Factory function"

        `create_text_block` may also be used as a factory to create a
        `TextContentBlock`. Benefits include:

        * Automatic ID generation (when not provided)
        * Required arguments strictly validated at creation time
    """

    type: Literal["text"]
    """Type of the content block. Used for discrimination."""

    id: NotRequired[str]
    """Unique identifier for this content block.

    Either:

    - Generated by the provider
    - Generated by LangChain upon creation (`UUID4` prefixed with `'lc_'`))
    """

    text: str
    """Block text."""

    annotations: NotRequired[list[Annotation]]
    """`Citation`s and other annotations."""

    index: NotRequired[int | str]
    """Index of block in aggregate response. Used during streaming."""

    extras: NotRequired[dict[str, Any]]
    """Provider-specific metadata."""

Frequently Asked Questions

What is the TextContentBlock class?
TextContentBlock is a class in the langchain codebase, defined in libs/core/langchain_core/messages/content.py.
Where is TextContentBlock defined?
TextContentBlock is defined in libs/core/langchain_core/messages/content.py at line 207.

Analyze Your Own Codebase

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

Try Supermodel Free