# This file was auto-generated by Fern from our API Definition.

import typing

import pydantic
from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
from .file_reference import FileReference
from .input_message_content import InputMessageContent


class InputMessage(UniversalBaseModel):
    """
    Input message with role and content.

    Content can be either:
    - Simple string (convenience)
    - Array of ContentBlock objects (structured)

    Files can be referenced via:
    - files[] array (recommended for multiple files)
    - ContentBlock with type='file' (alternative)
    """

    role: str = pydantic.Field()
    """
    Message role: 'user', 'assistant', 'system', or 'tool'
    """

    content: InputMessageContent = pydantic.Field()
    """
    Message content as text blocks array, string, or JSON object (for tool results). Content blocks can include text ({type: 'text', text: '...'}), file references ({type: 'file', file_id: '...'}), or image data in various formats.
    """

    files: typing.Optional[typing.List[FileReference]] = pydantic.Field(default=None)
    """
    Array of file references for context retrieval. Each file reference contains only file_id. Relevant chunks from these files will be injected into the conversation.
    """

    id: typing.Optional[str] = pydantic.Field(default=None)
    """
    Unique ID of the input message. Populated when items are returned via API.
    """

    tool_call_id: typing.Optional[str] = pydantic.Field(default=None)
    """
    Tool call ID for tool result messages. Required when role='tool'.
    """

    if IS_PYDANTIC_V2:
        model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True)  # type: ignore # Pydantic v2
    else:

        class Config:
            frozen = True
            smart_union = True
            extra = pydantic.Extra.allow
