import logging

from pydantic_settings import BaseSettings
from dotenv import load_dotenv

log = logging.getLogger(__name__)
if not load_dotenv():
    log.error(".env file not found.")

class ApplicationSettings(BaseSettings):
    """Define application configuration model.

    Constructor will attempt to determine the values of any fields not passed
    as keyword arguments by reading from the environment. Default values will
    still be used if the matching environment variable is not set.

    Environment variables:
        * FASTAPI_DEBUG
        * FASTAPI_PROJECT_NAME
        * FASTAPI_VERSION
        * FASTAPI_DOCS_URL
        * FASTAPI_USE_REDIS

    Attributes:
        DEBUG (bool): FastAPI logging level. You should disable this for
            production.
        PROJECT_NAME (str): FastAPI project name.
        VERSION (str): Application version.
        DOCS_URL (str): Path where swagger ui will be served at.
        USE_REDIS (bool): Whether or not to use Redis.

    """

    DEBUG: bool = True
    PROJECT_NAME: str = "CHAT_WITH_DATA"
    DOCS_URL: str = "/"
    OPENAI_KEY: str = ''
    DB_USERNAME: str = ''
    DB_PASSWORD: str = ''
    DB_NAME:str = ''
    DB_HOST: str = ''
    TOKEN: str = ''

    class Config:
        case_sensitive = True
        env_prefix = "CWD_"


settings = ApplicationSettings()
