# coding: utf-8

"""
    Ephor.ai

    Collaborative AI

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

class RetrieveRequest(BaseModel):
    """
    RetrieveRequest
    """ # noqa: E501
    query: StrictStr
    past_messages: Optional[List[Dict[str, Any]]] = None
    library_id: StrictStr
    top_k: Optional[StrictInt] = None
    intent_to_retrieve: Optional[StrictBool] = None
    metadata: Optional[Dict[str, Any]] = None
    shared_context: Optional[StrictBool] = None
    relevant_namespaces: Optional[List[StrictStr]] = None
    folder_structure: Optional[List[Dict[str, Any]]] = None
    require_folder_structure: Optional[StrictBool] = None
    vectorized_query: Optional[Annotated[List[Any], Field(min_length=2, max_length=2)]] = None
    extreme_drop_k: Optional[StrictBool] = None
    __properties: ClassVar[List[str]] = ["query", "past_messages", "library_id", "top_k", "intent_to_retrieve", "metadata", "shared_context", "relevant_namespaces", "folder_structure", "require_folder_structure", "vectorized_query", "extreme_drop_k"]

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

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

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

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

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

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

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

        return _dict

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

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

        _obj = cls.model_validate({
            "query": obj.get("query"),
            "past_messages": obj.get("past_messages"),
            "library_id": obj.get("library_id"),
            "top_k": obj.get("top_k"),
            "intent_to_retrieve": obj.get("intent_to_retrieve"),
            "metadata": obj.get("metadata"),
            "shared_context": obj.get("shared_context"),
            "relevant_namespaces": obj.get("relevant_namespaces"),
            "folder_structure": obj.get("folder_structure"),
            "require_folder_structure": obj.get("require_folder_structure"),
            "vectorized_query": obj.get("vectorized_query"),
            "extreme_drop_k": obj.get("extreme_drop_k")
        })
        return _obj


