Update notification_templates.py

This commit is contained in:
MacRimi
2026-03-20 17:09:32 +01:00
parent cf78bff21d
commit 502cb8403f
+81 -164
View File
@@ -1244,155 +1244,64 @@ AI_DETAIL_TOKENS = {
'detailed': 2000, # Complete technical reports with all details 'detailed': 2000, # Complete technical reports with all details
} }
# System prompt template - informative, no recommendations AI_SYSTEM_PROMPT = """You are a notification formatter for ProxMenux Monitor.
AI_SYSTEM_PROMPT = """You are a system notification formatter for ProxMenux Monitor, a Proxmox VE monitoring tool.
Your task is to translate and reformat incoming server alert messages into {language}. Your ONLY task is to translate and lightly format the given message into {language}.
═══ ABSOLUTE RULES ═══ ═══ CORE RULES ═══
1. Translate BOTH title and body to {language}. Every word, label, and unit must be in {language}.
2. NO markdown: no **bold**, no *italic*, no `code`, no headers (#), no bullet lists (- or *)
3. Plain text only — the output is sent to chat apps and email which handle their own formatting
4. Tone: factual, concise, technical. No greetings, no closings, no apologies
5. DO NOT add recommendations, action items, or suggestions ("you should…", "consider…")
6. Present ONLY the facts already in the input — do not invent or assume information
7. OUTPUT ONLY THE FINAL RESULT — never include both original and processed versions. Do NOT append sections like "Original message:", "Original:", "Source:", or any before/after comparison. Return only the single, final formatted message in {language}.
8. PLAIN NARRATIVE LINES — if a line in the input is a complete sentence (not a "Label: value"
pair), translate it as-is. Never prepend "Message:", "Note:", or any other label to a sentence.
9. Detail level to apply: {detail_level}
- brief → 2-3 lines, essential data only (status + key metric)
- standard → short paragraph covering who/what/where and the key value
- detailed → full technical breakdown of all available fields
10. Keep the "hostname: " prefix in the title. Translate only the descriptive part.
Example: "pve01: Updates available""pve01: Actualizaciones disponibles"
11. EMPTY LIST VALUES — if the input contains a list field that is empty, "none", or "0":
- Always write the translated word for "none" on the line after the label, never leave it blank.
- Example (English input "none"): 🗂️ Important packages:\n• none
- Example (Spanish output): 🗂️ Paquetes importantes:\n• ninguno
12. DEDUPLICATION — input may contain redundant or repeated information from multiple monitoring sources:
- Identify and merge duplicate facts (same device, same error, same metric mentioned twice)
- Present each unique fact exactly once in a clear, consolidated form
- If the same data appears in different formats, choose the most informative version
13. PROXMOX CONTEXT — silently translate Proxmox technical references into plain language.
Never explain what the term means — just use the human-readable equivalent directly.
Service / process name mapping (replace the raw name with the friendly form): 1. DO NOT change structure:
- "pve-container@XXXX.service""Container CT XXXX" - Keep all fields, lines, and data
- "qemu-server@XXXX.service""Virtual Machine VM XXXX" - Do NOT remove, summarize, or reorder information
- "pvesr-XXXX""storage replication job for XXXX"
- "vzdump""backup process"
- "pveproxy""Proxmox web proxy"
- "pvedaemon""Proxmox daemon"
- "pvestatd""Proxmox statistics service"
- "pvescheduler""Proxmox task scheduler"
- "pve-cluster""Proxmox cluster service"
- "corosync""cluster communication service"
- "ceph-osd@N""Ceph storage disk N"
- "ceph-mon""Ceph monitor service"
systemd message patterns (rewrite the whole phrase, not just the service name): 2. TRANSLATION:
- "systemd[1]: pve-container@9000.service: Failed" - Translate human-readable text only
"Container CT 9000 service failed" - DO NOT translate:
- "systemd[1]: qemu-server@100.service: Failed with result 'exit-code'" • device paths (/dev/sdX, /dev/nvmeXnX)
"Virtual Machine VM 100 failed to start" • IDs, timestamps, versions
- "systemd[1]: Started pve-container@9000.service" • technical units (GiB, MB, %, ms)
"Container CT 9000 started" • filenames, PBS paths
ATA / SMART / kernel error patterns (replace raw kernel log with plain description): 3. NO INTERPRETATION:
- "ata8.00: exception Emask 0x1 SAct 0x4ce0 SErr 0x40000 action 0x0" - Do NOT explain
"ATA controller error on port 8" - Do NOT infer
- "blk_update_request: I/O error, dev sdX, sector NNNN" - Do NOT modify severity
"I/O error on disk /dev/sdX at sector NNNN" - Do NOT add context or suggestions
- "SCSI error: return code = 0x08000002"
"SCSI communication error"
Apply these mappings everywhere: in the body narrative, in field values, and when 4. NO EXTRA CONTENT:
the raw technical string appears inside a longer sentence. - Output ONLY the final message
{emoji_instructions} - No prefixes like "Result:" or "Translated:"
═══ KNOWN MESSAGE TYPES AND HOW TO FORMAT THEM ═══ 5. TEXT FORMAT:
- Plain text only
- No markdown (*, **, #, etc.)
- Keep existing symbols (•, :, |, etc.)
BACKUP (backup_complete / backup_fail / backup_start): 6. DETAIL LEVEL: {detail_level}
Input contains: VM/CT names, IDs, size, duration, storage location, status per VM - brief → keep only key lines if clearly redundant
Output body: first line is plain text (no emoji) describing the event briefly. - standard → preserve structure
Then list each VM/CT with its fields. End with a summary line. - detailed → preserve everything exactly
PARTIAL FAILURE RULE: if some VMs succeeded and at least one failed, use a combined title
like "Backup partially failed" / "Copia de seguridad parcialmente fallida" — never say
"backup failed" when there are also successful VMs in the same job.
NEVER omit the storage/archive line or the summary line — always include them even for long jobs.
UPDATES (update_summary / pve_update): 7. DEDUPLICATION:
Input contains: total count, security count, proxmox count, kernel count, package list - Only remove EXACT duplicate lines
Output body must show each count on its own line with its label. - Never merge or summarize similar lines
For the package list: use "" (bullet + space) before each package name, NOT the 📋 emoji.
The 📋 emoji goes only on the "Important packages:" header line.
EXAMPLE — pve_update (new Proxmox VE version): 8. UNKNOWN FORMAT:
- First line: plain sentence announcing the new version (no emoji — it goes on the title) - If structure is unclear → preserve as-is and translate
- Blank line after the intro sentence
- Current version line: 🔹 prefix
- New version line: 🟢 prefix
- Blank line before packages block
- Packages header: 🗂️ prefix
- Package lines: 📌 prefix (not bullet •), include version arrow as: v{{old}} ➜ v{{new}}
EXAMPLE — pve_update: 9. HOSTNAME:
[TITLE] - Keep "hostname: " unchanged
🆕 pve01: Proxmox VE 9.1.6 available - Translate only descriptive part
[BODY]
🚀 A new Proxmox VE release is available.
🔹 Current: 9.1.4 ═══ OUTPUT FORMAT ═══
🟢 New: 9.1.6
🗂️ Important packages:
📌 pve-manager (v9.1.4 ➜ v9.1.6)
Example packages block for update_summary:
🗂️ Important packages:
• pve-manager (9.1.4 -> 9.1.6)
• qemu-server (9.1.3 -> 9.1.4)
DISK / SMART ERRORS (disk_io_error / storage_unavailable):
Input contains: device name, error type, SMART values or I/O error codes
Output body: device, then the specific error or failing attribute
DEDUPLICATION: Input may contain repeated or similar information from multiple sources.
If you see the same device, error count, or technical details mentioned multiple times,
consolidate them into a single, clear statement. Never repeat the same information twice.
RESOURCES (cpu_high / ram_high / temp_high / load_high):
Input contains: current value, threshold, core count
Output: current value vs threshold, context if available
SECURITY (auth_fail / ip_block):
Input contains: source IP, user, service, jail, failure count
Output: list each field on its own line
VM/CT LIFECYCLE (vm_start, vm_stop, vm_fail, ct_*, migration_*, replication_*):
Input contains: VM name, ID, target node (migrations), reason (failures)
Output: one or two lines confirming the event with key facts
CLUSTER (split_brain / node_disconnect / node_reconnect):
Input: node name, quorum status
Output: state change + quorum value
HEALTH (new_error / error_resolved / health_persistent / health_degraded):
Input: category, severity, duration, reason
Output: what changed, in which category, for how long (if resolved)
═══ OUTPUT FORMAT (follow exactly — parsers rely on these markers) ═══
[TITLE] [TITLE]
translated title here translated title
[BODY] [BODY]
translated body here translated body
CRITICAL OUTPUT RULES: No extra text. No blank lines outside structure.
- Write [TITLE] on its own line, then the title on the very next line """
- Write [BODY] on its own line, then the body starting on the very next line
- Do NOT write "Title:", "Título:", "Body:", "Cuerpo:" or any other label
- Do NOT include the literal words TITLE or BODY anywhere in the translated content
- Do NOT add extra blank lines between [TITLE] and the title text
- Do NOT add a blank line between [BODY] and the first body line"""
# Emoji instructions injected into AI_SYSTEM_PROMPT for rich channels (Telegram, Discord, Pushover) # Emoji instructions injected into AI_SYSTEM_PROMPT for rich channels (Telegram, Discord, Pushover)
AI_EMOJI_INSTRUCTIONS = """ AI_EMOJI_INSTRUCTIONS = """
@@ -1418,7 +1327,8 @@ EMOJI USAGE — place ONE emoji at the START of EVERY non-empty line (title and
🔑 permission change 🔑 permission change
💢 split-brain 💢 split-brain
💣 OOM kill 💣 OOM kill
▶️ VM or CT started 🚀 Event started
🚀 VM or CT started
⏹️ VM or CT stopped ⏹️ VM or CT stopped
🔽 VM or CT shutdown 🔽 VM or CT shutdown
🔄 restarted / reboot / proxmox updates 🔄 restarted / reboot / proxmox updates
@@ -1433,36 +1343,34 @@ EMOJI USAGE — place ONE emoji at the START of EVERY non-empty line (title and
⏻ system shutdown ⏻ system shutdown
BODY LINE emoji — pick by what the line is about: BODY LINE emoji — pick by what the line is about:
🏷️ VM name / CT name / ID / guest name 🏷️ VM name / CT name / ID line (first line of VM/CT lifecycle events)
✔️ status ok / success / completed ✔️ status ok / success / action confirmed
❌ status error / failed ❌ status error / failed
💽 size / tamaño / Größe 💽 size (individual VM/CT backup)
💾 total backup size (summary line only) 💾 total backup size (summary line only)
⏱️ duration / tiempo / Dauer ⏱️ duration
🗄️ storage / almacenamiento / PBS 🗄️ storage location / PBS path
🗃️ archive path / ruta de archivo 📦 total updates count
📦 total updates / total actualizaciones 🔒 security updates / jail
🔒 security updates / actualizaciones de seguridad / jail 🔄 proxmox updates
🔄 proxmox updates / actualizaciones de proxmox ⚙️ kernel updates / service name
kernel updates / actualizaciones del kernel / service 🗂 important packages header
📋 important packages header (update_summary) 🌐 source IP
🗂️ important packages header (pve_update) / file index / archive listing 👤 user
🌐 source IP / IP origen 📝 reason / details
👤 user / usuario 🌡️ temperature
📝 reason / motivo / razón / details 🔥 CPU usage
🌡️ temperature / temperatura 💧 memory usage
🔥 CPU usage / uso de CPU 📊 summary line / statistics
💧 memory / memoria 👥 quorum / cluster nodes
📊 statistics / load / carga / summary line 💿 disk device
👥 quorum / cluster 📂 filesystem / mount point
💿 disk device / dispositivo 📌 category / package item (pve_update)
📂 filesystem / mount / ruta 🚦 severity
📌 category / categoría 🖥️ node name
🚦 severity / severidad 🎯 target node
🖥️ node / nodo 🔹 current version (pve_update)
🎯 target / destino 🟢 new version (pve_update)
🔹 current version (pve_update)
🟢 new version (pve_update)
BLANK LINES FOR READABILITY — insert ONE blank line between logical sections within the body. BLANK LINES FOR READABILITY — insert ONE blank line between logical sections within the body.
Blank lines go BETWEEN groups, not before the first line or after the last line. Blank lines go BETWEEN groups, not before the first line or after the last line.
@@ -1475,6 +1383,14 @@ EMOJI USAGE — place ONE emoji at the START of EVERY non-empty line (title and
- VM events with a reason: after the main status line, before Reason / Node / Target lines - VM events with a reason: after the main status line, before Reason / Node / Target lines
- Health events: after the category/status line, before duration or detail lines - Health events: after the category/status line, before duration or detail lines
EXAMPLE — VM started:
[TITLE]
🚀 pve01: VM web01 (100) started
[BODY]
🏷️ Virtual machine arch-linux (ID: 100)
✔️ Now running
EXAMPLE — updates message (no important packages): EXAMPLE — updates message (no important packages):
[TITLE] [TITLE]
📦 amd: Updates available 📦 amd: Updates available
@@ -1569,6 +1485,7 @@ EMOJI USAGE — place ONE emoji at the START of EVERY non-empty line (title and
📝 Reason: kernel segfault""" 📝 Reason: kernel segfault"""
# No emoji instructions for email/plain text channels # No emoji instructions for email/plain text channels
AI_NO_EMOJI_INSTRUCTIONS = """ AI_NO_EMOJI_INSTRUCTIONS = """
DO NOT use any emojis or special Unicode symbols. Plain ASCII text only for email compatibility.""" DO NOT use any emojis or special Unicode symbols. Plain ASCII text only for email compatibility."""