File size: 942 Bytes
50231a8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2d0ef3b
 
50231a8
2571402
50231a8
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from functools import lru_cache
from pathlib import Path

from pydantic import Field
from pydantic_settings import BaseSettings, SettingsConfigDict


class Settings(BaseSettings):
    model_config = SettingsConfigDict(env_file=".env", env_file_encoding="utf-8", extra="ignore")

    app_name: str = "Classifier General API"
    environment: str = "development"
    debug: bool = False

    static_dir: Path = Path("static")
    upload_subdir: str = "uploads"

    classifier_model: str = "AyoubChLin/bert-base-uncased-zeroshot-nli"
    enable_model_quantization: bool = True
    huggingface_token: str | None = None
    classifier_entailment_label_id: int | None = None

    default_labels_csv: str = Field(default="news,sport,finance,politics")

    @property
    def upload_dir(self) -> Path:
        return self.static_dir / self.upload_subdir


@lru_cache
def get_settings() -> Settings:
    return Settings()


settings = get_settings()