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

from __future__ import annotations
from .apiendpoint import APIEndpoint
from .batchrequest import BatchRequest, BatchRequestTypedDict
from mistralai.client.types import (
    BaseModel,
    Nullable,
    OptionalNullable,
    UNSET,
    UNSET_SENTINEL,
)
from pydantic import model_serializer
from typing import Dict, List, Optional
from typing_extensions import NotRequired, TypedDict


class CreateBatchJobRequestTypedDict(TypedDict):
    endpoint: APIEndpoint
    input_files: NotRequired[Nullable[List[str]]]
    r"""The list of input files to be used for batch inference, these files should be `jsonl` files, containing the input data corresponding to the bory request for the batch inference in a \"body\" field. An example of such file is the following: ```json {\"custom_id\": \"0\", \"body\": {\"max_tokens\": 100, \"messages\": [{\"role\": \"user\", \"content\": \"What is the best French cheese?\"}]}} {\"custom_id\": \"1\", \"body\": {\"max_tokens\": 100, \"messages\": [{\"role\": \"user\", \"content\": \"What is the best French wine?\"}]}} ```"""
    requests: NotRequired[Nullable[List[BatchRequestTypedDict]]]
    model: NotRequired[Nullable[str]]
    r"""The model to be used for batch inference."""
    agent_id: NotRequired[Nullable[str]]
    r"""In case you want to use a specific agent from the **deprecated** agents api for batch inference, you can specify the agent ID here."""
    metadata: NotRequired[Nullable[Dict[str, str]]]
    r"""The metadata of your choice to be associated with the batch inference job."""
    timeout_hours: NotRequired[int]
    r"""The timeout in hours for the batch inference job."""


class CreateBatchJobRequest(BaseModel):
    endpoint: APIEndpoint

    input_files: OptionalNullable[List[str]] = UNSET
    r"""The list of input files to be used for batch inference, these files should be `jsonl` files, containing the input data corresponding to the bory request for the batch inference in a \"body\" field. An example of such file is the following: ```json {\"custom_id\": \"0\", \"body\": {\"max_tokens\": 100, \"messages\": [{\"role\": \"user\", \"content\": \"What is the best French cheese?\"}]}} {\"custom_id\": \"1\", \"body\": {\"max_tokens\": 100, \"messages\": [{\"role\": \"user\", \"content\": \"What is the best French wine?\"}]}} ```"""

    requests: OptionalNullable[List[BatchRequest]] = UNSET

    model: OptionalNullable[str] = UNSET
    r"""The model to be used for batch inference."""

    agent_id: OptionalNullable[str] = UNSET
    r"""In case you want to use a specific agent from the **deprecated** agents api for batch inference, you can specify the agent ID here."""

    metadata: OptionalNullable[Dict[str, str]] = UNSET
    r"""The metadata of your choice to be associated with the batch inference job."""

    timeout_hours: Optional[int] = 24
    r"""The timeout in hours for the batch inference job."""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(
            [
                "input_files",
                "requests",
                "model",
                "agent_id",
                "metadata",
                "timeout_hours",
            ]
        )
        nullable_fields = set(
            ["input_files", "requests", "model", "agent_id", "metadata"]
        )
        serialized = handler(self)
        m = {}

        for n, f in type(self).model_fields.items():
            k = f.alias or n
            val = serialized.get(k, serialized.get(n))
            is_nullable_and_explicitly_set = (
                k in nullable_fields
                and (self.__pydantic_fields_set__.intersection({n}))  # pylint: disable=no-member
            )

            if val != UNSET_SENTINEL:
                if (
                    val is not None
                    or k not in optional_fields
                    or is_nullable_and_explicitly_set
                ):
                    m[k] = val

        return m
