Spaces:
Sleeping
Sleeping
File size: 1,094 Bytes
ae4e2a6 |
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 37 38 39 40 41 42 43 44 45 46 47 |
"""
Core Configuration
==================
Application settings using Pydantic Settings
"""
from pydantic_settings import BaseSettings
from typing import List
import torch
class Settings(BaseSettings):
"""Application settings"""
# Model Configuration
MODEL_NAME: str = "vinai/phobert-base"
MODEL_PATH: str = "./models/PhoBERTFineTuned_best.pth"
MAX_LENGTH: int = 128
DEVICE: str = "cuda" if torch.cuda.is_available() else "cpu"
# API Configuration
API_TITLE: str = "Toxic Text Detection API"
API_VERSION: str = "1.0.0"
API_DESCRIPTION: str = "Vietnamese toxic text detection with gradient-based explainability"
API_HOST: str = "0.0.0.0"
API_PORT: int = 8000
API_RELOAD: bool = True
# CORS
ALLOWED_ORIGINS: List[str] = ["*"]
# Analysis Settings
GRADIENT_STEPS: int = 20
PERCENTILE_THRESHOLD: int = 75
MIN_WORD_LENGTH: int = 2
# Logging
LOG_LEVEL: str = "INFO"
class Config:
env_file = ".env"
case_sensitive = True
# Singleton instance
settings = Settings()
|