# coding: utf-8

"""
    ollm-api

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

    The version of the OpenAPI document: 0.1
    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 typing import Any, ClassVar, Dict, List, Optional
from pydantic import BaseModel, StrictBool, StrictInt
try:
    from typing import Self
except ImportError:
    from typing_extensions import Self

class ChatCompletionRequestExtVLLM(BaseModel):
    """
    ChatCompletionRequestExtVLLM
    """ # noqa: E501
    best_of: Optional[StrictInt] = None
    ignore_eos: Optional[StrictBool] = None
    skip_special_tokens: Optional[StrictBool] = None
    stop_token_ids: Optional[Any] = None
    top_k: Optional[StrictInt] = None
    use_beam_search: Optional[StrictBool] = None
    __properties: ClassVar[List[str]] = ["best_of", "ignore_eos", "skip_special_tokens", "stop_token_ids", "top_k", "use_beam_search"]

    model_config = {
        "populate_by_name": 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"""
        # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
        return json.dumps(self.to_dict())

    @classmethod
    def from_json(cls, json_str: str) -> Self:
        """Create an instance of ChatCompletionRequestExtVLLM 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.
        """
        _dict = self.model_dump(
            by_alias=True,
            exclude={
            },
            exclude_none=True,
        )
        # override the default output from pydantic by calling `to_dict()` of stop_token_ids
        if self.stop_token_ids:
            _dict['stop_token_ids'] = self.stop_token_ids.to_dict()
        # set to None if best_of (nullable) is None
        # and model_fields_set contains the field
        if self.best_of is None and "best_of" in self.model_fields_set:
            _dict['best_of'] = None

        # set to None if ignore_eos (nullable) is None
        # and model_fields_set contains the field
        if self.ignore_eos is None and "ignore_eos" in self.model_fields_set:
            _dict['ignore_eos'] = None

        # set to None if skip_special_tokens (nullable) is None
        # and model_fields_set contains the field
        if self.skip_special_tokens is None and "skip_special_tokens" in self.model_fields_set:
            _dict['skip_special_tokens'] = None

        # set to None if stop_token_ids (nullable) is None
        # and model_fields_set contains the field
        if self.stop_token_ids is None and "stop_token_ids" in self.model_fields_set:
            _dict['stop_token_ids'] = None

        # set to None if top_k (nullable) is None
        # and model_fields_set contains the field
        if self.top_k is None and "top_k" in self.model_fields_set:
            _dict['top_k'] = None

        # set to None if use_beam_search (nullable) is None
        # and model_fields_set contains the field
        if self.use_beam_search is None and "use_beam_search" in self.model_fields_set:
            _dict['use_beam_search'] = None

        return _dict

    @classmethod
    def from_dict(cls, obj: Dict) -> Self:
        """Create an instance of ChatCompletionRequestExtVLLM from a dict"""
        if obj is None:
            return None

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

        _obj = cls.model_validate({
            "best_of": obj.get("best_of"),
            "ignore_eos": obj.get("ignore_eos"),
            "skip_special_tokens": obj.get("skip_special_tokens"),
            "stop_token_ids": AnyOf.from_dict(obj.get("stop_token_ids")) if obj.get("stop_token_ids") is not None else None,
            "top_k": obj.get("top_k"),
            "use_beam_search": obj.get("use_beam_search")
        })
        return _obj


