File size: 1,385 Bytes
b5a9373
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""Configuration settings for LegiScan AI Governance Bills Tracker."""
import os
from pathlib import Path
import dotenv

dotenv.load_dotenv()

class ConfigManager:
    def __init__(self):
        """
        Initialize configuration with profile-specific settings.

        Args:
            profile (str): Configuration profile (production, development, testing)
        """
        self._load_base_config()

    def _load_base_config(self):
        """Load base configuration that applies to all profiles."""
        self.OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
        self.OPENAI_LLM_MODEL = os.getenv("OPENAI_LLM_MODEL", "gpt-4o")

    def reload(self):
        """Reload configuration."""
        self._load_base_config()
        self._load_profile_config(self.profile)
        self._validate_config()

    def __str__(self) -> str:
        """Return string representation of non-sensitive config."""
        sensitive_keys = ["OPENAI_API_KEY", "LEGISCAN_API_KEY"]
        config_str = f"Configuration Profile: {self.profile}\n"
        for key, value in self.__dict__.items():
            if key.startswith("_"):
                continue
            if key in sensitive_keys:
                config_str += f"{key}: {'*' * 8}\n"
            else:
                config_str += f"{key}: {value}\n"
        return config_str

# Create default instance
config = ConfigManager()