"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""

from __future__ import annotations
from openrouter.types import BaseModel, UnrecognizedStr
from openrouter.utils import get_discriminator, validate_const, validate_open_enum
import pydantic
from pydantic import Discriminator, Tag
from pydantic.functional_validators import AfterValidator, PlainValidator
from typing import List, Literal, Optional, Union
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict


class Schema17ResponseHealingTypedDict(TypedDict):
    id: Literal["response-healing"]
    enabled: NotRequired[bool]


class Schema17ResponseHealing(BaseModel):
    ID: Annotated[
        Annotated[
            Literal["response-healing"],
            AfterValidator(validate_const("response-healing")),
        ],
        pydantic.Field(alias="id"),
    ] = "response-healing"

    enabled: Optional[bool] = None


PdfEngine = Union[
    Literal[
        "mistral-ocr",
        "pdf-text",
        "native",
    ],
    UnrecognizedStr,
]


class PdfTypedDict(TypedDict):
    engine: NotRequired[PdfEngine]


class Pdf(BaseModel):
    engine: Annotated[
        Optional[PdfEngine], PlainValidator(validate_open_enum(False))
    ] = None


class Schema17FileParserTypedDict(TypedDict):
    id: Literal["file-parser"]
    enabled: NotRequired[bool]
    pdf: NotRequired[PdfTypedDict]


class Schema17FileParser(BaseModel):
    ID: Annotated[
        Annotated[
            Literal["file-parser"], AfterValidator(validate_const("file-parser"))
        ],
        pydantic.Field(alias="id"),
    ] = "file-parser"

    enabled: Optional[bool] = None

    pdf: Optional[Pdf] = None


Engine = Union[
    Literal[
        "native",
        "exa",
    ],
    UnrecognizedStr,
]


class Schema17WebTypedDict(TypedDict):
    id: Literal["web"]
    enabled: NotRequired[bool]
    max_results: NotRequired[float]
    search_prompt: NotRequired[str]
    engine: NotRequired[Engine]


class Schema17Web(BaseModel):
    ID: Annotated[
        Annotated[Literal["web"], AfterValidator(validate_const("web"))],
        pydantic.Field(alias="id"),
    ] = "web"

    enabled: Optional[bool] = None

    max_results: Optional[float] = None

    search_prompt: Optional[str] = None

    engine: Annotated[Optional[Engine], PlainValidator(validate_open_enum(False))] = (
        None
    )


class Schema17ModerationTypedDict(TypedDict):
    id: Literal["moderation"]


class Schema17Moderation(BaseModel):
    ID: Annotated[
        Annotated[Literal["moderation"], AfterValidator(validate_const("moderation"))],
        pydantic.Field(alias="id"),
    ] = "moderation"


class Schema17AutoRouterTypedDict(TypedDict):
    id: Literal["auto-router"]
    enabled: NotRequired[bool]
    allowed_models: NotRequired[List[str]]


class Schema17AutoRouter(BaseModel):
    ID: Annotated[
        Annotated[
            Literal["auto-router"], AfterValidator(validate_const("auto-router"))
        ],
        pydantic.Field(alias="id"),
    ] = "auto-router"

    enabled: Optional[bool] = None

    allowed_models: Optional[List[str]] = None


Schema17TypedDict = TypeAliasType(
    "Schema17TypedDict",
    Union[
        Schema17ModerationTypedDict,
        Schema17ResponseHealingTypedDict,
        Schema17AutoRouterTypedDict,
        Schema17FileParserTypedDict,
        Schema17WebTypedDict,
    ],
)


Schema17 = Annotated[
    Union[
        Annotated[Schema17AutoRouter, Tag("auto-router")],
        Annotated[Schema17Moderation, Tag("moderation")],
        Annotated[Schema17Web, Tag("web")],
        Annotated[Schema17FileParser, Tag("file-parser")],
        Annotated[Schema17ResponseHealing, Tag("response-healing")],
    ],
    Discriminator(lambda m: get_discriminator(m, "id", "id")),
]
