File size: 1,973 Bytes
66fef64
 
 
 
 
 
b8ca8ae
66fef64
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0236fb6
b8ca8ae
 
 
 
 
 
 
 
 
 
 
 
 
 
0236fb6
66fef64
 
 
b8ca8ae
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66fef64
 
 
 
 
 
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
"""
Settings and environment configuration
"""
import os
from functools import lru_cache
from pydantic_settings import BaseSettings
from typing import Optional


class Settings(BaseSettings):
    """Application settings"""
    
    # OpenAI API key for embeddings
    openai_api_key: str
    
    # TMDB API key for movie data
    tmdb_api_key: str
    
    # API authentication token
    api_token: str
    
    # Environment (dev/prod)
    env: str = "dev"
    
    # Logging level
    log_level: str = "INFO"
    
    # Filter adult content (True = exclude adult films, False = include all)
    filter_adult_content: Optional[str] = "true"
    
    # Hugging Face configuration
    hf_token: str = ""
    hf_dataset_repo: str = ""
    
    # Vector update configuration
    auto_update_vectors: Optional[str] = "true"
    update_interval_hours: int = 24
    batch_size: int = 100
    max_movies_limit: int = 10000
    
    # Admin configuration
    admin_token: str = ""

    class Config:
        env_file = ".env"
        env_file_encoding = "utf-8"
    
    @property
    def filter_adult_content_bool(self) -> bool:
        """Parse filter_adult_content as boolean"""
        if isinstance(self.filter_adult_content, str):
            # Remove any comments and strip whitespace
            value = self.filter_adult_content.split('#')[0].strip().lower()
            return value in ('true', '1', 'yes', 'on')
        return bool(self.filter_adult_content)
    
    @property
    def auto_update_vectors_bool(self) -> bool:
        """Parse auto_update_vectors as boolean"""
        if isinstance(self.auto_update_vectors, str):
            # Remove any comments and strip whitespace
            value = self.auto_update_vectors.split('#')[0].strip().lower()
            return value in ('true', '1', 'yes', 'on')
        return bool(self.auto_update_vectors)


@lru_cache()
def get_settings() -> Settings:
    """Get cached settings instance"""
    return Settings()