# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from __future__ import annotations

from typing import Union, Iterable
from typing_extensions import Literal, Required, TypeAlias, TypedDict

__all__ = [
    "ChatMessageParam",
    "ContentContentPartArray",
    "ContentContentPartArrayContentPartText",
    "ContentContentPartArrayContentPartImageURL",
    "ContentContentPartArrayContentPartImageURLImageURL",
    "ContentContentPartArrayContentPartInputAudio",
    "ContentContentPartArrayContentPartInputAudioInputAudio",
    "ContentContentPartArrayContentPartFile",
    "ContentContentPartArrayContentPartFileFile",
    "ContentContentPartArrayContentPartRefusal",
    "ToolCall",
    "ToolCallFunction",
]


class ContentContentPartArrayContentPartText(TypedDict, total=False):
    text: Required[str]

    type: Required[Literal["text"]]


class ContentContentPartArrayContentPartImageURLImageURL(TypedDict, total=False):
    url: Required[str]
    """URL or base64 image data"""

    detail: Literal["auto", "low", "high"]


class ContentContentPartArrayContentPartImageURL(TypedDict, total=False):
    image_url: Required[ContentContentPartArrayContentPartImageURLImageURL]

    type: Required[Literal["image_url"]]


class ContentContentPartArrayContentPartInputAudioInputAudio(TypedDict, total=False):
    data: Required[str]
    """Base64 encoded audio data"""

    format: Required[Literal["wav", "mp3"]]


class ContentContentPartArrayContentPartInputAudio(TypedDict, total=False):
    input_audio: Required[ContentContentPartArrayContentPartInputAudioInputAudio]

    type: Required[Literal["input_audio"]]


class ContentContentPartArrayContentPartFileFile(TypedDict, total=False):
    file_data: str
    """Base64 encoded file data"""

    file_id: str

    filename: str


class ContentContentPartArrayContentPartFile(TypedDict, total=False):
    file: Required[ContentContentPartArrayContentPartFileFile]

    type: Required[Literal["file"]]


class ContentContentPartArrayContentPartRefusal(TypedDict, total=False):
    refusal: Required[str]

    type: Required[Literal["refusal"]]


ContentContentPartArray: TypeAlias = Union[
    ContentContentPartArrayContentPartText,
    ContentContentPartArrayContentPartImageURL,
    ContentContentPartArrayContentPartInputAudio,
    ContentContentPartArrayContentPartFile,
    ContentContentPartArrayContentPartRefusal,
]


class ToolCallFunction(TypedDict, total=False):
    arguments: Required[str]

    name: Required[str]


class ToolCall(TypedDict, total=False):
    id: Required[str]

    function: Required[ToolCallFunction]

    type: Required[Literal["function"]]


class ChatMessageParam(TypedDict, total=False):
    content: Required[Union[str, Iterable[ContentContentPartArray], None]]
    """Message content.

    String, array of content parts (multimodal), or null when tool_calls present.
    """

    role: Required[Literal["developer", "system", "user", "assistant", "tool"]]
    """Message role"""

    name: str
    """Optional participant name"""

    tool_call_id: str
    """Tool call ID (required when role is "tool")"""

    tool_calls: Iterable[ToolCall]
    """Tool calls (assistant role only)"""
