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

from typing import Union, Optional
from typing_extensions import Literal, Annotated, TypeAlias

from ..._utils import PropertyInfo
from ..._models import BaseModel

__all__ = ["ResponseFunctionToolCall", "Caller", "CallerDirect", "CallerProgram"]


class CallerDirect(BaseModel):
    type: Literal["direct"]


class CallerProgram(BaseModel):
    caller_id: str
    """The call ID of the program item that produced this tool call."""

    type: Literal["program"]


Caller: TypeAlias = Annotated[Union[CallerDirect, CallerProgram, None], PropertyInfo(discriminator="type")]


class ResponseFunctionToolCall(BaseModel):
    """A tool call to run a function.

    See the
    [function calling guide](https://platform.openai.com/docs/guides/function-calling) for more information.
    """

    arguments: str
    """A JSON string of the arguments to pass to the function."""

    call_id: str
    """The unique ID of the function tool call generated by the model."""

    name: str
    """The name of the function to run."""

    type: Literal["function_call"]
    """The type of the function tool call. Always `function_call`."""

    id: Optional[str] = None
    """The unique ID of the function tool call."""

    caller: Optional[Caller] = None
    """The execution context that produced this tool call."""

    namespace: Optional[str] = None
    """The namespace of the function to run."""

    status: Optional[Literal["in_progress", "completed", "incomplete"]] = None
    """The status of the item.

    One of `in_progress`, `completed`, or `incomplete`. Populated when items are
    returned via API.
    """
