"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
# @generated-id: 81651291187a

from __future__ import annotations
from .classifierfinetuningjob import (
    ClassifierFineTuningJob,
    ClassifierFineTuningJobTypedDict,
)
from .completionfinetuningjob import (
    CompletionFineTuningJob,
    CompletionFineTuningJobTypedDict,
)
from .legacyjobmetadata import LegacyJobMetadata, LegacyJobMetadataTypedDict
from functools import partial
from mistralai.client.types import BaseModel
from mistralai.client.utils.unions import parse_open_union
from pydantic import ConfigDict
from pydantic.functional_validators import BeforeValidator
from typing import Any, Literal, Union
from typing_extensions import Annotated, TypeAliasType


ResponseTypedDict = TypeAliasType(
    "ResponseTypedDict",
    Union[ClassifierFineTuningJobTypedDict, CompletionFineTuningJobTypedDict],
)


class UnknownResponse(BaseModel):
    r"""A Response variant the SDK doesn't recognize. Preserves the raw payload."""

    job_type: Literal["UNKNOWN"] = "UNKNOWN"
    raw: Any
    is_unknown: Literal[True] = True

    model_config = ConfigDict(frozen=True)


_RESPONSE_VARIANTS: dict[str, Any] = {
    "classifier": ClassifierFineTuningJob,
    "completion": CompletionFineTuningJob,
}


Response = Annotated[
    Union[ClassifierFineTuningJob, CompletionFineTuningJob, UnknownResponse],
    BeforeValidator(
        partial(
            parse_open_union,
            disc_key="job_type",
            variants=_RESPONSE_VARIANTS,
            unknown_cls=UnknownResponse,
            union_name="Response",
        )
    ),
]


JobsAPIRoutesFineTuningCreateFineTuningJobResponseTypedDict = TypeAliasType(
    "JobsAPIRoutesFineTuningCreateFineTuningJobResponseTypedDict",
    Union[LegacyJobMetadataTypedDict, ResponseTypedDict],
)
r"""OK"""


JobsAPIRoutesFineTuningCreateFineTuningJobResponse = TypeAliasType(
    "JobsAPIRoutesFineTuningCreateFineTuningJobResponse",
    Union[LegacyJobMetadata, Response],
)
r"""OK"""
