# 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 .agent_chat_stream_event_type import AgentChatStreamEventType


class AgentChatStreamEvent(UniversalBaseModel):
    """
    JSON payload sent in the `data:` line of a Server-Sent Event (SSE) frame for streaming chat responses.
    Each SSE frame uses the standard `event:` and `data:` lines; this schema describes the JSON object
    in the `data:` line. The event type is encoded in the top-level `type` property.
    Event types: message_start, content_delta, tool_use, tool_result, message_end, error.
    """

    type: typing.Optional[AgentChatStreamEventType] = pydantic.Field(default=None)
    """
    The event type
    """

    session_id: typing.Optional[str] = pydantic.Field(default=None)
    """
    Chat session ID
    """

    content: typing.Optional[str] = pydantic.Field(default=None)
    """
    Incremental text content (present in content_delta events)
    """

    success: typing.Optional[bool] = pydantic.Field(default=None)
    """
    Whether the operation was successful
    """

    message: typing.Optional[str] = pydantic.Field(default=None)
    """
    Status message
    """

    function_name: typing.Optional[str] = pydantic.Field(default=None)
    """
    Tool/function name (present in tool_use and tool_result events)
    """

    function_args: typing.Optional[typing.Dict[str, typing.Any]] = pydantic.Field(default=None)
    """
    Tool arguments (present in tool_use events)
    """

    function_result: typing.Optional[typing.Dict[str, typing.Any]] = pydantic.Field(default=None)
    """
    Tool execution result (present in tool_result events)
    """

    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
