# This file was auto-generated by Fern from our API Definition.

import typing

import pydantic
import typing_extensions
from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
from ..core.serialization import FieldMetadata
from .tool_part_state import ToolPartState


class ToolPart(UniversalBaseModel):
    """
    Tool invocation and result part.
    """

    error_text: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="errorText")] = pydantic.Field(
        alias="errorText", default=None
    )
    """
    Error message if tool failed
    """

    input: typing.Dict[str, typing.Any] = pydantic.Field()
    """
    Input arguments for the tool
    """

    output: typing.Optional[typing.Any] = pydantic.Field(default=None)
    """
    Output from the tool
    """

    state: ToolPartState = pydantic.Field()
    """
    Current state of the tool execution
    """

    tool_call_id: typing_extensions.Annotated[str, FieldMetadata(alias="toolCallId")] = pydantic.Field(
        alias="toolCallId"
    )
    """
    Unique ID for this tool call
    """

    tool_name: typing_extensions.Annotated[str, FieldMetadata(alias="toolName")] = pydantic.Field(alias="toolName")
    """
    Name of the tool
    """

    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
