# coding: utf-8

"""
    

    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 import Optional, Set
from typing_extensions import Self

class LLMSamplingParams(BaseModel):
    """
    Sampling and generation parameters for controlling LLM text output
    """ # noqa: E501
    max_tokens: Optional[StrictInt] = Field(default=None, description="Maximum tokens to generate (>0 if set; provider-dependent limits apply)", alias="maxTokens")
    temperature: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Sampling temperature 0.0-2.0 (0.0=deterministic, 2.0=highly random)")
    top_p: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Nucleus sampling threshold 0.0-1.0 (smaller values focus on higher probability tokens)", alias="topP")
    top_k: Optional[StrictInt] = Field(default=None, description="Top-k sampling limit (>0 if set; primarily for local/open-source models)", alias="topK")
    frequency_penalty: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Frequency penalty -2.0 to 2.0 (positive values reduce repetition based on frequency)", alias="frequencyPenalty")
    presence_penalty: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Presence penalty -2.0 to 2.0 (positive values encourage topic diversity)", alias="presencePenalty")
    stop_sequences: Optional[List[StrictStr]] = Field(default=None, description="Generation stop sequences (≤10 sequences; each ≤100 chars; generation halts on exact match)", alias="stopSequences")
    __properties: ClassVar[List[str]] = ["maxTokens", "temperature", "topP", "topK", "frequencyPenalty", "presencePenalty", "stopSequences"]

    model_config = ConfigDict(
        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) -> Optional[Self]:
        """Create an instance of LLMSamplingParams 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,
        )
        # set to None if max_tokens (nullable) is None
        # and model_fields_set contains the field
        if self.max_tokens is None and "max_tokens" in self.model_fields_set:
            _dict['maxTokens'] = None

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

        # set to None if top_p (nullable) is None
        # and model_fields_set contains the field
        if self.top_p is None and "top_p" in self.model_fields_set:
            _dict['topP'] = 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['topK'] = None

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

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

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

        return _dict

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

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

        _obj = cls.model_validate({
            "maxTokens": obj.get("maxTokens"),
            "temperature": obj.get("temperature"),
            "topP": obj.get("topP"),
            "topK": obj.get("topK"),
            "frequencyPenalty": obj.get("frequencyPenalty"),
            "presencePenalty": obj.get("presencePenalty"),
            "stopSequences": obj.get("stopSequences")
        })
        return _obj


