engine-space / core /config.py
GodRad's picture
Upload 6 files
f299bbf verified
Raw History Blame Contribute Delete
1.53 kB
import os
from pydantic_settings import BaseSettings
from typing import Optional
class Settings(BaseSettings):
# App Settings
APP_NAME: str = "Open Source Syllabus Engine"
DEBUG: bool = False
PORT: int = 7860
# Storage Settings
PERSISTENT_STORAGE_PATH: str = os.getenv("PERSISTENT_STORAGE_PATH", os.path.expanduser("~/data"))
CHROMA_DB_PATH: str = os.path.join(PERSISTENT_STORAGE_PATH, "chromadb")
UPLOAD_DIR: str = os.path.join(PERSISTENT_STORAGE_PATH, "uploads")
# Model Settings
# For CPU: a smaller model suitable for CPU inference via Transformers
# For GPU: a larger model
MODEL_ID_GPU: str = "meta-llama/Meta-Llama-3.1-8B-Instruct"
# Using a quantized-friendly or smaller model for CPU if available, or just the same base model
# For this transition, we'll use a smaller Llama model that is naturally supported
MODEL_ID_CPU: str = "meta-llama/Llama-3.2-1B-Instruct"
DEVICE: str = os.getenv("DEVICE", "cpu") # "cpu" or "cuda"
# Security
API_KEY: Optional[str] = os.getenv("API_KEY") # Secret set in HF Spaces
HF_TOKEN: Optional[str] = os.getenv("HF_TOKEN")
# Constraints
MAX_FILE_SIZE: int = 10 * 1024 * 1024 # 10MB
CHUNK_SIZE: int = 1000
CHUNK_OVERLAP: int = 200
class Config:
env_file = ".env"
settings = Settings()
# Ensure directories exist
os.makedirs(settings.UPLOAD_DIR, exist_ok=True)
os.makedirs(settings.CHROMA_DB_PATH, exist_ok=True)