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

import datetime as dt
import typing

import pydantic
from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
from .agent_session_key import AgentSessionKey
from .artifact_reference import ArtifactReference


class ArtifactUploadEvent(UniversalBaseModel):
    """
    Event representing files uploaded to the agent workspace as artifacts.

    This event is created when users upload one or more files to an agent session using multipart requests. The event becomes part of the session's conversation history and contains references to all artifacts that were uploaded in the request. Each uploaded file is assigned a unique artifact identifier and stored in the session's workspace.

    When an agent processes this event, it becomes aware that new files are available in the session and can use various tools to read, analyze, or transform these artifacts. For example, after receiving an artifact upload event with a PDF, the agent might use the document conversion tool to extract and analyze the document's contents.

    See the `ArtifactReference` schema for comprehensive details about what artifacts are, how they are stored, their lifecycle, and how agents interact with them.
    """

    id: str = pydantic.Field()
    """
    The unique identifier for the event.
    """

    session_key: AgentSessionKey = pydantic.Field()
    """
    The key of the session this event belongs to.
    """

    type: typing.Literal["artifact_upload"] = "artifact_upload"
    artifacts: typing.List[ArtifactReference] = pydantic.Field()
    """
    References to uploaded artifacts
    """

    created_at: dt.datetime = pydantic.Field()
    """
    Timestamp when the event was created.
    """

    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
