File size: 1,486 Bytes
66dbebd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# config.py
import os
from pydantic_settings import BaseSettings

class Settings(BaseSettings):
    # HF Spaces specific settings
    hf_token: str = os.getenv("HF_TOKEN", "")
    hf_cache_dir: str = os.getenv("HF_HOME", "/tmp/huggingface")
    
    # Model settings
    default_model: str = "mistralai/Mistral-7B-Instruct-v0.2"
    embedding_model: str = "sentence-transformers/all-MiniLM-L6-v2"
    classification_model: str = "cardiffnlp/twitter-roberta-base-emotion"
    
    # Performance settings
    max_workers: int = int(os.getenv("MAX_WORKERS", "2"))
    cache_ttl: int = int(os.getenv("CACHE_TTL", "3600"))
    
    # Database settings
    db_path: str = os.getenv("DB_PATH", "sessions.db")
    faiss_index_path: str = os.getenv("FAISS_INDEX_PATH", "embeddings.faiss")
    
    # Session settings
    session_timeout: int = int(os.getenv("SESSION_TIMEOUT", "3600"))
    max_session_size_mb: int = int(os.getenv("MAX_SESSION_SIZE_MB", "10"))
    
    # Mobile optimization settings
    mobile_max_tokens: int = int(os.getenv("MOBILE_MAX_TOKENS", "800"))
    mobile_timeout: int = int(os.getenv("MOBILE_TIMEOUT", "15000"))
    
    # Gradio settings
    gradio_port: int = int(os.getenv("GRADIO_PORT", "7860"))
    gradio_host: str = os.getenv("GRADIO_HOST", "0.0.0.0")
    
    # Logging settings
    log_level: str = os.getenv("LOG_LEVEL", "INFO")
    log_format: str = os.getenv("LOG_FORMAT", "json")
    
    class Config:
        env_file = ".env"

settings = Settings()