# coding: utf-8

"""
    RAGsys API

     RAGSys API is an innovative AI retrieval engine developed by Crossing Minds to enhance  Large Language Model (LLM) performance without the need for traditional fine-tuning.  By integrating Retrieval-Augmented Generation (RAG) techniques, RAGSys enables seamless adaptation  of LLMs to various tasks and domains, offering a cost-effective and scalable solution for  enterprises.   Key Features of RAGSys:  - **Seamless Integration**: Compatible with any LLM, including those from Anthropic, OpenAI, and open-source alternatives, allowing effortless switching between models without losing optimizations.  - **Enhanced Retrieval with RAG Embeddings**: Utilizes proprietary RAG embeddings to ensure better understanding and rapid information retrieval, even with massive datasets, resulting in more contextually relevant and accurate LLM outputs.  - **Groundbreaking Accuracy Improvements**: Consistently outperforms traditional fine-tuning, achieving up to a 76% improvement on key benchmarks, with significant enhancements in truthfulness, emotion detection, and commonsense reasoning across various LLMs.  - **Scalable Architecture**: Designed for enterprise-scale deployment, efficiently handling large datasets and complex retrieval tasks, ensuring consistent performance as AI needs grow.   By leveraging RAGSys, organizations can rapidly adapt LLMs to new tasks or domains, saving computational resources and accelerating deployment cycles, all while maintaining high levels of accuracy and relevance in AI outputs.  

    The version of the OpenAPI document: 1.0.0
    Contact: contact@crossingminds.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, StrictInt
from typing import Any, ClassVar, Dict, List, Optional
from ragsys.models.database_item import DatabaseItem
from typing import Optional, Set
from typing_extensions import Self

class DatabaseListResponse(BaseModel):
    """
    DatabaseListResponse
    """ # noqa: E501
    databases: List[DatabaseItem] = Field(description="List of databases")
    has_next: Optional[StrictBool] = None
    next_page: Optional[StrictInt] = None
    __properties: ClassVar[List[str]] = ["databases", "has_next", "next_page"]

    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 DatabaseListResponse 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,
        )
        # override the default output from pydantic by calling `to_dict()` of each item in databases (list)
        _items = []
        if self.databases:
            for _item_databases in self.databases:
                if _item_databases:
                    _items.append(_item_databases.to_dict())
            _dict['databases'] = _items
        # set to None if has_next (nullable) is None
        # and model_fields_set contains the field
        if self.has_next is None and "has_next" in self.model_fields_set:
            _dict['has_next'] = None

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

        return _dict

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

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

        _obj = cls.model_validate({
            "databases": [DatabaseItem.from_dict(_item) for _item in obj["databases"]] if obj.get("databases") is not None else None,
            "has_next": obj.get("has_next"),
            "next_page": obj.get("next_page")
        })
        return _obj


