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

from __future__ import annotations
import httpx
from leonardo_ai_sdk.types import (
    BaseModel,
    Nullable,
    OptionalNullable,
    UNSET,
    UNSET_SENTINEL,
)
import pydantic
from pydantic import model_serializer
from typing import Optional
from typing_extensions import Annotated, NotRequired, TypedDict


class PromptImproveRequestBodyTypedDict(TypedDict):
    r"""Query parameters to be provided in the request body as a JSON object"""

    prompt: str
    r"""The prompt to improve."""
    prompt_instructions: NotRequired[Nullable[str]]
    r"""The prompt is improved based on the given instructions."""


class PromptImproveRequestBody(BaseModel):
    r"""Query parameters to be provided in the request body as a JSON object"""

    prompt: str
    r"""The prompt to improve."""

    prompt_instructions: Annotated[
        OptionalNullable[str], pydantic.Field(alias="promptInstructions")
    ] = UNSET
    r"""The prompt is improved based on the given instructions."""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = ["promptInstructions"]
        nullable_fields = ["promptInstructions"]
        null_default_fields = []

        serialized = handler(self)

        m = {}

        for n, f in self.model_fields.items():
            k = f.alias or n
            val = serialized.get(k)
            serialized.pop(k, None)

            optional_nullable = k in optional_fields and k in nullable_fields
            is_set = (
                self.__pydantic_fields_set__.intersection({n})
                or k in null_default_fields
            )  # pylint: disable=no-member

            if val is not None and val != UNSET_SENTINEL:
                m[k] = val
            elif val != UNSET_SENTINEL and (
                not k in optional_fields or (optional_nullable and is_set)
            ):
                m[k] = val

        return m


class PromptGenerationOutputTypedDict(TypedDict):
    api_credit_cost: NotRequired[int]
    r"""API Credits Cost for Random Prompt Generation. Available for Production API Users."""
    prompt: NotRequired[str]
    r"""The improved prompt."""


class PromptGenerationOutput(BaseModel):
    api_credit_cost: Annotated[Optional[int], pydantic.Field(alias="apiCreditCost")] = 4
    r"""API Credits Cost for Random Prompt Generation. Available for Production API Users."""

    prompt: Optional[str] = "The improved prompt."
    r"""The improved prompt."""


class PromptImproveResponseBodyTypedDict(TypedDict):
    r"""Responses for POST /prompt/improve"""

    prompt_generation: NotRequired[PromptGenerationOutputTypedDict]


class PromptImproveResponseBody(BaseModel):
    r"""Responses for POST /prompt/improve"""

    prompt_generation: Annotated[
        Optional[PromptGenerationOutput], pydantic.Field(alias="promptGeneration")
    ] = None


class PromptImproveResponseTypedDict(TypedDict):
    content_type: str
    r"""HTTP response content type for this operation"""
    status_code: int
    r"""HTTP response status code for this operation"""
    raw_response: httpx.Response
    r"""Raw HTTP response; suitable for custom response parsing"""
    object: NotRequired[PromptImproveResponseBodyTypedDict]
    r"""Responses for POST /prompt/improve"""


class PromptImproveResponse(BaseModel):
    content_type: str
    r"""HTTP response content type for this operation"""

    status_code: int
    r"""HTTP response status code for this operation"""

    raw_response: httpx.Response
    r"""Raw HTTP response; suitable for custom response parsing"""

    object: Optional[PromptImproveResponseBody] = None
    r"""Responses for POST /prompt/improve"""
