# 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__ = [
    "ActionAddAIAssistantMessagesParams",
    "Message",
    "MessageUserMessage",
    "MessageAssistantMessage",
    "MessageAssistantMessageToolCall",
    "MessageAssistantMessageToolCallFunction",
    "MessageToolMessage",
    "MessageSystemMessage",
    "MessageDeveloperMessage",
]


class ActionAddAIAssistantMessagesParams(TypedDict, total=False):
    client_state: str
    """Use this field to add state to every subsequent webhook.

    It must be a valid Base-64 encoded string.
    """

    command_id: str
    """Use this field to avoid duplicate commands.

    Telnyx will ignore any command with the same `command_id` for the same
    `call_control_id`.
    """

    messages: Iterable[Message]
    """The messages to add to the conversation."""


class MessageUserMessage(TypedDict, total=False):
    """Messages sent by an end user"""

    content: Required[str]
    """The contents of the user message."""

    role: Required[Literal["user"]]
    """The role of the messages author, in this case `user`."""

    metadata: object
    """Metadata to add to the message"""


class MessageAssistantMessageToolCallFunction(TypedDict, total=False):
    """The function that the model called."""

    name: Required[str]
    """The name of the function to call."""


class MessageAssistantMessageToolCall(TypedDict, total=False):
    """A call to a function tool created by the model."""

    id: Required[str]
    """The ID of the tool call."""

    function: Required[MessageAssistantMessageToolCallFunction]
    """The function that the model called."""

    type: Required[Literal["function"]]
    """The type of the tool. Currently, only `function` is supported."""


class MessageAssistantMessage(TypedDict, total=False):
    """Messages sent by the model in response to user messages."""

    role: Required[Literal["assistant"]]
    """The role of the messages author, in this case `assistant`."""

    content: str
    """The contents of the assistant message. Required unless `tool_calls`"""

    metadata: object
    """Metadata to add to the message"""

    tool_calls: Iterable[MessageAssistantMessageToolCall]
    """The tool calls generated by the model, such as function calls."""


class MessageToolMessage(TypedDict, total=False):
    content: Required[str]
    """The contents of the tool message."""

    role: Required[Literal["tool"]]
    """The role of the messages author, in this case `tool`."""

    tool_call_id: Required[str]
    """Tool call that this message is responding to."""

    metadata: object
    """Metadata to add to the message"""


class MessageSystemMessage(TypedDict, total=False):
    """
    Developer-provided instructions that the model should follow, regardless of messages sent by the user.
    """

    content: Required[str]
    """The contents of the system message."""

    role: Required[Literal["system"]]
    """The role of the messages author, in this case `system`."""

    metadata: object
    """Metadata to add to the message"""


class MessageDeveloperMessage(TypedDict, total=False):
    """
    Developer-provided instructions that the model should follow, regardless of messages sent by the user.
    """

    content: Required[str]
    """The contents of the developer message."""

    role: Required[Literal["developer"]]
    """The role of the messages author, in this case developer."""

    metadata: object
    """Metadata to add to the message"""


Message: TypeAlias = Union[
    MessageUserMessage, MessageAssistantMessage, MessageToolMessage, MessageSystemMessage, MessageDeveloperMessage
]
