# coding: utf-8

"""
    smritea SDK API

    Public SDK API for smritea AI memory system — programmatic memory operations via API key

    The version of the OpenAPI document: 1.0.0
    Contact: support@smritea.ai
    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, StrictFloat, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional, Union
from typing import Optional, Set
from typing_extensions import Self

class CommondtoEntityExtractionConfig(BaseModel):
    """
    CommondtoEntityExtractionConfig
    """ # noqa: E501
    context_window: Optional[StrictInt] = Field(default=None, description="ContextWindow is the number of previous messages to include in context. Only used when EnableContext is true. 0 means use default (10 messages).")
    enable_context: Optional[StrictBool] = Field(default=None, description="EnableContext enables context-aware extraction using conversation history. When true, extraction considers previous messages in the conversation for better entity resolution and relationship detection.")
    entity_types: Optional[List[StrictStr]] = Field(default=None, description="EntityTypes filters which entity types to extract (empty = all types). Valid types: person, organization, concept, location, event, product, other")
    fallback_messages: Optional[StrictInt] = Field(default=None, description="FallbackMessages is the minimum number of messages to include even if the conversation is shorter than ContextWindow. Prevents empty context.")
    max_passes: Optional[StrictInt] = Field(default=None, description="MaxPasses controls how many extraction passes to perform. -1 = explicitly skip entity extraction (sentinel value). 0 = not specified (Go zero value), use default. 1-5 = run N extraction passes. Multiple passes can improve extraction quality but increase cost and latency.")
    max_tokens: Optional[StrictInt] = Field(default=None, description="MaxTokens is the maximum completion tokens for LLM responses. 0 = not set (use default). Higher values allow more entities but increase cost. TODO(https://linear.app/bityantriki/issue/BIT-83): revert gte=0 to gte=100 once pedantigo applies defaults to nested structs during Validate()")
    min_confidence: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="MinConfidence is the minimum confidence threshold for extracted entities (0.0 to 1.0). Entities below this threshold are filtered out.")
    model: Optional[StrictStr] = Field(default=None, description="Model is the LLM model to use (empty = use provider default). Examples: \"gpt-4\", \"gpt-3.5-turbo\", \"llama-3.3-70b-versatile\"")
    temperature: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Temperature controls LLM randomness (0.0 = deterministic, higher = creative). For extraction, lower values (0.0-0.3) are recommended for consistency.")
    __properties: ClassVar[List[str]] = ["context_window", "enable_context", "entity_types", "fallback_messages", "max_passes", "max_tokens", "min_confidence", "model", "temperature"]

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

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

        _obj = cls.model_validate({
            "context_window": obj.get("context_window"),
            "enable_context": obj.get("enable_context"),
            "entity_types": obj.get("entity_types"),
            "fallback_messages": obj.get("fallback_messages"),
            "max_passes": obj.get("max_passes"),
            "max_tokens": obj.get("max_tokens"),
            "min_confidence": obj.get("min_confidence"),
            "model": obj.get("model"),
            "temperature": obj.get("temperature")
        })
        return _obj


