# coding: utf-8

"""
    Mixpeek API

    This is the Mixpeek API, providing access to various endpoints for data processing and retrieval.

    The version of the OpenAPI document: 1.3.0
    Contact: info@mixpeek.com
    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, StrictStr, field_validator
from typing import Any, ClassVar, Dict, List, Optional
from typing_extensions import Annotated
from typing import Optional, Set
from typing_extensions import Self

class SentimentClassifierParams(BaseModel):
    """
    Parameters for sentiment classifier.
    """ # noqa: E501
    extractor_type: Optional[StrictStr] = Field(default='sentiment_classifier', description="Discriminator field for parameter type identification.")
    model_name: Optional[StrictStr] = Field(default='distilbert-base-uncased-finetuned-sst-2-english', description="HuggingFace model name for sentiment classification")
    max_length: Optional[Annotated[int, Field(le=1024, strict=True, ge=32)]] = Field(default=512, description="Maximum token length")
    batch_size: Optional[Annotated[int, Field(le=128, strict=True, ge=1)]] = Field(default=32, description="Inference batch size")
    return_all_scores: Optional[StrictBool] = Field(default=True, description="Return scores for all classes, not just top")
    embed: Optional[StrictBool] = Field(default=False, description="Generate E5 embeddings for semantic retrieval alongside classification. Uses the internal E5 embedding service for 1024-dimensional vectors.")
    __properties: ClassVar[List[str]] = ["extractor_type", "model_name", "max_length", "batch_size", "return_all_scores", "embed"]

    @field_validator('extractor_type')
    def extractor_type_validate_enum(cls, value):
        """Validates the enum"""
        if value is None:
            return value

        if value not in set(['sentiment_classifier']):
            raise ValueError("must be one of enum values ('sentiment_classifier')")
        return value

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

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

        _obj = cls.model_validate({
            "extractor_type": obj.get("extractor_type") if obj.get("extractor_type") is not None else 'sentiment_classifier',
            "model_name": obj.get("model_name") if obj.get("model_name") is not None else 'distilbert-base-uncased-finetuned-sst-2-english',
            "max_length": obj.get("max_length") if obj.get("max_length") is not None else 512,
            "batch_size": obj.get("batch_size") if obj.get("batch_size") is not None else 32,
            "return_all_scores": obj.get("return_all_scores") if obj.get("return_all_scores") is not None else True,
            "embed": obj.get("embed") if obj.get("embed") is not None else False
        })
        return _obj


