File size: 1,251 Bytes
87ceafd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import os
from typing import Optional

class Config:
    """Application configuration"""
    
    # API Keys
    ANTHROPIC_API_KEY: Optional[str] = os.getenv("ANTHROPIC_API_KEY","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")
    
    # Model settings
    MODEL_ID: str = "ds4sd/SmolDocling-256M-preview"
    MAX_PAGES_PER_CHUNK: int = int(os.getenv("MAX_PAGES_PER_CHUNK", "10"))
    MAX_NEW_TOKENS: int = 8192
    
    # Device settings
    DEVICE: str = os.getenv("MODEL_DEVICE", "auto")  # auto, cuda, cpu
    
    # Processing settings
    PDF_DPI: int = 200  # DPI for PDF to image conversion
    
    # Anthropic settings
    ANTHROPIC_MODEL: str = "claude-3-haiku-20240307"
    ANTHROPIC_MAX_TOKENS: int = 4000
    ANTHROPIC_TEMPERATURE: float = 0.3
    
    # Text chunking settings
    MAX_TOKENS_PER_CHUNK: int = 90000  # Half of Claude's context window
    
    @classmethod
    def validate(cls) -> bool:
        """Validate configuration"""
        if not cls.ANTHROPIC_API_KEY:
            print("Warning: ANTHROPIC_API_KEY not set. Summary generation will not be available.")
            return False
        return True

# Create global config instance
config = Config()