File size: 1,526 Bytes
ec77441
 
 
 
 
 
 
 
 
 
 
f299bbf
ec77441
 
 
 
1269709
 
ec77441
1269709
 
 
ec77441
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
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)