# coding: utf-8

"""
    Docling Serve

    No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)

    The version of the OpenAPI document: 
    Generated by OpenAPI Generator (https://openapi-generator.tech)

    Do not edit the class manually.
"""  # noqa: E501


from __future__ import annotations
import pprint
import re  # noqa: F401
import json

from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional, Union
from typing_extensions import Annotated
from yfkm3_services_parse_client.models.response_format import ResponseFormat
from typing import Optional, Set
from typing_extensions import Self
from pydantic_core import to_jsonable_python

class VlmModelApi(BaseModel):
    """
    VlmModelApi
    """ # noqa: E501
    url: Annotated[str, Field(min_length=1, strict=True)] = Field(description="Endpoint which accepts openai-api compatible requests.")
    headers: Optional[Dict[str, StrictStr]] = Field(default=None, description="Headers used for calling the API endpoint. For example, it could include authentication headers.")
    params: Optional[Dict[str, Any]] = Field(default=None, description="Model parameters.")
    timeout: Optional[Union[StrictFloat, StrictInt]] = Field(default=60, description="Timeout for the API request.")
    concurrency: Optional[Annotated[int, Field(strict=True, gt=0)]] = Field(default=1, description="Maximum number of concurrent requests to the API.")
    prompt: Optional[StrictStr] = Field(default='Convert this page to docling.', description="Prompt used when calling the vision-language model.")
    scale: Optional[Union[StrictFloat, StrictInt]] = Field(default=2.0, description="Scale factor of the images used.")
    response_format: ResponseFormat = Field(description="Type of response generated by the model.")
    temperature: Optional[Union[StrictFloat, StrictInt]] = Field(default=0.0, description="Temperature parameter controlling the reproducibility of the result.")
    __properties: ClassVar[List[str]] = ["url", "headers", "params", "timeout", "concurrency", "prompt", "scale", "response_format", "temperature"]

    model_config = ConfigDict(
        validate_by_name=True,
        validate_by_alias=True,
        validate_assignment=True,
        protected_namespaces=(),
    )


    def to_str(self) -> str:
        """Returns the string representation of the model using alias"""
        return pprint.pformat(self.model_dump(by_alias=True))

    def to_json(self) -> str:
        """Returns the JSON representation of the model using alias"""
        return json.dumps(to_jsonable_python(self.to_dict()))

    @classmethod
    def from_json(cls, json_str: str) -> Optional[Self]:
        """Create an instance of VlmModelApi from a JSON string"""
        return cls.from_dict(json.loads(json_str))

    def to_dict(self) -> Dict[str, Any]:
        """Return the dictionary representation of the model using alias.

        This has the following differences from calling pydantic's
        `self.model_dump(by_alias=True)`:

        * `None` is only added to the output dict for nullable fields that
          were set at model initialization. Other fields with value `None`
          are ignored.
        """
        excluded_fields: Set[str] = set([
        ])

        _dict = self.model_dump(
            by_alias=True,
            exclude=excluded_fields,
            exclude_none=True,
        )
        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of VlmModelApi from a dict"""
        if obj is None:
            return None

        if not isinstance(obj, dict):
            return cls.model_validate(obj)

        _obj = cls.model_validate({
            "url": obj.get("url"),
            "headers": obj.get("headers"),
            "params": obj.get("params"),
            "timeout": obj.get("timeout") if obj.get("timeout") is not None else 60,
            "concurrency": obj.get("concurrency") if obj.get("concurrency") is not None else 1,
            "prompt": obj.get("prompt") if obj.get("prompt") is not None else 'Convert this page to docling.',
            "scale": obj.get("scale") if obj.get("scale") is not None else 2.0,
            "response_format": obj.get("response_format"),
            "temperature": obj.get("temperature") if obj.get("temperature") is not None else 0.0
        })
        return _obj


