# 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 .return_user_defined_tool_tool_type import ReturnUserDefinedToolToolType
from .return_user_defined_tool_version_type import ReturnUserDefinedToolVersionType


class ReturnUserDefinedTool(UniversalBaseModel):
    """
    A specific tool version returned from the server
    """

    created_on: int = pydantic.Field()
    """
    The timestamp when the first version of this tool was created.
    """

    description: typing.Optional[str] = pydantic.Field(default=None)
    """
    An optional description of what the Tool does, used by the supplemental LLM to choose when and how to call the function.
    """

    fallback_content: typing.Optional[str] = pydantic.Field(default=None)
    """
    Optional text passed to the supplemental LLM in place of the tool call result. The LLM then uses this text to generate a response back to the user, ensuring continuity in the conversation if the Tool errors.
    """

    id: str = pydantic.Field()
    """
    Identifier for a Tool. Formatted as a UUID.
    """

    modified_on: int = pydantic.Field()
    """
    The timestamp when this version of the tool was created.
    """

    name: str = pydantic.Field()
    """
    Name of the built-in tool to use. Hume supports the following built-in tools:
    
    - **web_search:** enables EVI to search the web for up-to-date information when applicable.
    - **hang_up:** closes the WebSocket connection when appropriate (e.g., after detecting a farewell in the conversation).
    
    For more information, see our guide on [using built-in tools](/docs/speech-to-speech-evi/features/tool-use#using-built-in-tools).
    """

    parameters: str = pydantic.Field()
    """
    Stringified JSON defining the parameters used by this version of the Tool.
    
    These parameters define the inputs needed for the Tool's execution, including the expected data type and description for each input field. Structured as a stringified JSON schema, this format ensures the Tool receives data in the expected format.
    """

    tool_type: ReturnUserDefinedToolToolType
    version: int = pydantic.Field()
    """
    Version number for a Tool. Version numbers should be integers. The combination of configId and version number is unique.
    """

    version_description: typing.Optional[str] = pydantic.Field(default=None)
    """
    An optional description of the Tool version.
    """

    version_type: ReturnUserDefinedToolVersionType

    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
