Spaces:
Sleeping
Sleeping
Download core/config.py from GodRad/engine-space: direct link, hf CLI and curl.
- Browser
- Download file 1.53 kB
-
https://huggingface.co/spaces/GodRad/engine-space/resolve/main/core/config.py
- Command line
-
hf download hf://spaces/GodRad/engine-space/core/config.py
-
curl -L -o config.py https://huggingface.co/spaces/GodRad/engine-space/resolve/main/core/config.py
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) | |