From 1a3f1f9a402cc4220d2c674403d8b9d195ad2f3d Mon Sep 17 00:00:00 2001 From: root Date: Mon, 16 Mar 2026 13:18:53 +0700 Subject: [PATCH] Hausmeister-Bot: Wochentags-Muster nur bei ausreichend Daten, WordPress/Matomo Tool-Beschreibungen geschaerft --- homelab-ai-bot/core/matomo_client.py | 14 ++++++++++---- homelab-ai-bot/llm.py | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/homelab-ai-bot/core/matomo_client.py b/homelab-ai-bot/core/matomo_client.py index 99ed07cd..042073ce 100644 --- a/homelab-ai-bot/core/matomo_client.py +++ b/homelab-ai-bot/core/matomo_client.py @@ -392,7 +392,7 @@ def format_trend(days: int = 30) -> str: trend_dir = _trend_direction(pairs) lines.append(f"Trend-Richtung: {trend_dir}") - # Wochentags-Muster + # Wochentags-Muster (nur bei >= 14 Tagen Daten sinnvoll) weekday_map = {} for d, v in pairs: try: @@ -401,8 +401,9 @@ def format_trend(days: int = 30) -> str: except ValueError: pass - if weekday_map: - lines.append(f"\n=== WOCHENTAGS-MUSTER ===") + min_samples = min(len(vals) for vals in weekday_map.values()) if weekday_map else 0 + if weekday_map and min_samples >= 2: + lines.append(f"\n=== WOCHENTAGS-MUSTER (je {min_samples}-{max(len(v) for v in weekday_map.values())} Datenpunkte) ===") wd_order = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"] wd_de = {"Monday": "Mo", "Tuesday": "Di", "Wednesday": "Mi", "Thursday": "Do", "Friday": "Fr", "Saturday": "Sa", "Sunday": "So"} @@ -410,11 +411,16 @@ def format_trend(days: int = 30) -> str: if wd in weekday_map: vals = weekday_map[wd] wd_avg = mean(vals) if vals else 0 - lines.append(f" {wd_de[wd]}: Ø {wd_avg:.0f} Besucher") + lines.append(f" {wd_de[wd]}: Ø {wd_avg:.0f} Besucher ({len(vals)}x gemessen)") best_wd = max(weekday_map.items(), key=lambda x: mean(x[1]) if x[1] else 0) worst_wd = min(weekday_map.items(), key=lambda x: mean(x[1]) if x[1] else float('inf')) lines.append(f" → Bester Wochentag: {wd_de.get(best_wd[0], best_wd[0])} (Ø {mean(best_wd[1]):.0f})") lines.append(f" → Schwaechster: {wd_de.get(worst_wd[0], worst_wd[0])} (Ø {mean(worst_wd[1]):.0f})") + if min_samples < 4: + lines.append(f" ⚠ Wenig Datenpunkte — Muster wird mit mehr Daten zuverlaessiger") + elif weekday_map: + lines.append(f"\n=== WOCHENTAGS-MUSTER ===") + lines.append(f" Zu wenig Daten fuer zuverlaessige Wochentags-Analyse (nur {days} Tage, mind. 14 noetig)") # Wachstums-Prognose if len(values_nonzero) >= 14: diff --git a/homelab-ai-bot/llm.py b/homelab-ai-bot/llm.py index b6957e6a..4a7a0819 100644 --- a/homelab-ai-bot/llm.py +++ b/homelab-ai-bot/llm.py @@ -264,7 +264,7 @@ TOOLS = [ "type": "function", "function": { "name": "get_wordpress_stats", - "description": "WordPress/Blog-Statistiken: Posts heute/gestern/Woche, offene Kommentare, letzte Artikel, Plugin-Status", + "description": "WordPress INTERNE Statistiken: Anzahl veroeffentlichter Posts/Artikel, offene Kommentare, Plugin-Status. NICHT fuer Besucherzahlen — dafuer get_matomo_analytics nutzen.", "parameters": {"type": "object", "properties": {}, "required": []}, }, },