File size: 1,379 Bytes
a2e3298
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a39d8e8
a2e3298
a39d8e8
 
 
 
 
a2e3298
 
 
 
 
 
 
 
 
 
 
 
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
import os
from typing import Optional

class Config:
    """Centralized configuration for the SmolLM API"""
    
    # Server Configuration
    PORT: int = int(os.getenv("PORT", "7860"))
    HOST: str = "0.0.0.0"
    
    # Cache Configuration
    HF_HOME: str = os.getenv("HF_HOME", "/app/cache")
    
    # CPU Configuration
    N_THREADS: int = int(os.getenv("CPU_THREADS", "2"))
    
    # Text Model Configuration
    TEXT_MODEL_REPO: str = "bartowski/SmolLM2-1.7B-Instruct-GGUF"
    TEXT_MODEL_FILE: str = "SmolLM2-1.7B-Instruct-Q4_K_M.gguf"
    TEXT_MODEL_CTX: int = 2048
    TEXT_MODEL_BATCH: int = 512
    
    # Vision Model Configuration
    # FIXED: Corrected capitalization for Repository and Filenames
    VISION_MODEL_REPO: str = "ggml-org/SmolVLM-500M-Instruct-GGUF"
    
    # IMPORTANT: These filenames must match the Repo EXACTLY (Case-Sensitive)
    VISION_MODEL_FILE: str = "SmolVLM-500M-Instruct-Q8_0.gguf"
    VISION_MMPROJ_FILE: str = "mmproj-SmolVLM-500M-Instruct-f16.gguf"
    
    VISION_MODEL_CTX: int = 2048
    VISION_MODEL_BATCH: int = 512
    
    # Default Generation Parameters
    DEFAULT_TEMPERATURE: float = 0.6
    DEFAULT_MAX_TOKENS: int = 512
    
    # File Upload Configuration
    MAX_FILE_SIZE: int = 10 * 1024 * 1024  # 10MB
    ALLOWED_IMAGE_EXTENSIONS: set = {".jpg", ".jpeg", ".png", ".gif", ".webp", ".bmp"}
    
config = Config()