JatsTheAIGen's picture
fix: Resolve database permission errors and OMP_NUM_THREADS warning
f5d3311
# 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", "4"))
cache_ttl: int = int(os.getenv("CACHE_TTL", "3600"))
# Database settings
# Use /tmp for database in Docker containers (writable location)
db_path: str = os.getenv("DB_PATH", "/tmp/sessions.db")
faiss_index_path: str = os.getenv("FAISS_INDEX_PATH", "/tmp/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()