mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2026-04-18 18:12:15 +00:00
Update notification service
This commit is contained in:
@@ -129,7 +129,7 @@ const AI_PROVIDERS = [
|
|||||||
{
|
{
|
||||||
value: "anthropic",
|
value: "anthropic",
|
||||||
label: "Anthropic (Claude)",
|
label: "Anthropic (Claude)",
|
||||||
model: "claude-3-haiku-20240307",
|
model: "claude-3-5-haiku-latest",
|
||||||
description: "Excellent for writing and translation. Fast and economical.",
|
description: "Excellent for writing and translation. Fast and economical.",
|
||||||
keyUrl: "https://console.anthropic.com/settings/keys",
|
keyUrl: "https://console.anthropic.com/settings/keys",
|
||||||
icon: "https://cdn.jsdelivr.net/gh/selfhst/icons@main/webp/claude-light.webp",
|
icon: "https://cdn.jsdelivr.net/gh/selfhst/icons@main/webp/claude-light.webp",
|
||||||
@@ -138,7 +138,7 @@ const AI_PROVIDERS = [
|
|||||||
{
|
{
|
||||||
value: "gemini",
|
value: "gemini",
|
||||||
label: "Google Gemini",
|
label: "Google Gemini",
|
||||||
model: "gemini-1.5-flash",
|
model: "gemini-2.0-flash",
|
||||||
description: "Free tier available, great quality/price ratio.",
|
description: "Free tier available, great quality/price ratio.",
|
||||||
keyUrl: "https://aistudio.google.com/app/apikey",
|
keyUrl: "https://aistudio.google.com/app/apikey",
|
||||||
icon: "https://cdn.jsdelivr.net/gh/selfhst/icons@main/webp/google-gemini.webp",
|
icon: "https://cdn.jsdelivr.net/gh/selfhst/icons@main/webp/google-gemini.webp",
|
||||||
@@ -260,6 +260,7 @@ export function NotificationSettings() {
|
|||||||
try {
|
try {
|
||||||
const data = await fetchApi<{ success: boolean; config: NotificationConfig }>("/api/notifications/settings")
|
const data = await fetchApi<{ success: boolean; config: NotificationConfig }>("/api/notifications/settings")
|
||||||
if (data.success && data.config) {
|
if (data.success && data.config) {
|
||||||
|
// Backend automatically migrates deprecated AI models to current versions
|
||||||
setConfig(data.config)
|
setConfig(data.config)
|
||||||
setOriginalConfig(data.config)
|
setOriginalConfig(data.config)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,13 +44,13 @@ PROVIDER_INFO = {
|
|||||||
},
|
},
|
||||||
'anthropic': {
|
'anthropic': {
|
||||||
'name': 'Anthropic (Claude)',
|
'name': 'Anthropic (Claude)',
|
||||||
'default_model': 'claude-3-haiku-20240307',
|
'default_model': 'claude-3-5-haiku-latest',
|
||||||
'description': 'Excellent for writing and translation. Fast and affordable.',
|
'description': 'Excellent for writing and translation. Fast and affordable.',
|
||||||
'requires_api_key': True,
|
'requires_api_key': True,
|
||||||
},
|
},
|
||||||
'gemini': {
|
'gemini': {
|
||||||
'name': 'Google Gemini',
|
'name': 'Google Gemini',
|
||||||
'default_model': 'gemini-1.5-flash',
|
'default_model': 'gemini-2.0-flash',
|
||||||
'description': 'Free tier available, very good quality/price ratio.',
|
'description': 'Free tier available, very good quality/price ratio.',
|
||||||
'requires_api_key': True,
|
'requires_api_key': True,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
"""Anthropic (Claude) provider implementation.
|
"""Anthropic (Claude) provider implementation.
|
||||||
|
|
||||||
Anthropic's Claude models are excellent for text generation and translation.
|
Anthropic's Claude models are excellent for text generation and translation.
|
||||||
Claude Haiku is particularly fast and affordable for notification enhancement.
|
Claude 3.5 Haiku is fast and affordable for notification enhancement.
|
||||||
"""
|
"""
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
from .base import AIProvider, AIProviderError
|
from .base import AIProvider, AIProviderError
|
||||||
@@ -11,7 +11,7 @@ class AnthropicProvider(AIProvider):
|
|||||||
"""Anthropic provider using their Messages API."""
|
"""Anthropic provider using their Messages API."""
|
||||||
|
|
||||||
NAME = "anthropic"
|
NAME = "anthropic"
|
||||||
DEFAULT_MODEL = "claude-3-haiku-20240307"
|
DEFAULT_MODEL = "claude-3-5-haiku-latest"
|
||||||
REQUIRES_API_KEY = True
|
REQUIRES_API_KEY = True
|
||||||
API_URL = "https://api.anthropic.com/v1/messages"
|
API_URL = "https://api.anthropic.com/v1/messages"
|
||||||
API_VERSION = "2023-06-01"
|
API_VERSION = "2023-06-01"
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
"""Google Gemini provider implementation.
|
"""Google Gemini provider implementation.
|
||||||
|
|
||||||
Google's Gemini models offer a free tier and excellent quality/price ratio.
|
Google's Gemini models offer a free tier and excellent quality/price ratio.
|
||||||
Gemini 1.5 Flash is particularly fast and cost-effective.
|
Gemini 2.0 Flash is fast and cost-effective with improved capabilities.
|
||||||
"""
|
"""
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
from .base import AIProvider, AIProviderError
|
from .base import AIProvider, AIProviderError
|
||||||
@@ -11,7 +11,7 @@ class GeminiProvider(AIProvider):
|
|||||||
"""Google Gemini provider using the Generative Language API."""
|
"""Google Gemini provider using the Generative Language API."""
|
||||||
|
|
||||||
NAME = "gemini"
|
NAME = "gemini"
|
||||||
DEFAULT_MODEL = "gemini-1.5-flash"
|
DEFAULT_MODEL = "gemini-2.0-flash"
|
||||||
REQUIRES_API_KEY = True
|
REQUIRES_API_KEY = True
|
||||||
API_BASE = "https://generativelanguage.googleapis.com/v1beta/models"
|
API_BASE = "https://generativelanguage.googleapis.com/v1beta/models"
|
||||||
|
|
||||||
|
|||||||
@@ -1477,6 +1477,33 @@ class NotificationManager:
|
|||||||
for ch_type in CHANNEL_TYPES:
|
for ch_type in CHANNEL_TYPES:
|
||||||
ai_detail_levels[ch_type] = self._config.get(f'ai_detail_level_{ch_type}', 'standard')
|
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 = {
|
config = {
|
||||||
'enabled': self._enabled,
|
'enabled': self._enabled,
|
||||||
'channels': channels,
|
'channels': channels,
|
||||||
@@ -1487,7 +1514,7 @@ class NotificationManager:
|
|||||||
'ai_enabled': self._config.get('ai_enabled', 'false') == 'true',
|
'ai_enabled': self._config.get('ai_enabled', 'false') == 'true',
|
||||||
'ai_provider': self._config.get('ai_provider', 'groq'),
|
'ai_provider': self._config.get('ai_provider', 'groq'),
|
||||||
'ai_api_key': self._config.get('ai_api_key', ''),
|
'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_language': self._config.get('ai_language', 'en'),
|
||||||
'ai_ollama_url': self._config.get('ai_ollama_url', 'http://localhost:11434'),
|
'ai_ollama_url': self._config.get('ai_ollama_url', 'http://localhost:11434'),
|
||||||
'ai_openai_base_url': self._config.get('ai_openai_base_url', ''),
|
'ai_openai_base_url': self._config.get('ai_openai_base_url', ''),
|
||||||
|
|||||||
@@ -1470,8 +1470,7 @@ A blank line must be completely empty — no emoji, no spaces.
|
|||||||
🔄 Proxmox updates: 0
|
🔄 Proxmox updates: 0
|
||||||
⚙️ Kernel updates: 0
|
⚙️ Kernel updates: 0
|
||||||
|
|
||||||
🗂️ Important packages:
|
🗂️ Important packages: 0
|
||||||
• none
|
|
||||||
|
|
||||||
EXAMPLE — updates message (with important packages):
|
EXAMPLE — updates message (with important packages):
|
||||||
[TITLE]
|
[TITLE]
|
||||||
|
|||||||
Reference in New Issue
Block a user