adding ai summary - default is disabled

This commit is contained in:
2026-01-26 17:13:11 -06:00
parent 2820944ec6
commit 921b6a81a4
13 changed files with 1357 additions and 43 deletions

View File

@@ -63,6 +63,35 @@ class AlertSettings:
rules: AlertRules = field(default_factory=AlertRules)
@dataclass
class AISettings:
"""AI summarization settings."""
enabled: bool = False
model: str = "meta/meta-llama-3-8b-instruct"
api_timeout: int = 60
max_tokens: int = 500
api_token: str = ""
@dataclass
class ChangeThresholds:
"""Thresholds for detecting significant changes between runs."""
temperature: float = 5.0
wind_speed: float = 10.0
wind_gust: float = 10.0
precipitation_prob: float = 20.0
@dataclass
class ChangeDetectionSettings:
"""Change detection settings."""
enabled: bool = True
thresholds: ChangeThresholds = field(default_factory=ChangeThresholds)
@dataclass
class AppConfig:
"""Complete application configuration."""
@@ -72,6 +101,8 @@ class AppConfig:
alerts: AlertSettings = field(default_factory=AlertSettings)
notifications: NotificationSettings = field(default_factory=NotificationSettings)
state: StateSettings = field(default_factory=StateSettings)
ai: AISettings = field(default_factory=AISettings)
change_detection: ChangeDetectionSettings = field(default_factory=ChangeDetectionSettings)
def load_config(
@@ -113,6 +144,8 @@ def load_config(
alerts_data = config_data.get("alerts", {})
notifications_data = config_data.get("notifications", {})
state_data = config_data.get("state", {})
ai_data = config_data.get("ai", {})
change_detection_data = config_data.get("change_detection", {})
# Build app settings
app_settings = AppSettings(
@@ -150,10 +183,34 @@ def load_config(
dedup_window_hours=state_data.get("dedup_window_hours", 24),
)
# Build AI settings with token from environment
ai_settings = AISettings(
enabled=ai_data.get("enabled", False),
model=ai_data.get("model", "meta/meta-llama-3-8b-instruct"),
api_timeout=ai_data.get("api_timeout", 60),
max_tokens=ai_data.get("max_tokens", 500),
api_token=os.environ.get("REPLICATE_API_TOKEN", ""),
)
# Build change detection settings
thresholds_data = change_detection_data.get("thresholds", {})
change_thresholds = ChangeThresholds(
temperature=thresholds_data.get("temperature", 5.0),
wind_speed=thresholds_data.get("wind_speed", 10.0),
wind_gust=thresholds_data.get("wind_gust", 10.0),
precipitation_prob=thresholds_data.get("precipitation_prob", 20.0),
)
change_detection_settings = ChangeDetectionSettings(
enabled=change_detection_data.get("enabled", True),
thresholds=change_thresholds,
)
return AppConfig(
app=app_settings,
weather=weather_settings,
alerts=alert_settings,
notifications=notification_settings,
state=state_settings,
ai=ai_settings,
change_detection=change_detection_settings,
)