from pathlib import Path
from pydantic_settings import BaseSettings, SettingsConfigDict
from dotenv import load_dotenv

load_dotenv()

class Settings(BaseSettings):
    raw_path_: str 
    data_path_: str
    processed_path_: str 
    models_path_: str 
    external_path_: str 
    kubeconfig_path: str 
    interim_path_: str 
    database_url: str 
    openai_api_key: str 
    elasticsearch_index: str 
    elasticsearch_docs_index: str 
    elasticsearch_code_index: str 
    llm_base_url: str 
    ollama_url: str 
    ollama_local_url: str 
    langfuse_host: str 
    elasticsearch_url: str 
    elasticsearch_local_url: str 
    ollama_model_name: str 
    ollama_emb_model_name: str 
    model_name: str 
    hf_emb_model_name: str 
    langfuse_public_key: str 
    langfuse_secret_key: str 
    hf_token: str 

    model_config = SettingsConfigDict(
        env_file=".env",
        env_file_encoding="utf-8",
        case_sensitive=False,
        extra="ignore",
    )

    @property
    def proj_root(self) -> Path:
        return Path(__file__).resolve().parents[1]

    @property
    def data_path(self) -> Path:
        proj_root = self.proj_root
        return proj_root / self.data_path_
    
    @property
    def models_path(self) -> Path:
        proj_root = self.proj_root
        return proj_root / self.models_path_

    @property
    def processed_path(self) -> Path:
        proj_root = self.proj_root
        return proj_root / self.processed_path_

    @property
    def raw_path(self) -> Path:
        proj_root = self.proj_root
        return proj_root / self.raw_path_

    @property
    def interim_path(self) -> Path:
        proj_root = self.proj_root
        return proj_root / self.interim_path_

    @property
    def external_path(self) -> Path:
        proj_root = self.proj_root
        return proj_root / self.external_path_

    @property
    def database_url(self) -> str:
        return self.database_url

    @property
    def openai_api_key(self) -> str:
        return self.openai_api_key

    @property
    def elasticsearch_index(self) -> str:
        return self.elasticsearch_index

    @property
    def elasticsearch_docs_index(self) -> str:
        return self.elasticsearch_docs_index

    @property
    def elasticsearch_code_index(self) -> str:
        return self.elasticsearch_code_index

    @property
    def llm_base_url(self) -> str:
        return self.llm_base_url

    @property
    def ollama_url(self) -> str:
        return self.ollama_url

    @property
    def ollama_local_url(self) -> str:
        return self.ollama_local_url

    @property
    def langfuse_host(self) -> str:
        return self.langfuse_host

    @property
    def elasticsearch_url(self) -> str:
        return self.elasticsearch_url

    @property
    def elasticsearch_local_url(self) -> str:
        return self.elasticsearch_local_url

    @property
    def ollama_model_name(self) -> str:
        return self.ollama_model_name

    @property
    def ollama_emb_model_name(self) -> str:
        return self.ollama_emb_model_name

    @property
    def model_name(self) -> str:
        return self.model_name

    @property
    def hf_emb_model_name(self) -> str:
        return self.hf_emb_model_name

    @property
    def langfuse_public_key(self) -> str:
        return self.langfuse_public_key

    @property
    def langfuse_secret_key(self) -> str:
        return self.langfuse_secret_key

    @property
    def hf_token(self) -> str:
        return self.hf_token

    @property
    def kubeconfig_path(self) -> Path:
        proj_root = self.proj_root
        return proj_root / self.kubeconfig_path

settings = Settings()