from typing_extensions import Literal, Optional, Union

from openai._models import BaseModel

from openai.types.chat import (
    ChatCompletionContentPartTextParam,
    ChatCompletionContentPartImageParam,
)

from nexusflowai.types.chat_completion_content_part_image_bytes_param import (
    NexusflowAIChatCompletionContentPartImageBytesParam,
)

__all__ = ["NexusflowAIChatCompletionMessageToolCall", "Function"]


class Function(BaseModel):
    arguments: str
    """
    The arguments to call the function with, as generated by the model in JSON
    format. Note that the model does not always generate valid JSON, and may
    hallucinate parameters not defined by your function schema. Validate the
    arguments in your code before calling your function.
    """

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


class NexusflowAIChatCompletionMessageToolCall(BaseModel):
    id: str
    """The ID of the tool call."""

    function: Function
    """The function that the model called."""

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

    execution_result: Optional[
        Union[
            ChatCompletionContentPartTextParam,
            ChatCompletionContentPartImageParam,
            NexusflowAIChatCompletionContentPartImageBytesParam,
        ]
    ] = None
    """The execution_result of the tool call. Optional."""
