Home / Function/ create_video_block() — langchain Function Reference

create_video_block() — langchain Function Reference

Architecture documentation for the create_video_block() function in content.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  b4fec61e_abfe_b5f0_a973_31f567ef70c8["create_video_block()"]
  c7f11daf_e104_efbe_7225_f1d6da8e8630["content.py"]
  b4fec61e_abfe_b5f0_a973_31f567ef70c8 -->|defined in| c7f11daf_e104_efbe_7225_f1d6da8e8630
  style b4fec61e_abfe_b5f0_a973_31f567ef70c8 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/langchain_core/messages/content.py lines 1057–1120

def create_video_block(
    *,
    url: str | None = None,
    base64: str | None = None,
    file_id: str | None = None,
    mime_type: str | None = None,
    id: str | None = None,
    index: int | str | None = None,
    **kwargs: Any,
) -> VideoContentBlock:
    """Create a `VideoContentBlock`.

    Args:
        url: URL of the video.
        base64: Base64-encoded video data.
        file_id: ID of the video file from a file storage system.
        mime_type: MIME type of the video.

            Required for base64 data.
        id: Content block identifier.

            Generated automatically if not provided.
        index: Index of block in aggregate response.

            Used during streaming.

    Returns:
        A properly formatted `VideoContentBlock`.

    Raises:
        ValueError: If no video source is provided or if `base64` is used without
            `mime_type`.

    !!! note

        The `id` is generated automatically if not provided, using a UUID4 format
        prefixed with `'lc_'` to indicate it is a LangChain-generated ID.
    """
    if not any([url, base64, file_id]):
        msg = "Must provide one of: url, base64, or file_id"
        raise ValueError(msg)

    if base64 and not mime_type:
        msg = "mime_type is required when using base64 data"
        raise ValueError(msg)

    block = VideoContentBlock(type="video", id=ensure_id(id))

    if url is not None:
        block["url"] = url
    if base64 is not None:
        block["base64"] = base64
    if file_id is not None:
        block["file_id"] = file_id
    if mime_type is not None:
        block["mime_type"] = mime_type
    if index is not None:
        block["index"] = index

    extras = {k: v for k, v in kwargs.items() if v is not None}
    if extras:
        block["extras"] = extras

    return block

Domain

Subdomains

Frequently Asked Questions

What does create_video_block() do?
create_video_block() is a function in the langchain codebase, defined in libs/core/langchain_core/messages/content.py.
Where is create_video_block() defined?
create_video_block() is defined in libs/core/langchain_core/messages/content.py at line 1057.

Analyze Your Own Codebase

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

Try Supermodel Free