
    f3fi                        d Z ddlmZmZmZmZ ddlmZmZ ddl	m
Z
  G d de      Z G d de      Zeez  Z	  G d	 d
e      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d d e      Z G d! d"e      Z G d# d$e      Zeez  ez  ez  ez  Z	 eez  ez  ez  ez  Zeez  ez  ez  ez  ez  Z	 h d%Z	 d&e e!d'f   fd(Z"d)e#d&e$fd*Z%d+d+d+d,d-e!d.e!d+z  d/e&e   d+z  d0e'e!z  d+z  d1ed&efd2Z(d+d+d+d+d+d+d3d4e!d+z  d5e!d+z  d6e!d+z  d7e!d+z  d.e!d+z  d0e'e!z  d+z  d1ed&efd8Z)d+d+d+d+d+d+d3d4e!d+z  d5e!d+z  d6e!d+z  d7e!d+z  d.e!d+z  d0e'e!z  d+z  d1ed&efd9Z*d+d+d+d+d+d+d3d4e!d+z  d5e!d+z  d6e!d+z  d7e!d+z  d.e!d+z  d0e'e!z  d+z  d1ed&efd:Z+d+d+d+d+d+d+d3d4e!d+z  d5e!d+z  d6e!d+z  d7e!d+z  d.e!d+z  d0e'e!z  d+z  d1ed&efd;Z,	 	 	 	 	 	 	 	 dLd-e!d+z  d4e!d+z  d5e!d+z  d6e!d+z  d<e!d+z  d=e!d+z  d.e!d+z  d0e'e!z  d+z  d1ed&efd>Z-d+d+d?d@e!dAe#e!ef   d.e!d+z  d0e'e!z  d+z  d1ed&efdBZ.	 	 	 dMdCe!d+z  d.e!d+z  d0e'e!z  d+z  d1ed&ef
dDZ/d+d+d+d+d+d+dEd4e!d+z  d<e!d+z  dFe'd+z  dGe'd+z  dHe!d+z  d.e!d+z  d1ed&efdIZ0d+d+d?dJe#e!ef   d.e!d+z  d0e'e!z  d+z  d&efdKZ1y+)Na|  Standard, multimodal content blocks for Large Language Model I/O.

This module provides standardized data structures for representing inputs to and outputs
from LLMs. The core abstraction is the **Content Block**, a `TypedDict`.

**Rationale**

Different LLM providers use distinct and incompatible API schemas. This module provides
a unified, provider-agnostic format to facilitate these interactions. A message to or
from a model is simply a list of content blocks, allowing for the natural interleaving
of text, images, and other content in a single ordered sequence.

An adapter for a specific provider is responsible for translating this standard list of
blocks into the format required by its API.

**Extensibility**

Data **not yet mapped** to a standard block may be represented using the
`NonStandardContentBlock`, which allows for provider-specific data to be included
without losing the benefits of type checking and validation.

Furthermore, provider-specific fields **within** a standard block are fully supported
by default in the `extras` field of each block. This allows for additional metadata
to be included without breaking the standard structure. For example, Google's thought
signature:

```python
AIMessage(
    content=[
        {
            "type": "text",
            "text": "J'adore la programmation.",
            "extras": {"signature": "EpoWCpc..."},  # Thought signature
        }
    ], ...
)
```


!!! note

    Following widespread adoption of [PEP 728](https://peps.python.org/pep-0728/), we
    intend to add `extra_items=Any` as a param to Content Blocks. This will signify to
    type checkers that additional provider-specific fields are allowed outside of the
    `extras` field, and that will become the new standard approach to adding
    provider-specific metadata.

    ??? note

        **Example with PEP 728 provider-specific fields:**

        ```python
        # Content block definition
        # NOTE: `extra_items=Any`
        class TextContentBlock(TypedDict, extra_items=Any):
            type: Literal["text"]
            id: NotRequired[str]
            text: str
            annotations: NotRequired[list[Annotation]]
            index: NotRequired[int]
        ```

        ```python
        from langchain_core.messages.content import TextContentBlock

        # Create a text content block with provider-specific fields
        my_block: TextContentBlock = {
            # Add required fields
            "type": "text",
            "text": "Hello, world!",
            # Additional fields not specified in the TypedDict
            # These are valid with PEP 728 and are typed as Any
            "openai_metadata": {"model": "gpt-4", "temperature": 0.7},
            "anthropic_usage": {"input_tokens": 10, "output_tokens": 20},
            "custom_field": "any value",
        }

        # Mutating an existing block to add provider-specific fields
        openai_data = my_block["openai_metadata"]  # Type: Any
        ```

**Example Usage**

```python
# Direct construction
from langchain_core.messages.content import TextContentBlock, ImageContentBlock

multimodal_message: AIMessage(
    content_blocks=[
        TextContentBlock(type="text", text="What is shown in this image?"),
        ImageContentBlock(
            type="image",
            url="https://www.langchain.com/images/brand/langchain_logo_text_w_white.png",
            mime_type="image/png",
        ),
    ]
)

# Using factories
from langchain_core.messages.content import create_text_block, create_image_block

multimodal_message: AIMessage(
    content=[
        create_text_block("What is shown in this image?"),
        create_image_block(
            url="https://www.langchain.com/images/brand/langchain_logo_text_w_white.png",
            mime_type="image/png",
        ),
    ]
)
```

Factory functions offer benefits such as:

- Automatic ID generation (when not provided)
- No need to manually specify the `type` field
    )AnyLiteralget_argsget_type_hints)NotRequired	TypedDict)	ensure_idc                       e Zd ZU dZed   ed<   	 ee   ed<   	 ee   ed<   	 ee   ed<   	 ee   ed<   	 ee   ed<   	 ee   ed	<   	 ee	ee
f      ed
<   y)Citationa  Annotation for citing data from a document.

    !!! note

        `start`/`end` indices refer to the **response text**,
        not the source text. This means that the indices are relative to the model's
        response, not the original document (as specified in the `url`).

    !!! note "Factory function"

        `create_citation` may also be used as a factory to create a `Citation`.
        Benefits include:

        * Automatic ID generation (when not provided)
        * Required arguments strictly validated at creation time
    citationtypeidurltitlestart_index	end_index
cited_textextrasN__name__
__module____qualname____doc__r   __annotations__r   strintdictr        ]/var/www/auto_recruiter/arenv/lib/python3.12/site-packages/langchain_core/messages/content.pyr   r   ~   s    " *
=C 
S	%s
 S!!I3FC  - S#X''%r   r   c                   J    e Zd ZU dZed   ed<   	 ee   ed<   	 eee	f   ed<   y)NonStandardAnnotationz$Provider-specific annotation format.non_standard_annotationr   r   valueN)
r   r   r   r   r   r   r   r   r   r   r   r   r    r"   r"      s7    .
+
,,=C S>,r   r"   c                       e Zd ZU dZed   ed<   	 ee   ed<   	 eed<   	 eee	      ed<   	 ee
ez     ed<   	 eeeef      ed<   y)	TextContentBlocka  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
    textr   r   annotationsindexr   N)r   r   r   r   r   r   r   r   list
Annotationr   r   r   r   r   r    r&   r&      sk     &/=C IT*-..,sSy!!FS#X''%r   r&   c                       e Zd ZU dZed   ed<   	 edz  ed<   	 eed<   	 eeef   ed<   	 e	e
ez     ed<   	 e	eeef      ed	<   y)
ToolCalla  Represents an AI's request to call a tool.

    Example:
        ```python
        {"name": "foo", "args": {"a": 1}, "id": "123"}
        ```

        This represents a request to call the tool named "foo" with arguments {"a": 1}
        and an identifier of "123".

    !!! note "Factory function"

        `create_tool_call` may also be used as a factory to create a
        `ToolCall`. Benefits include:

        * Automatic ID generation (when not provided)
        * Required arguments strictly validated at creation time
    	tool_callr   Nr   nameargsr)   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r-   r-      sh    & +
"d
N I,
sCx.)sSy!!FS#X''%r   r-   c                       e Zd ZU dZed   ed<   	 edz  ed<   	 edz  ed<   	 edz  ed<   	 eeez     ed<   	 ee	ee
f      ed	<   y)
ToolCallChunka  A chunk of a tool call (yielded when streaming).

    When merging `ToolCallChunks` (e.g., via `AIMessageChunk.__add__`),
    all string attributes are concatenated. Chunks are only merged if their
    values of `index` are equal and not `None`.

    Example:
    ```python
    left_chunks = [ToolCallChunk(name="foo", args='{"a":', index=0)]
    right_chunks = [ToolCallChunk(name=None, args="1}", index=0)]

    (
        AIMessageChunk(content="", tool_call_chunks=left_chunks)
        + AIMessageChunk(content="", tool_call_chunks=right_chunks)
    ).tool_call_chunks == [ToolCallChunk(name="foo", args='{"a":1}', index=0)]
    ```
    tool_call_chunkr   Nr   r/   r0   r)   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r3   r3   #  sj    ( #
$$!d
N *,
*)sSy!!3S#X''%r   r3   c                       e Zd ZU dZed   ed<   	 edz  ed<   	 edz  ed<   	 edz  ed<   	 edz  ed<   	 eeez     ed	<   	 ee	ee
f      ed
<   y)InvalidToolCallzAllowance for errors made by LLM.

    Here we add an `error` key to surface errors made during generation
    (e.g., invalid JSON arguments.)
    invalid_tool_callr   Nr   r/   r0   errorr)   r   r5   r   r   r    r7   r7   P  sw     %
&&"d
N *,
*):9sSy!!FS#X''%r   r7   c                       e Zd ZU dZed   ed<   	 eed<   	 eed<   	 eeef   ed<   	 e	e
ez     ed<   	 e	eeef      ed<   y	)
ServerToolCallz_Tool call that is executed server-side.

    For example: code execution, web search, etc.
    server_tool_callr   r   r/   r0   r)   r   Nr1   r   r   r    r;   r;   t  sa    
 $
%%"G6
I,
sCx.)sSy!!FS#X''%r   r;   c                       e Zd ZU dZed   ed<   	 ee   ed<   	 ee   ed<   	 ee   ed<   	 eeez     ed<   	 ee	ee
f      ed<   y	)
ServerToolCallChunkz<A chunk of a server-side tool call (yielded when streaming).server_tool_call_chunkr   r/   r0   r   r)   r   Nr   r   r   r    r>   r>     sj    F
*
++"
c
,
c
;C sSy!!FS#X''%r   r>   c                       e Zd ZU dZed   ed<   	 ee   ed<   	 eed<   	 ed   ed<   	 ee   ed<   	 ee	ez     ed	<   	 ee
eef      ed
<   y)ServerToolResultz"Result of a server-side tool call.server_tool_resultr   r   tool_call_id)successr9   statusoutputr)   r   N)r   r   r   r   r   r   r   r   r   r   r   r   r   r    rA   rA     st    ,
&
''"C 3&''3&sSy!!FS#X''%r   rA   c                   z    e Zd ZU dZed   ed<   	 ee   ed<   	 ee   ed<   	 eeez     ed<   	 ee	ee
f      ed<   y)ReasoningContentBlocka9  Reasoning output from a LLM.

    !!! note "Factory function"

        `create_reasoning_block` may also be used as a factory to create a
        `ReasoningContentBlock`. Benefits include:

        * Automatic ID generation (when not provided)
        * Required arguments strictly validated at creation time
    	reasoningr   r   r)   r   Nr   r   r   r    rH   rH     sc    	 +
=C 3 sSy!!FS#X''%r   rH   c                       e Zd ZU dZed   ed<   	 ee   ed<   	 ee   ed<   	 ee   ed<   	 eeez     ed<   	 ee   ed<   	 ee   ed	<   	 ee	ee
f      ed
<   y)ImageContentBlocka!  Image data.

    !!! note "Factory function"

        `create_image_block` may also be used as a factory to create an
        `ImageContentBlock`. Benefits include:

        * Automatic ID generation (when not provided)
        * Required arguments strictly validated at creation time
    imager   r   file_id	mime_typer)   r   base64r   Nr   r   r   r    rK   rK         	 '
=C 
 3 sSy!!F	S	"S#X''Wr   rK   c                       e Zd ZU dZed   ed<   	 ee   ed<   	 ee   ed<   	 ee   ed<   	 eeez     ed<   	 ee   ed<   	 ee   ed	<   	 ee	ee
f      ed
<   y)VideoContentBlocka   Video data.

    !!! note "Factory function"

        `create_video_block` may also be used as a factory to create a
        `VideoContentBlock`. Benefits include:

        * Automatic ID generation (when not provided)
        * Required arguments strictly validated at creation time
    videor   r   rM   rN   r)   r   rO   r   Nr   r   r   r    rR   rR   $  rP   r   rR   c                       e Zd ZU dZed   ed<   	 ee   ed<   	 ee   ed<   	 ee   ed<   	 eeez     ed<   	 ee   ed<   	 ee   ed	<   	 ee	ee
f      ed
<   y)AudioContentBlocka!  Audio data.

    !!! note "Factory function"

        `create_audio_block` may also be used as a factory to create an
        `AudioContentBlock`. Benefits include:

        * Automatic ID generation (when not provided)
        * Required arguments strictly validated at creation time
    audior   r   rM   rN   r)   r   rO   r   Nr   r   r   r    rU   rU   W  rP   r   rU   c                       e Zd ZU dZed   ed<   	 ee   ed<   	 ee   ed<   	 ed   ed<   	 eeez     ed<   	 ee   ed	<   	 ee   ed
<   	 ee   ed<   	 ee   ed<   	 ee   ed<   	 ee	ee
f      ed<   y)PlainTextContentBlocka~  Plaintext data (e.g., from a `.txt` or `.md` document).

    !!! note

        A `PlainTextContentBlock` existed in `langchain-core<1.0.0`. Although the
        name has carried over, the structure has changed significantly. The only shared
        keys between the old and new versions are `type` and `text`, though the
        `type` value has changed from `'text'` to `'text-plain'`.

    !!! note

        Title and context are optional fields that may be passed to the model. See
        Anthropic [example](https://platform.claude.com/docs/en/build-with-claude/citations#citable-vs-non-citable-content).

    !!! note "Factory function"

        `create_plaintext_block` may also be used as a factory to create a
        `PlainTextContentBlock`. Benefits include:

        * Automatic ID generation (when not provided)
        * Required arguments strictly validated at creation time
    
text-plainr   r   rM   
text/plainrN   r)   r   rO   r'   r   contextr   Nr   r   r   r    rX   rX     s    . ,
=C 
 |$$
 sSy!!F	S	"
c
Ps@US#X''Qr   rX   c                       e Zd ZU dZed   ed<   	 ee   ed<   	 ee   ed<   	 ee   ed<   	 eeez     ed<   	 ee   ed<   	 ee   ed	<   	 ee	ee
f      ed
<   y)FileContentBlocka  File data that doesn't fit into other multimodal block types.

    This block is intended for files that are not images, audio, or plaintext. For
    example, it can be used for PDFs, Word documents, etc.

    If the file is an image, audio, or plaintext, you should use the corresponding
    content block type (e.g., `ImageContentBlock`, `AudioContentBlock`,
    `PlainTextContentBlock`).

    !!! note "Factory function"

        `create_file_block` may also be used as a factory to create a
        `FileContentBlock`. Benefits include:

        * Automatic ID generation (when not provided)
        * Required arguments strictly validated at creation time
    filer   r   rM   rN   r)   r   rO   r   Nr   r   r   r    r]   r]     s    $ &/=C  3 sSy!!F	S	"S#X''Vr   r]   c                   b    e Zd ZU dZed   ed<   	 ee   ed<   	 eee	f   ed<   	 ee
ez     ed<   y)NonStandardContentBlocka  Provider-specific content data.

    This block contains data for which there is not yet a standard type.

    The purpose of this block should be to simply hold a provider-specific payload.
    If a provider's non-standard output includes reasoning and tool calls, it should be
    the adapter's job to parse that payload and emit the corresponding standard
    `ReasoningContentBlock` and `ToolCalls`.

    Has no `extras` field, as provider-specific data should be included in the
    `value` field.

    !!! note "Factory function"

        `create_non_standard_block` may also be used as a factory to create a
        `NonStandardContentBlock`. Benefits include:

        * Automatic ID generation (when not provided)
        * Required arguments strictly validated at creation time
    non_standardr   r   r$   r)   N)r   r   r   r   r   r   r   r   r   r   r   r   r   r    r`   r`     sL    * .
!!=C S>)sSy!!Fr   r`   >   r^   r'   rV   rL   rS   rI   r.   ra   r4   r<   r8   rB   r?   rY   return.c                      g } t        t              D ]D  }t        |      }d|v s|d   }t        |d      s%|j                  d   }| j                  |       F t        |       S )a`  Get type literals from DataContentBlock union members dynamically.

    Example: ("image", "video", "audio", "text-plain", "file")

    Note that old style multimodal blocks type literals with new style blocks.
    Specifically, "image", "audio", and "file".

    See the docstring of `_normalize_messages` in `language_models._utils` for details.
    r   __args__r   )r   DataContentBlockr   hasattrrd   appendtuple)data_block_types
block_typehintstype_annotationliteral_values        r    _get_data_content_block_typesrn   s  so     /0 7
z*U?#FmO
3 / 8 8 ; ''67 !""r   blockc                       j                  d      t               vryt         fddD              r d   dk(  rd vryyd v r+ d   }|dk(  rd v s	|d	k(  rd
 v ry|dk(  rd v s	|dk(  rd v ryy)a*  Check if the provided content block is a data content block.

    Returns True for both v0 (old-style) and v1 (new-style) multimodal data blocks.

    Args:
        block: The content block to check.

    Returns:
        `True` if the content block is a data content block, `False` otherwise.
    r   Fc              3   &   K   | ]  }|v  
 y w)Nr   ).0keyro   s     r    	<genexpr>z(is_data_content_block.<locals>.<genexpr>  s     
HC3%<
Hs   )r   rO   rM   r'   r'   source_typeTr   rO   datar   )getrn   any)ro   ru   s   ` r    is_data_content_blockry     s     yy = ??

H#G
HH =F"}E'A M*5 Ue^8#%4DEM6!eunr   N)r   r(   r)   r'   r   r(   r)   kwargsc                    t        d| t        |            }|||d<   |||d<   |j                         D ci c]  \  }}|	|| }}}|r||d<   |S c c}}w )a=  Create a `TextContentBlock`.

    Args:
        text: The text content of the block.
        id: Content block identifier.

            Generated automatically if not provided.
        annotations: `Citation`s and other annotations for the text.
        index: Index of block in aggregate response.

            Used during streaming.

    Returns:
        A properly formatted `TextContentBlock`.

    !!! note

        The `id` is generated automatically if not provided, using a UUID4 format
        prefixed with `'lc_'` to indicate it is a LangChain-generated ID.
    r'   )r   r'   r   r(   r)   r   )r&   r	   items)	r'   r   r(   r)   rz   ro   kvr   s	            r    create_text_blockr     sx    8 R=E
 *mg%||~?tq!ad?F? hL	 @s   
AA)r   rO   rM   rN   r   r)   r   rO   rM   rN   c                    t        | ||g      sd}t        |      t        dt        |            }| | |d<   |||d<   |||d<   |||d<   |||d<   |j	                         D 	
ci c]  \  }	}
|
	|	|
 }}	}
|r||d	<   |S c c}
}	w )
a$  Create an `ImageContentBlock`.

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

            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 `ImageContentBlock`.

    Raises:
        ValueError: If no image 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.
    ,Must provide one of: url, base64, or file_idrL   r   r   r   rO   rM   rN   r)   r   )rx   
ValueErrorrK   r	   r|   r   rO   rM   rN   r   r)   rz   msgro   r}   r~   r   s               r    create_image_blockr     s    L VW%&<o7y}=E
e h"i&kg%||~?tq!ad?F? hL	 @s   (
B3Bc                 6   t        | ||g      sd}t        |      |r|sd}t        |      t        dt        |            }| | |d<   |||d<   |||d<   |||d<   |||d	<   |j	                         D 	
ci c]  \  }	}
|
	|	|
 }}	}
|r||d
<   |S c c}
}	w )a#  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.
    r   ,mime_type is required when using base64 datarS   r   r   rO   rM   rN   r)   r   )rx   r   rR   r	   r|   r   s               r    create_video_blockr          L VW%&<oi<o7y}=E
e h"i&kg%||~?tq!ad?F? hL	 @   9
BBc                 6   t        | ||g      sd}t        |      |r|sd}t        |      t        dt        |            }| | |d<   |||d<   |||d<   |||d<   |||d	<   |j	                         D 	
ci c]  \  }	}
|
	|	|
 }}	}
|r||d
<   |S c c}
}	w )a$  Create an `AudioContentBlock`.

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

            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 `AudioContentBlock`.

    Raises:
        ValueError: If no audio 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.
    r   r   rV   r   r   rO   rM   rN   r)   r   )rx   r   rU   r	   r|   r   s               r    create_audio_blockr   b  r   r   c                 6   t        | ||g      sd}t        |      |r|sd}t        |      t        dt        |            }| | |d<   |||d<   |||d<   |||d<   |||d	<   |j	                         D 	
ci c]  \  }	}
|
	|	|
 }}	}
|r||d
<   |S c c}
}	w )a  Create a `FileContentBlock`.

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

            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 `FileContentBlock`.

    Raises:
        ValueError: If no file 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.
    r   r   r^   r   r   rO   rM   rN   r)   r   )rx   r   r]   r	   r|   r   s               r    create_file_blockr     s    L VW%&<oi<o&Yr];E
e h"i&kg%||~?tq!ad?F? hL	 @r   r   r[   c                     t        ddt        |            }	| | |	d<   |||	d<   |||	d<   |||	d<   |||	d<   |||	d	<   |||	d
<   |j                         D 
ci c]  \  }
}|	|
| }}
}|r||	d<   |	S c c}}
w )a  Create a `PlainTextContentBlock`.

    Args:
        text: The plaintext content.
        url: URL of the plaintext file.
        base64: Base64-encoded plaintext data.
        file_id: ID of the plaintext file from a file storage system.
        title: Title of the text data.
        context: Context or description of the text content.
        id: Content block identifier.

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

            Used during streaming.

    Returns:
        A properly formatted `PlainTextContentBlock`.

    !!! note

        The `id` is generated automatically if not provided, using a UUID4 format
        prefixed with `'lc_'` to indicate it is a LangChain-generated ID.
    rY   rZ   )r   rN   r   r'   r   rO   rM   r   r[   r)   r   )rX   r	   r|   )r'   r   rO   rM   r   r[   r   r)   rz   ro   r}   r~   r   s                r    create_plaintext_blockr     s    F "R=E f
e h"ig"ig%||~?tq!ad?F? hL	 @s   
A8'A8)r   r)   r/   r0   c                    t        d| |t        |            }|||d<   |j                         D ci c]  \  }}|	|| }}}|r||d<   |S c c}}w )a!  Create a `ToolCall`.

    Args:
        name: The name of the tool to be called.
        args: The arguments to the tool call.
        id: An identifier for the tool call.

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

            Used during streaming.

    Returns:
        A properly formatted `ToolCall`.

    !!! note

        The `id` is generated automatically if not provided, using a UUID4 format
        prefixed with `'lc_'` to indicate it is a LangChain-generated ID.
    r.   )r   r/   r0   r   r)   r   )r-   r	   r|   )	r/   r0   r   r)   rz   ro   r}   r~   r   s	            r    create_tool_callr   %  sk    8 R=	E g%||~?tq!ad?F? hL	 @s
   
AArI   c                     t        d| xs dt        |            }|||d<   |j                         D ci c]  \  }}|	|| }}}|r||d<   |S c c}}w )a  Create a `ReasoningContentBlock`.

    Args:
        reasoning: The reasoning text or thought summary.
        id: Content block identifier.

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

            Used during streaming.

    Returns:
        A properly formatted `ReasoningContentBlock`.

    !!! note

        The `id` is generated automatically if not provided, using a UUID4 format
        prefixed with `'lc_'` to indicate it is a LangChain-generated ID.
    rI    )r   rI   r   r)   r   )rH   r	   r|   )rI   r   r)   rz   ro   r}   r~   r   s           r    create_reasoning_blockr   R  sl    2 "/rR=E g%||~?tq!ad?F? hL	 @s   
AA)r   r   r   r   r   r   r   r   r   c                     t        dt        |            }| | |d<   |||d<   |||d<   |||d<   |||d<   |j                         D 	ci c]  \  }}	|		||	 }
}}	|
r|
|d<   |S c c}	}w )	a  Create a `Citation`.

    Args:
        url: URL of the document source.
        title: Source document title.
        start_index: Start index in the response text where citation applies.
        end_index: End index in the response text where citation applies.
        cited_text: Excerpt of source text being cited.
        id: Content block identifier.

            Generated automatically if not provided.

    Returns:
        A properly formatted `Citation`.

    !!! note

        The `id` is generated automatically if not provided, using a UUID4 format
        prefixed with `'lc_'` to indicate it is a LangChain-generated ID.
    r   r   r   r   r   r   r   r   )r   r	   r|   )r   r   r   r   r   r   rz   ro   r}   r~   r   s              r    create_citationr   {  s    < *27E
eg*m&k(l%||~?tq!ad?F? hL	 @s   
A)A)r$   c                B    t        d| t        |            }|||d<   |S )a  Create a `NonStandardContentBlock`.

    Args:
        value: Provider-specific content data.
        id: Content block identifier.

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

            Used during streaming.

    Returns:
        A properly formatted `NonStandardContentBlock`.

    !!! note

        The `id` is generated automatically if not provided, using a UUID4 format
        prefixed with `'lc_'` to indicate it is a LangChain-generated ID.
    ra   )r   r$   r   r)   )r`   r	   )r$   r   r)   ro   s       r    create_non_standard_blockr     s1    2 $R=E gLr   )NNNNNNNN)NNN)2r   typingr   r   r   r   typing_extensionsr   r   langchain_core.utils.utilsr	   r   r"   r+   r&   r-   r3   r7   r;   r>   rA   rH   rK   rR   rU   rX   r]   r`   re   ToolContentBlockContentBlockKNOWN_BLOCK_TYPESrh   r   rn   r   boolry   r*   r   r   r   r   r   r   r   r   r   r   r   r   r   r    <module>r      sX  tl : 9 4 07&y 7&t-I -& --
 0%&y %&P)&y )&X*&I *&Z!&i !&H&Y &2&) &8&y &>#&I #&R0X	 0Xf0X	 0Xf0X	 0XfCRI CRL=Wy =WJ&Gi &GV   	  C }~-0CCFVV 
   	
   ? ,#uS#X #0' '$ 'Z +/"*
* 	d
* j!D(	*
 9t* * *^  ";	t; $J; 4Z	;
 Tz; 	d
; 9t; ; ;@  "?	t? $J? 4Z	?
 Tz? 	d
? 9t? ? ?H  "?	t? $J? 4Z	?
 Tz? 	d
? 9t? ? ?H  "?	t? $J? 4Z	?
 Tz? 	d
? 9t? ? ?F "<
*<	t< $J< 4Z	<
 :< 4Z< 	d
< 9t< < <F "*
*
sCx.* 	d
	*
 9t* * *\ !"&Tz&d
& 9t& 	&
 &V " !/	t/ :/ t	/
 Tz/ d
/ 	d
/ / /j "	"S>" 	d
" 9t	"
 "r   