Update notification service

This commit is contained in:
MacRimi
2026-03-20 18:45:35 +01:00
parent b49be42f2d
commit 72d02010c7
6 changed files with 38 additions and 11 deletions

View File

@@ -1477,6 +1477,33 @@ class NotificationManager:
for ch_type in CHANNEL_TYPES:
ai_detail_levels[ch_type] = self._config.get(f'ai_detail_level_{ch_type}', 'standard')
# Migrate deprecated AI model names to current versions
DEPRECATED_MODELS = {
'gemini-1.5-flash': 'gemini-2.0-flash',
'gemini-1.5-pro': 'gemini-2.0-flash',
'claude-3-haiku-20240307': 'claude-3-5-haiku-latest',
'claude-3-sonnet-20240229': 'claude-3-5-sonnet-latest',
}
current_model = self._config.get('ai_model', '')
migrated_model = DEPRECATED_MODELS.get(current_model, current_model)
# If model was deprecated, update it in the database automatically
if current_model and current_model != migrated_model:
try:
conn = sqlite3.connect(str(DB_PATH), timeout=10)
cursor = conn.cursor()
cursor.execute('''
INSERT OR REPLACE INTO user_settings (setting_key, setting_value, updated_at)
VALUES (?, ?, ?)
''', (f'{SETTINGS_PREFIX}ai_model', migrated_model, datetime.now().isoformat()))
conn.commit()
conn.close()
self._config['ai_model'] = migrated_model
print(f"[NotificationManager] Migrated AI model from '{current_model}' to '{migrated_model}'")
except Exception as e:
print(f"[NotificationManager] Failed to migrate AI model: {e}")
config = {
'enabled': self._enabled,
'channels': channels,
@@ -1487,7 +1514,7 @@ class NotificationManager:
'ai_enabled': self._config.get('ai_enabled', 'false') == 'true',
'ai_provider': self._config.get('ai_provider', 'groq'),
'ai_api_key': self._config.get('ai_api_key', ''),
'ai_model': self._config.get('ai_model', ''),
'ai_model': migrated_model,
'ai_language': self._config.get('ai_language', 'en'),
'ai_ollama_url': self._config.get('ai_ollama_url', 'http://localhost:11434'),
'ai_openai_base_url': self._config.get('ai_openai_base_url', ''),