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

from __future__ import annotations
from datetime import datetime
import dateutil.parser
from orq_ai_sdk.types import (
    BaseModel,
    Nullable,
    OptionalNullable,
    UNSET,
    UNSET_SENTINEL,
)
from orq_ai_sdk.utils import FieldMetadata, HeaderMetadata, PathParamMetadata
import pydantic
from pydantic import model_serializer
from typing import Any, Dict, List, Literal, Optional, Union
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict


class FindOnePromptSnippetGlobalsTypedDict(TypedDict):
    contact_id: NotRequired[str]


class FindOnePromptSnippetGlobals(BaseModel):
    contact_id: Annotated[
        Optional[str],
        pydantic.Field(alias="contactId"),
        FieldMetadata(header=HeaderMetadata(style="simple", explode=False)),
    ] = None


class FindOnePromptSnippetRequestTypedDict(TypedDict):
    id: str
    r"""Prompt ID"""


class FindOnePromptSnippetRequest(BaseModel):
    id: Annotated[
        str, FieldMetadata(path=PathParamMetadata(style="simple", explode=False))
    ]
    r"""Prompt ID"""


FindOnePromptSnippetOwner2 = Literal["vendor"]

FindOnePromptSnippetOwnerTypedDict = TypeAliasType(
    "FindOnePromptSnippetOwnerTypedDict", Union[str, FindOnePromptSnippetOwner2]
)


FindOnePromptSnippetOwner = TypeAliasType(
    "FindOnePromptSnippetOwner", Union[str, FindOnePromptSnippetOwner2]
)


FindOnePromptSnippetModelType = Literal[
    "chat",
    "completion",
    "embedding",
    "vision",
    "image",
    "tts",
    "stt",
    "rerank",
    "moderations",
]
r"""The type of the model"""

FindOnePromptSnippetFormat = Literal["url", "b64_json", "text", "json_object"]
r"""Only supported on `image` models."""

FindOnePromptSnippetQuality = Literal["standard", "hd"]
r"""Only supported on `image` models."""

FindOnePromptSnippetResponseFormatPromptSnippetsType = Literal["json_object"]


class FindOnePromptSnippetResponseFormat2TypedDict(TypedDict):
    type: FindOnePromptSnippetResponseFormatPromptSnippetsType


class FindOnePromptSnippetResponseFormat2(BaseModel):
    type: FindOnePromptSnippetResponseFormatPromptSnippetsType


FindOnePromptSnippetResponseFormatType = Literal["json_schema"]


class FindOnePromptSnippetResponseFormatJSONSchemaTypedDict(TypedDict):
    name: str
    strict: bool
    schema_: Dict[str, Any]


class FindOnePromptSnippetResponseFormatJSONSchema(BaseModel):
    name: str

    strict: bool

    schema_: Annotated[Dict[str, Any], pydantic.Field(alias="schema")]


class FindOnePromptSnippetResponseFormat1TypedDict(TypedDict):
    type: FindOnePromptSnippetResponseFormatType
    json_schema: FindOnePromptSnippetResponseFormatJSONSchemaTypedDict


class FindOnePromptSnippetResponseFormat1(BaseModel):
    type: FindOnePromptSnippetResponseFormatType

    json_schema: FindOnePromptSnippetResponseFormatJSONSchema


FindOnePromptSnippetResponseFormatTypedDict = TypeAliasType(
    "FindOnePromptSnippetResponseFormatTypedDict",
    Union[
        FindOnePromptSnippetResponseFormat2TypedDict,
        FindOnePromptSnippetResponseFormat1TypedDict,
    ],
)
r"""An object specifying the format that the model must output.

Setting to `{ \"type\": \"json_schema\", \"json_schema\": {...} }` enables Structured Outputs which ensures the model will match your supplied JSON schema

Setting to `{ \"type\": \"json_object\" }` enables JSON mode, which ensures the message the model generates is valid JSON.

Important: when using JSON mode, you must also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly \"stuck\" request. Also note that the message content may be partially cut off if finish_reason=\"length\", which indicates the generation exceeded max_tokens or the conversation exceeded the max context length.
"""


FindOnePromptSnippetResponseFormat = TypeAliasType(
    "FindOnePromptSnippetResponseFormat",
    Union[FindOnePromptSnippetResponseFormat2, FindOnePromptSnippetResponseFormat1],
)
r"""An object specifying the format that the model must output.

Setting to `{ \"type\": \"json_schema\", \"json_schema\": {...} }` enables Structured Outputs which ensures the model will match your supplied JSON schema

Setting to `{ \"type\": \"json_object\" }` enables JSON mode, which ensures the message the model generates is valid JSON.

Important: when using JSON mode, you must also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly \"stuck\" request. Also note that the message content may be partially cut off if finish_reason=\"length\", which indicates the generation exceeded max_tokens or the conversation exceeded the max context length.
"""


FindOnePromptSnippetPhotoRealVersion = Literal["v1", "v2"]
r"""The version of photoReal to use. Must be v1 or v2. Only available for `leonardoai` provider"""

FindOnePromptSnippetEncodingFormat = Literal["float", "base64"]
r"""The format to return the embeddings"""


class FindOnePromptSnippetModelParametersTypedDict(TypedDict):
    r"""Model Parameters: Not all parameters apply to every model"""

    temperature: NotRequired[float]
    r"""Only supported on `chat` and `completion` models."""
    max_tokens: NotRequired[float]
    r"""Only supported on `chat` and `completion` models."""
    top_k: NotRequired[float]
    r"""Only supported on `chat` and `completion` models."""
    top_p: NotRequired[float]
    r"""Only supported on `chat` and `completion` models."""
    frequency_penalty: NotRequired[float]
    r"""Only supported on `chat` and `completion` models."""
    presence_penalty: NotRequired[float]
    r"""Only supported on `chat` and `completion` models."""
    num_images: NotRequired[float]
    r"""Only supported on `image` models."""
    seed: NotRequired[float]
    r"""Best effort deterministic seed for the model. Currently only OpenAI models support these"""
    format_: NotRequired[FindOnePromptSnippetFormat]
    r"""Only supported on `image` models."""
    dimensions: NotRequired[str]
    r"""Only supported on `image` models."""
    quality: NotRequired[FindOnePromptSnippetQuality]
    r"""Only supported on `image` models."""
    style: NotRequired[str]
    r"""Only supported on `image` models."""
    response_format: NotRequired[Nullable[FindOnePromptSnippetResponseFormatTypedDict]]
    r"""An object specifying the format that the model must output.

    Setting to `{ \"type\": \"json_schema\", \"json_schema\": {...} }` enables Structured Outputs which ensures the model will match your supplied JSON schema

    Setting to `{ \"type\": \"json_object\" }` enables JSON mode, which ensures the message the model generates is valid JSON.

    Important: when using JSON mode, you must also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly \"stuck\" request. Also note that the message content may be partially cut off if finish_reason=\"length\", which indicates the generation exceeded max_tokens or the conversation exceeded the max context length.
    """
    photo_real_version: NotRequired[FindOnePromptSnippetPhotoRealVersion]
    r"""The version of photoReal to use. Must be v1 or v2. Only available for `leonardoai` provider"""
    encoding_format: NotRequired[FindOnePromptSnippetEncodingFormat]
    r"""The format to return the embeddings"""


class FindOnePromptSnippetModelParameters(BaseModel):
    r"""Model Parameters: Not all parameters apply to every model"""

    temperature: Optional[float] = None
    r"""Only supported on `chat` and `completion` models."""

    max_tokens: Annotated[Optional[float], pydantic.Field(alias="maxTokens")] = None
    r"""Only supported on `chat` and `completion` models."""

    top_k: Annotated[Optional[float], pydantic.Field(alias="topK")] = None
    r"""Only supported on `chat` and `completion` models."""

    top_p: Annotated[Optional[float], pydantic.Field(alias="topP")] = None
    r"""Only supported on `chat` and `completion` models."""

    frequency_penalty: Annotated[
        Optional[float], pydantic.Field(alias="frequencyPenalty")
    ] = None
    r"""Only supported on `chat` and `completion` models."""

    presence_penalty: Annotated[
        Optional[float], pydantic.Field(alias="presencePenalty")
    ] = None
    r"""Only supported on `chat` and `completion` models."""

    num_images: Annotated[Optional[float], pydantic.Field(alias="numImages")] = None
    r"""Only supported on `image` models."""

    seed: Optional[float] = None
    r"""Best effort deterministic seed for the model. Currently only OpenAI models support these"""

    format_: Annotated[
        Optional[FindOnePromptSnippetFormat], pydantic.Field(alias="format")
    ] = None
    r"""Only supported on `image` models."""

    dimensions: Optional[str] = None
    r"""Only supported on `image` models."""

    quality: Optional[FindOnePromptSnippetQuality] = None
    r"""Only supported on `image` models."""

    style: Optional[str] = None
    r"""Only supported on `image` models."""

    response_format: Annotated[
        OptionalNullable[FindOnePromptSnippetResponseFormat],
        pydantic.Field(alias="responseFormat"),
    ] = UNSET
    r"""An object specifying the format that the model must output.

    Setting to `{ \"type\": \"json_schema\", \"json_schema\": {...} }` enables Structured Outputs which ensures the model will match your supplied JSON schema

    Setting to `{ \"type\": \"json_object\" }` enables JSON mode, which ensures the message the model generates is valid JSON.

    Important: when using JSON mode, you must also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly \"stuck\" request. Also note that the message content may be partially cut off if finish_reason=\"length\", which indicates the generation exceeded max_tokens or the conversation exceeded the max context length.
    """

    photo_real_version: Annotated[
        Optional[FindOnePromptSnippetPhotoRealVersion],
        pydantic.Field(alias="photoRealVersion"),
    ] = None
    r"""The version of photoReal to use. Must be v1 or v2. Only available for `leonardoai` provider"""

    encoding_format: Optional[FindOnePromptSnippetEncodingFormat] = None
    r"""The format to return the embeddings"""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = [
            "temperature",
            "maxTokens",
            "topK",
            "topP",
            "frequencyPenalty",
            "presencePenalty",
            "numImages",
            "seed",
            "format",
            "dimensions",
            "quality",
            "style",
            "responseFormat",
            "photoRealVersion",
            "encoding_format",
        ]
        nullable_fields = ["responseFormat"]
        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


FindOnePromptSnippetProvider = Literal[
    "cohere",
    "openai",
    "anthropic",
    "huggingface",
    "replicate",
    "google",
    "google-ai",
    "azure",
    "aws",
    "anyscale",
    "perplexity",
    "groq",
    "fal",
    "leonardoai",
    "nvidia",
    "jina",
    "togetherai",
    "elevenlabs",
]

FindOnePromptSnippetRole = Literal[
    "system",
    "assistant",
    "user",
    "exception",
    "tool",
    "prompt",
    "correction",
    "expected_output",
]
r"""The role of the prompt message"""

FindOnePromptSnippet2PromptSnippetsType = Literal["image_url"]


class FindOnePromptSnippet2ImageURLTypedDict(TypedDict):
    url: str
    r"""Either a URL of the image or the base64 encoded data URI."""
    id: NotRequired[str]
    r"""The orq.ai id of the image"""
    detail: NotRequired[str]
    r"""Specifies the detail level of the image. Currently only supported with OpenAI models"""


class FindOnePromptSnippet2ImageURL(BaseModel):
    url: str
    r"""Either a URL of the image or the base64 encoded data URI."""

    id: Optional[str] = None
    r"""The orq.ai id of the image"""

    detail: Optional[str] = None
    r"""Specifies the detail level of the image. Currently only supported with OpenAI models"""


class FindOnePromptSnippet22TypedDict(TypedDict):
    r"""The image part of the prompt message. Only supported with vision models."""

    type: FindOnePromptSnippet2PromptSnippetsType
    image_url: FindOnePromptSnippet2ImageURLTypedDict


class FindOnePromptSnippet22(BaseModel):
    r"""The image part of the prompt message. Only supported with vision models."""

    type: FindOnePromptSnippet2PromptSnippetsType

    image_url: FindOnePromptSnippet2ImageURL


FindOnePromptSnippet2Type = Literal["text"]


class FindOnePromptSnippet21TypedDict(TypedDict):
    r"""Text content part of a prompt message"""

    type: FindOnePromptSnippet2Type
    text: str


class FindOnePromptSnippet21(BaseModel):
    r"""Text content part of a prompt message"""

    type: FindOnePromptSnippet2Type

    text: str


FindOnePromptSnippetContent2TypedDict = TypeAliasType(
    "FindOnePromptSnippetContent2TypedDict",
    Union[FindOnePromptSnippet21TypedDict, FindOnePromptSnippet22TypedDict],
)


FindOnePromptSnippetContent2 = TypeAliasType(
    "FindOnePromptSnippetContent2",
    Union[FindOnePromptSnippet21, FindOnePromptSnippet22],
)


FindOnePromptSnippetContentTypedDict = TypeAliasType(
    "FindOnePromptSnippetContentTypedDict",
    Union[str, List[FindOnePromptSnippetContent2TypedDict]],
)
r"""The contents of the user message. Either the text content of the message or an array of content parts with a defined type, each can be of type `text` or `image_url` when passing in images. You can pass multiple images by adding multiple `image_url` content parts."""


FindOnePromptSnippetContent = TypeAliasType(
    "FindOnePromptSnippetContent", Union[str, List[FindOnePromptSnippetContent2]]
)
r"""The contents of the user message. Either the text content of the message or an array of content parts with a defined type, each can be of type `text` or `image_url` when passing in images. You can pass multiple images by adding multiple `image_url` content parts."""


FindOnePromptSnippetPromptSnippetsType = Literal["function"]


class FindOnePromptSnippetFunctionTypedDict(TypedDict):
    name: str
    arguments: str
    r"""JSON string arguments for the functions"""


class FindOnePromptSnippetFunction(BaseModel):
    name: str

    arguments: str
    r"""JSON string arguments for the functions"""


class FindOnePromptSnippetToolCallsTypedDict(TypedDict):
    type: FindOnePromptSnippetPromptSnippetsType
    function: FindOnePromptSnippetFunctionTypedDict
    id: NotRequired[str]
    index: NotRequired[float]


class FindOnePromptSnippetToolCalls(BaseModel):
    type: FindOnePromptSnippetPromptSnippetsType

    function: FindOnePromptSnippetFunction

    id: Optional[str] = None

    index: Optional[float] = None


class FindOnePromptSnippetMessagesTypedDict(TypedDict):
    role: FindOnePromptSnippetRole
    r"""The role of the prompt message"""
    content: FindOnePromptSnippetContentTypedDict
    r"""The contents of the user message. Either the text content of the message or an array of content parts with a defined type, each can be of type `text` or `image_url` when passing in images. You can pass multiple images by adding multiple `image_url` content parts."""
    tool_calls: NotRequired[List[FindOnePromptSnippetToolCallsTypedDict]]


class FindOnePromptSnippetMessages(BaseModel):
    role: FindOnePromptSnippetRole
    r"""The role of the prompt message"""

    content: FindOnePromptSnippetContent
    r"""The contents of the user message. Either the text content of the message or an array of content parts with a defined type, each can be of type `text` or `image_url` when passing in images. You can pass multiple images by adding multiple `image_url` content parts."""

    tool_calls: Optional[List[FindOnePromptSnippetToolCalls]] = None


class FindOnePromptSnippetPromptConfigTypedDict(TypedDict):
    r"""A list of messages compatible with the openAI schema"""

    messages: List[FindOnePromptSnippetMessagesTypedDict]
    stream: NotRequired[bool]
    model: NotRequired[str]
    model_db_id: NotRequired[str]
    r"""The id of the resource"""
    model_type: NotRequired[FindOnePromptSnippetModelType]
    r"""The type of the model"""
    model_parameters: NotRequired[FindOnePromptSnippetModelParametersTypedDict]
    r"""Model Parameters: Not all parameters apply to every model"""
    provider: NotRequired[FindOnePromptSnippetProvider]
    integration_id: NotRequired[Nullable[str]]
    r"""The id of the resource"""
    version: NotRequired[str]


class FindOnePromptSnippetPromptConfig(BaseModel):
    r"""A list of messages compatible with the openAI schema"""

    messages: List[FindOnePromptSnippetMessages]

    stream: Optional[bool] = None

    model: Optional[str] = None

    model_db_id: Optional[str] = None
    r"""The id of the resource"""

    model_type: Optional[FindOnePromptSnippetModelType] = None
    r"""The type of the model"""

    model_parameters: Optional[FindOnePromptSnippetModelParameters] = None
    r"""Model Parameters: Not all parameters apply to every model"""

    provider: Optional[FindOnePromptSnippetProvider] = None

    integration_id: OptionalNullable[str] = UNSET
    r"""The id of the resource"""

    version: Optional[str] = None

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = [
            "stream",
            "model",
            "model_db_id",
            "model_type",
            "model_parameters",
            "provider",
            "integration_id",
            "version",
        ]
        nullable_fields = ["integration_id"]
        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


FindOnePromptSnippetUseCases = Literal[
    "Agents",
    "Agents simulations",
    "API interaction",
    "Autonomous Agents",
    "Chatbots",
    "Classification",
    "Code understanding",
    "Code writing",
    "Documents QA",
    "Conversation",
    "Extraction",
    "Multi-modal",
    "Self-checking",
    "SQL",
    "Summarization",
    "Tagging",
]

FindOnePromptSnippetLanguage = Literal[
    "Chinese", "Dutch", "English", "French", "German", "Russian", "Spanish"
]
r"""The language that the prompt is written in. Use this field to categorize the prompt for your own purpose"""


class FindOnePromptSnippetMetadataTypedDict(TypedDict):
    use_cases: NotRequired[List[FindOnePromptSnippetUseCases]]
    r"""A list of use cases that the prompt is meant to be used for. Use this field to categorize the prompt for your own purpose"""
    language: NotRequired[FindOnePromptSnippetLanguage]
    r"""The language that the prompt is written in. Use this field to categorize the prompt for your own purpose"""


class FindOnePromptSnippetMetadata(BaseModel):
    use_cases: Optional[List[FindOnePromptSnippetUseCases]] = None
    r"""A list of use cases that the prompt is meant to be used for. Use this field to categorize the prompt for your own purpose"""

    language: Optional[FindOnePromptSnippetLanguage] = None
    r"""The language that the prompt is written in. Use this field to categorize the prompt for your own purpose"""


FindOnePromptSnippetType = Literal["snippet"]

FindOnePromptSnippetPromptSnippetsModelType = Literal[
    "chat",
    "completion",
    "embedding",
    "vision",
    "image",
    "tts",
    "stt",
    "rerank",
    "moderations",
]
r"""The type of the model"""

FindOnePromptSnippetPromptSnippetsFormat = Literal[
    "url", "b64_json", "text", "json_object"
]
r"""Only supported on `image` models."""

FindOnePromptSnippetPromptSnippetsQuality = Literal["standard", "hd"]
r"""Only supported on `image` models."""

FindOnePromptSnippetResponseFormatPromptSnippetsResponse200Type = Literal["json_object"]


class FindOnePromptSnippetResponseFormatPromptSnippets2TypedDict(TypedDict):
    type: FindOnePromptSnippetResponseFormatPromptSnippetsResponse200Type


class FindOnePromptSnippetResponseFormatPromptSnippets2(BaseModel):
    type: FindOnePromptSnippetResponseFormatPromptSnippetsResponse200Type


FindOnePromptSnippetResponseFormatPromptSnippetsResponseType = Literal["json_schema"]


class FindOnePromptSnippetResponseFormatPromptSnippetsJSONSchemaTypedDict(TypedDict):
    name: str
    strict: bool
    schema_: Dict[str, Any]


class FindOnePromptSnippetResponseFormatPromptSnippetsJSONSchema(BaseModel):
    name: str

    strict: bool

    schema_: Annotated[Dict[str, Any], pydantic.Field(alias="schema")]


class FindOnePromptSnippetResponseFormatPromptSnippets1TypedDict(TypedDict):
    type: FindOnePromptSnippetResponseFormatPromptSnippetsResponseType
    json_schema: FindOnePromptSnippetResponseFormatPromptSnippetsJSONSchemaTypedDict


class FindOnePromptSnippetResponseFormatPromptSnippets1(BaseModel):
    type: FindOnePromptSnippetResponseFormatPromptSnippetsResponseType

    json_schema: FindOnePromptSnippetResponseFormatPromptSnippetsJSONSchema


FindOnePromptSnippetPromptSnippetsResponseFormatTypedDict = TypeAliasType(
    "FindOnePromptSnippetPromptSnippetsResponseFormatTypedDict",
    Union[
        FindOnePromptSnippetResponseFormatPromptSnippets2TypedDict,
        FindOnePromptSnippetResponseFormatPromptSnippets1TypedDict,
    ],
)
r"""An object specifying the format that the model must output.

Setting to `{ \"type\": \"json_schema\", \"json_schema\": {...} }` enables Structured Outputs which ensures the model will match your supplied JSON schema

Setting to `{ \"type\": \"json_object\" }` enables JSON mode, which ensures the message the model generates is valid JSON.

Important: when using JSON mode, you must also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly \"stuck\" request. Also note that the message content may be partially cut off if finish_reason=\"length\", which indicates the generation exceeded max_tokens or the conversation exceeded the max context length.
"""


FindOnePromptSnippetPromptSnippetsResponseFormat = TypeAliasType(
    "FindOnePromptSnippetPromptSnippetsResponseFormat",
    Union[
        FindOnePromptSnippetResponseFormatPromptSnippets2,
        FindOnePromptSnippetResponseFormatPromptSnippets1,
    ],
)
r"""An object specifying the format that the model must output.

Setting to `{ \"type\": \"json_schema\", \"json_schema\": {...} }` enables Structured Outputs which ensures the model will match your supplied JSON schema

Setting to `{ \"type\": \"json_object\" }` enables JSON mode, which ensures the message the model generates is valid JSON.

Important: when using JSON mode, you must also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly \"stuck\" request. Also note that the message content may be partially cut off if finish_reason=\"length\", which indicates the generation exceeded max_tokens or the conversation exceeded the max context length.
"""


FindOnePromptSnippetPromptSnippetsPhotoRealVersion = Literal["v1", "v2"]
r"""The version of photoReal to use. Must be v1 or v2. Only available for `leonardoai` provider"""

FindOnePromptSnippetPromptSnippetsEncodingFormat = Literal["float", "base64"]
r"""The format to return the embeddings"""


class FindOnePromptSnippetPromptSnippetsModelParametersTypedDict(TypedDict):
    r"""Model Parameters: Not all parameters apply to every model"""

    temperature: NotRequired[float]
    r"""Only supported on `chat` and `completion` models."""
    max_tokens: NotRequired[float]
    r"""Only supported on `chat` and `completion` models."""
    top_k: NotRequired[float]
    r"""Only supported on `chat` and `completion` models."""
    top_p: NotRequired[float]
    r"""Only supported on `chat` and `completion` models."""
    frequency_penalty: NotRequired[float]
    r"""Only supported on `chat` and `completion` models."""
    presence_penalty: NotRequired[float]
    r"""Only supported on `chat` and `completion` models."""
    num_images: NotRequired[float]
    r"""Only supported on `image` models."""
    seed: NotRequired[float]
    r"""Best effort deterministic seed for the model. Currently only OpenAI models support these"""
    format_: NotRequired[FindOnePromptSnippetPromptSnippetsFormat]
    r"""Only supported on `image` models."""
    dimensions: NotRequired[str]
    r"""Only supported on `image` models."""
    quality: NotRequired[FindOnePromptSnippetPromptSnippetsQuality]
    r"""Only supported on `image` models."""
    style: NotRequired[str]
    r"""Only supported on `image` models."""
    response_format: NotRequired[
        Nullable[FindOnePromptSnippetPromptSnippetsResponseFormatTypedDict]
    ]
    r"""An object specifying the format that the model must output.

    Setting to `{ \"type\": \"json_schema\", \"json_schema\": {...} }` enables Structured Outputs which ensures the model will match your supplied JSON schema

    Setting to `{ \"type\": \"json_object\" }` enables JSON mode, which ensures the message the model generates is valid JSON.

    Important: when using JSON mode, you must also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly \"stuck\" request. Also note that the message content may be partially cut off if finish_reason=\"length\", which indicates the generation exceeded max_tokens or the conversation exceeded the max context length.
    """
    photo_real_version: NotRequired[FindOnePromptSnippetPromptSnippetsPhotoRealVersion]
    r"""The version of photoReal to use. Must be v1 or v2. Only available for `leonardoai` provider"""
    encoding_format: NotRequired[FindOnePromptSnippetPromptSnippetsEncodingFormat]
    r"""The format to return the embeddings"""


class FindOnePromptSnippetPromptSnippetsModelParameters(BaseModel):
    r"""Model Parameters: Not all parameters apply to every model"""

    temperature: Optional[float] = None
    r"""Only supported on `chat` and `completion` models."""

    max_tokens: Annotated[Optional[float], pydantic.Field(alias="maxTokens")] = None
    r"""Only supported on `chat` and `completion` models."""

    top_k: Annotated[Optional[float], pydantic.Field(alias="topK")] = None
    r"""Only supported on `chat` and `completion` models."""

    top_p: Annotated[Optional[float], pydantic.Field(alias="topP")] = None
    r"""Only supported on `chat` and `completion` models."""

    frequency_penalty: Annotated[
        Optional[float], pydantic.Field(alias="frequencyPenalty")
    ] = None
    r"""Only supported on `chat` and `completion` models."""

    presence_penalty: Annotated[
        Optional[float], pydantic.Field(alias="presencePenalty")
    ] = None
    r"""Only supported on `chat` and `completion` models."""

    num_images: Annotated[Optional[float], pydantic.Field(alias="numImages")] = None
    r"""Only supported on `image` models."""

    seed: Optional[float] = None
    r"""Best effort deterministic seed for the model. Currently only OpenAI models support these"""

    format_: Annotated[
        Optional[FindOnePromptSnippetPromptSnippetsFormat],
        pydantic.Field(alias="format"),
    ] = None
    r"""Only supported on `image` models."""

    dimensions: Optional[str] = None
    r"""Only supported on `image` models."""

    quality: Optional[FindOnePromptSnippetPromptSnippetsQuality] = None
    r"""Only supported on `image` models."""

    style: Optional[str] = None
    r"""Only supported on `image` models."""

    response_format: Annotated[
        OptionalNullable[FindOnePromptSnippetPromptSnippetsResponseFormat],
        pydantic.Field(alias="responseFormat"),
    ] = UNSET
    r"""An object specifying the format that the model must output.

    Setting to `{ \"type\": \"json_schema\", \"json_schema\": {...} }` enables Structured Outputs which ensures the model will match your supplied JSON schema

    Setting to `{ \"type\": \"json_object\" }` enables JSON mode, which ensures the message the model generates is valid JSON.

    Important: when using JSON mode, you must also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly \"stuck\" request. Also note that the message content may be partially cut off if finish_reason=\"length\", which indicates the generation exceeded max_tokens or the conversation exceeded the max context length.
    """

    photo_real_version: Annotated[
        Optional[FindOnePromptSnippetPromptSnippetsPhotoRealVersion],
        pydantic.Field(alias="photoRealVersion"),
    ] = None
    r"""The version of photoReal to use. Must be v1 or v2. Only available for `leonardoai` provider"""

    encoding_format: Optional[FindOnePromptSnippetPromptSnippetsEncodingFormat] = None
    r"""The format to return the embeddings"""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = [
            "temperature",
            "maxTokens",
            "topK",
            "topP",
            "frequencyPenalty",
            "presencePenalty",
            "numImages",
            "seed",
            "format",
            "dimensions",
            "quality",
            "style",
            "responseFormat",
            "photoRealVersion",
            "encoding_format",
        ]
        nullable_fields = ["responseFormat"]
        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


FindOnePromptSnippetPromptSnippetsProvider = Literal[
    "cohere",
    "openai",
    "anthropic",
    "huggingface",
    "replicate",
    "google",
    "google-ai",
    "azure",
    "aws",
    "anyscale",
    "perplexity",
    "groq",
    "fal",
    "leonardoai",
    "nvidia",
    "jina",
    "togetherai",
    "elevenlabs",
]

FindOnePromptSnippetPromptSnippetsRole = Literal[
    "system",
    "assistant",
    "user",
    "exception",
    "tool",
    "prompt",
    "correction",
    "expected_output",
]
r"""The role of the prompt message"""

FindOnePromptSnippet2PromptSnippetsResponse200Type = Literal["image_url"]


class FindOnePromptSnippet2PromptSnippetsImageURLTypedDict(TypedDict):
    url: str
    r"""Either a URL of the image or the base64 encoded data URI."""
    id: NotRequired[str]
    r"""The orq.ai id of the image"""
    detail: NotRequired[str]
    r"""Specifies the detail level of the image. Currently only supported with OpenAI models"""


class FindOnePromptSnippet2PromptSnippetsImageURL(BaseModel):
    url: str
    r"""Either a URL of the image or the base64 encoded data URI."""

    id: Optional[str] = None
    r"""The orq.ai id of the image"""

    detail: Optional[str] = None
    r"""Specifies the detail level of the image. Currently only supported with OpenAI models"""


class FindOnePromptSnippet2PromptSnippets2TypedDict(TypedDict):
    r"""The image part of the prompt message. Only supported with vision models."""

    type: FindOnePromptSnippet2PromptSnippetsResponse200Type
    image_url: FindOnePromptSnippet2PromptSnippetsImageURLTypedDict


class FindOnePromptSnippet2PromptSnippets2(BaseModel):
    r"""The image part of the prompt message. Only supported with vision models."""

    type: FindOnePromptSnippet2PromptSnippetsResponse200Type

    image_url: FindOnePromptSnippet2PromptSnippetsImageURL


FindOnePromptSnippet2PromptSnippetsResponseType = Literal["text"]


class FindOnePromptSnippet2PromptSnippets1TypedDict(TypedDict):
    r"""Text content part of a prompt message"""

    type: FindOnePromptSnippet2PromptSnippetsResponseType
    text: str


class FindOnePromptSnippet2PromptSnippets1(BaseModel):
    r"""Text content part of a prompt message"""

    type: FindOnePromptSnippet2PromptSnippetsResponseType

    text: str


FindOnePromptSnippetContentPromptSnippets2TypedDict = TypeAliasType(
    "FindOnePromptSnippetContentPromptSnippets2TypedDict",
    Union[
        FindOnePromptSnippet2PromptSnippets1TypedDict,
        FindOnePromptSnippet2PromptSnippets2TypedDict,
    ],
)


FindOnePromptSnippetContentPromptSnippets2 = TypeAliasType(
    "FindOnePromptSnippetContentPromptSnippets2",
    Union[FindOnePromptSnippet2PromptSnippets1, FindOnePromptSnippet2PromptSnippets2],
)


FindOnePromptSnippetPromptSnippetsContentTypedDict = TypeAliasType(
    "FindOnePromptSnippetPromptSnippetsContentTypedDict",
    Union[str, List[FindOnePromptSnippetContentPromptSnippets2TypedDict]],
)
r"""The contents of the user message. Either the text content of the message or an array of content parts with a defined type, each can be of type `text` or `image_url` when passing in images. You can pass multiple images by adding multiple `image_url` content parts."""


FindOnePromptSnippetPromptSnippetsContent = TypeAliasType(
    "FindOnePromptSnippetPromptSnippetsContent",
    Union[str, List[FindOnePromptSnippetContentPromptSnippets2]],
)
r"""The contents of the user message. Either the text content of the message or an array of content parts with a defined type, each can be of type `text` or `image_url` when passing in images. You can pass multiple images by adding multiple `image_url` content parts."""


FindOnePromptSnippetPromptSnippetsResponseType = Literal["function"]


class FindOnePromptSnippetPromptSnippetsFunctionTypedDict(TypedDict):
    name: str
    arguments: str
    r"""JSON string arguments for the functions"""


class FindOnePromptSnippetPromptSnippetsFunction(BaseModel):
    name: str

    arguments: str
    r"""JSON string arguments for the functions"""


class FindOnePromptSnippetPromptSnippetsToolCallsTypedDict(TypedDict):
    type: FindOnePromptSnippetPromptSnippetsResponseType
    function: FindOnePromptSnippetPromptSnippetsFunctionTypedDict
    id: NotRequired[str]
    index: NotRequired[float]


class FindOnePromptSnippetPromptSnippetsToolCalls(BaseModel):
    type: FindOnePromptSnippetPromptSnippetsResponseType

    function: FindOnePromptSnippetPromptSnippetsFunction

    id: Optional[str] = None

    index: Optional[float] = None


class FindOnePromptSnippetPromptSnippetsMessagesTypedDict(TypedDict):
    role: FindOnePromptSnippetPromptSnippetsRole
    r"""The role of the prompt message"""
    content: FindOnePromptSnippetPromptSnippetsContentTypedDict
    r"""The contents of the user message. Either the text content of the message or an array of content parts with a defined type, each can be of type `text` or `image_url` when passing in images. You can pass multiple images by adding multiple `image_url` content parts."""
    tool_calls: NotRequired[List[FindOnePromptSnippetPromptSnippetsToolCallsTypedDict]]


class FindOnePromptSnippetPromptSnippetsMessages(BaseModel):
    role: FindOnePromptSnippetPromptSnippetsRole
    r"""The role of the prompt message"""

    content: FindOnePromptSnippetPromptSnippetsContent
    r"""The contents of the user message. Either the text content of the message or an array of content parts with a defined type, each can be of type `text` or `image_url` when passing in images. You can pass multiple images by adding multiple `image_url` content parts."""

    tool_calls: Optional[List[FindOnePromptSnippetPromptSnippetsToolCalls]] = None


class FindOnePromptSnippetPromptSnippetsPromptConfigTypedDict(TypedDict):
    r"""A list of messages compatible with the openAI schema"""

    messages: List[FindOnePromptSnippetPromptSnippetsMessagesTypedDict]
    stream: NotRequired[bool]
    model: NotRequired[str]
    model_db_id: NotRequired[str]
    r"""The id of the resource"""
    model_type: NotRequired[FindOnePromptSnippetPromptSnippetsModelType]
    r"""The type of the model"""
    model_parameters: NotRequired[
        FindOnePromptSnippetPromptSnippetsModelParametersTypedDict
    ]
    r"""Model Parameters: Not all parameters apply to every model"""
    provider: NotRequired[FindOnePromptSnippetPromptSnippetsProvider]
    integration_id: NotRequired[Nullable[str]]
    r"""The id of the resource"""
    version: NotRequired[str]


class FindOnePromptSnippetPromptSnippetsPromptConfig(BaseModel):
    r"""A list of messages compatible with the openAI schema"""

    messages: List[FindOnePromptSnippetPromptSnippetsMessages]

    stream: Optional[bool] = None

    model: Optional[str] = None

    model_db_id: Optional[str] = None
    r"""The id of the resource"""

    model_type: Optional[FindOnePromptSnippetPromptSnippetsModelType] = None
    r"""The type of the model"""

    model_parameters: Optional[FindOnePromptSnippetPromptSnippetsModelParameters] = None
    r"""Model Parameters: Not all parameters apply to every model"""

    provider: Optional[FindOnePromptSnippetPromptSnippetsProvider] = None

    integration_id: OptionalNullable[str] = UNSET
    r"""The id of the resource"""

    version: Optional[str] = None

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = [
            "stream",
            "model",
            "model_db_id",
            "model_type",
            "model_parameters",
            "provider",
            "integration_id",
            "version",
        ]
        nullable_fields = ["integration_id"]
        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


FindOnePromptSnippetPromptSnippetsUseCases = Literal[
    "Agents",
    "Agents simulations",
    "API interaction",
    "Autonomous Agents",
    "Chatbots",
    "Classification",
    "Code understanding",
    "Code writing",
    "Documents QA",
    "Conversation",
    "Extraction",
    "Multi-modal",
    "Self-checking",
    "SQL",
    "Summarization",
    "Tagging",
]

FindOnePromptSnippetPromptSnippetsLanguage = Literal[
    "Chinese", "Dutch", "English", "French", "German", "Russian", "Spanish"
]
r"""The language that the prompt is written in. Use this field to categorize the prompt for your own purpose"""


class FindOnePromptSnippetPromptSnippetsMetadataTypedDict(TypedDict):
    use_cases: NotRequired[List[FindOnePromptSnippetPromptSnippetsUseCases]]
    r"""A list of use cases that the prompt is meant to be used for. Use this field to categorize the prompt for your own purpose"""
    language: NotRequired[FindOnePromptSnippetPromptSnippetsLanguage]
    r"""The language that the prompt is written in. Use this field to categorize the prompt for your own purpose"""


class FindOnePromptSnippetPromptSnippetsMetadata(BaseModel):
    use_cases: Optional[List[FindOnePromptSnippetPromptSnippetsUseCases]] = None
    r"""A list of use cases that the prompt is meant to be used for. Use this field to categorize the prompt for your own purpose"""

    language: Optional[FindOnePromptSnippetPromptSnippetsLanguage] = None
    r"""The language that the prompt is written in. Use this field to categorize the prompt for your own purpose"""


class FindOnePromptSnippetVersionsTypedDict(TypedDict):
    r"""Prompt version model returned from the API"""

    id: str
    display_name: str
    r"""The prompt snippet’s name, meant to be displayable in the UI."""
    prompt_config: FindOnePromptSnippetPromptSnippetsPromptConfigTypedDict
    r"""A list of messages compatible with the openAI schema"""
    metadata: FindOnePromptSnippetPromptSnippetsMetadataTypedDict
    created_by_id: str
    updated_by_id: str
    timestamp: str
    description: NotRequired[Nullable[str]]
    r"""The prompt snippet’s description, meant to be displayable in the UI. Use this field to optionally store a long form explanation of the prompt for your own purpose"""


class FindOnePromptSnippetVersions(BaseModel):
    r"""Prompt version model returned from the API"""

    id: Annotated[str, pydantic.Field(alias="_id")]

    display_name: str
    r"""The prompt snippet’s name, meant to be displayable in the UI."""

    prompt_config: FindOnePromptSnippetPromptSnippetsPromptConfig
    r"""A list of messages compatible with the openAI schema"""

    metadata: FindOnePromptSnippetPromptSnippetsMetadata

    created_by_id: str

    updated_by_id: str

    timestamp: str

    description: OptionalNullable[str] = UNSET
    r"""The prompt snippet’s description, meant to be displayable in the UI. Use this field to optionally store a long form explanation of the prompt for your own purpose"""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = ["description"]
        nullable_fields = ["description"]
        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 FindOnePromptSnippetResponseBodyTypedDict(TypedDict):
    r"""Prompt snippet model returned from the API"""

    id: str
    owner: FindOnePromptSnippetOwnerTypedDict
    domain_id: str
    key: str
    display_name: str
    r"""The prompt snippet’s name, meant to be displayable in the UI."""
    prompt_config: FindOnePromptSnippetPromptConfigTypedDict
    r"""A list of messages compatible with the openAI schema"""
    metadata: FindOnePromptSnippetMetadataTypedDict
    created_by_id: str
    updated_by_id: str
    type: FindOnePromptSnippetType
    versions: List[FindOnePromptSnippetVersionsTypedDict]
    description: NotRequired[Nullable[str]]
    r"""The prompt snippet’s description, meant to be displayable in the UI. Use this field to optionally store a long form explanation of the prompt for your own purpose"""
    created: NotRequired[datetime]
    r"""The date and time the resource was created"""
    updated: NotRequired[datetime]
    r"""The date and time the resource was last updated"""


class FindOnePromptSnippetResponseBody(BaseModel):
    r"""Prompt snippet model returned from the API"""

    id: Annotated[str, pydantic.Field(alias="_id")]

    owner: FindOnePromptSnippetOwner

    domain_id: str

    key: str

    display_name: str
    r"""The prompt snippet’s name, meant to be displayable in the UI."""

    prompt_config: FindOnePromptSnippetPromptConfig
    r"""A list of messages compatible with the openAI schema"""

    metadata: FindOnePromptSnippetMetadata

    created_by_id: str

    updated_by_id: str

    type: FindOnePromptSnippetType

    versions: List[FindOnePromptSnippetVersions]

    description: OptionalNullable[str] = UNSET
    r"""The prompt snippet’s description, meant to be displayable in the UI. Use this field to optionally store a long form explanation of the prompt for your own purpose"""

    created: Optional[datetime] = None
    r"""The date and time the resource was created"""

    updated: Optional[datetime] = dateutil.parser.isoparse("2025-01-29T09:53:28.099Z")
    r"""The date and time the resource was last updated"""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = ["description", "created", "updated"]
        nullable_fields = ["description"]
        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
