# coding: utf-8

"""
    Agent Management API

    API for managing agents, their templates, and call logs

    The version of the OpenAPI document: 1.0.0
    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, StrictBool
from typing import Any, ClassVar, Dict, List, Optional, Union
from typing_extensions import Annotated
from typing import Optional, Set
from typing_extensions import Self

class AgentIdPatchRequestLanguageSwitching(BaseModel):
    """
    Language switching configuration for the agent. If enabled, the agent will be able to switch between languages based on the user's language.
    """ # noqa: E501
    is_enabled: Optional[StrictBool] = Field(default=False, description="Whether to enable language switching for the agent", alias="isEnabled")
    min_words_for_detection: Optional[Union[Annotated[float, Field(le=10, strict=True, ge=1)], Annotated[int, Field(le=10, strict=True, ge=1)]]] = Field(default=2, description="Minimum number of words required for language detection", alias="minWordsForDetection")
    strong_signal_threshold: Optional[Union[Annotated[float, Field(le=0.9, strict=True, ge=0.1)], Annotated[int, Field(le=0, strict=True, ge=1)]]] = Field(default=0.7, description="Threshold for strong language signal detection (0.1 to 0.9)", alias="strongSignalThreshold")
    weak_signal_threshold: Optional[Union[Annotated[float, Field(le=0.9, strict=True, ge=0.1)], Annotated[int, Field(le=0, strict=True, ge=1)]]] = Field(default=0.3, description="Threshold for weak language signal detection (0.1 to 0.9)", alias="weakSignalThreshold")
    min_consecutive_for_weak_threshold_switch: Optional[Union[Annotated[float, Field(le=5, strict=True, ge=1)], Annotated[int, Field(le=5, strict=True, ge=1)]]] = Field(default=2, description="Minimum consecutive detections required for weak threshold language switch", alias="minConsecutiveForWeakThresholdSwitch")
    __properties: ClassVar[List[str]] = ["isEnabled", "minWordsForDetection", "strongSignalThreshold", "weakSignalThreshold", "minConsecutiveForWeakThresholdSwitch"]

    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 AgentIdPatchRequestLanguageSwitching 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 AgentIdPatchRequestLanguageSwitching from a dict"""
        if obj is None:
            return None

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

        _obj = cls.model_validate({
            "isEnabled": obj.get("isEnabled") if obj.get("isEnabled") is not None else False,
            "minWordsForDetection": obj.get("minWordsForDetection") if obj.get("minWordsForDetection") is not None else 2,
            "strongSignalThreshold": obj.get("strongSignalThreshold") if obj.get("strongSignalThreshold") is not None else 0.7,
            "weakSignalThreshold": obj.get("weakSignalThreshold") if obj.get("weakSignalThreshold") is not None else 0.3,
            "minConsecutiveForWeakThresholdSwitch": obj.get("minConsecutiveForWeakThresholdSwitch") if obj.get("minConsecutiveForWeakThresholdSwitch") is not None else 2
        })
        return _obj


