import json from pathlib import Path from typing import Dict, Any from dataclasses import dataclass, asdict @dataclass class Config: """Configuration management for the notification system.""" ollama_endpoint: str = "http://localhost:11434" ollama_model: str = "llama2" # Silent time configuration (12pm to 8am) silent_start: str = "20:00" silent_end: str = "12:00" timezone: str = "UTC" # Interval configuration (in minutes) min_interval: int = 3 max_interval: int = 180 # Bark notification service bark_api_url: str = "" bark_device_key: str = "" # Ntfy notification service ntfy_api_url: str = "" ntfy_topic: str = "" ntfy_access_token: str = "" # Template settings templates_dir: str = "templates" def __post_init__(self): """Load configuration from file if exists.""" config_file = Path("config/config.json") if config_file.exists(): with open(config_file, 'r') as f: data = json.load(f) for key, value in data.items(): if hasattr(self, key): setattr(self, key, value) def save(self): """Save current configuration to file.""" config_file = Path("config/config.json") with open(config_file, 'w') as f: json.dump(asdict(self), f, indent=2)