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

from ..core.pydantic_utilities import UniversalBaseModel
import typing
from .ml_backend_state import MlBackendState
import pydantic
from .ml_backend_auth_method import MlBackendAuthMethod
import datetime as dt
from ..core.pydantic_utilities import IS_PYDANTIC_V2


class MlBackend(UniversalBaseModel):
    id: typing.Optional[int] = None
    state: typing.Optional[MlBackendState] = None
    readable_state: typing.Optional[str] = None
    is_interactive: typing.Optional[bool] = pydantic.Field(default=None)
    """
    Used to interactively annotate tasks. If true, model returns one list with results
    """

    url: str = pydantic.Field()
    """
    URL for the machine learning model server
    """

    error_message: typing.Optional[str] = pydantic.Field(default=None)
    """
    Error message in error state
    """

    title: typing.Optional[str] = pydantic.Field(default=None)
    """
    Name of the machine learning backend
    """

    auth_method: typing.Optional[MlBackendAuthMethod] = None
    basic_auth_user: typing.Optional[str] = pydantic.Field(default=None)
    """
    HTTP Basic Auth user
    """

    basic_auth_pass: typing.Optional[str] = None
    basic_auth_pass_is_set: typing.Optional[str] = None
    description: typing.Optional[str] = pydantic.Field(default=None)
    """
    Description for the machine learning backend
    """

    extra_params: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = pydantic.Field(default=None)
    """
    Any extra parameters passed to the ML Backend during the setup
    """

    model_version: typing.Optional[str] = pydantic.Field(default=None)
    """
    Current model version associated with this machine learning backend
    """

    timeout: typing.Optional[float] = pydantic.Field(default=None)
    """
    Response model timeout
    """

    created_at: typing.Optional[dt.datetime] = None
    updated_at: typing.Optional[dt.datetime] = None
    auto_update: typing.Optional[bool] = pydantic.Field(default=None)
    """
    If false, model version is set by the user, if true - getting latest version from backend.
    """

    project: int

    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
