yabeskn commited on
Commit
45ea7c2
·
verified ·
1 Parent(s): b7d2605

Upload app/services/agent_activity_report_service.py with huggingface_hub

Browse files
app/services/agent_activity_report_service.py CHANGED
@@ -74,6 +74,10 @@ async def _fetch_worker_status() -> str:
74
 
75
 
76
  async def build_report_text(hours: int = 24) -> str:
 
 
 
 
77
  data = await _fetch_report_data(hours)
78
  now = datetime.now(timezone.utc)
79
  since = now - timedelta(hours=hours)
@@ -90,7 +94,7 @@ async def build_report_text(hours: int = 24) -> str:
90
  lines.append("🤖 *Aktivitas agent* (log/Status):")
91
  for a in data["agents"]:
92
  mark = "✅" if (a["fails"] or 0) == 0 else "⚠️"
93
- lines.append(f" {mark} {a['agent']}: {a['n']} log ({a['fails'] or 0} gagal)")
94
 
95
  lines.append("")
96
  q = data.get("queue") or {}
@@ -99,7 +103,7 @@ async def build_report_text(hours: int = 24) -> str:
99
  if data["pending_stale"]:
100
  lines.append(f" ⚠️ {data['pending_stale']} task Pending > 2 jam — periksa worker!")
101
 
102
- lines.append(f"☁️ *briga-agent-worker*: {await _fetch_worker_status()}")
103
  lines.append("")
104
  lines.append(f"_Dikirim otomatis oleh AI CEO • {now:%d %b %Y %H:%M} UTC_")
105
  return "\n".join(lines)
 
74
 
75
 
76
  async def build_report_text(hours: int = 24) -> str:
77
+ def md_safe(s) -> str:
78
+ """Escape underscore utk Telegram Markdown (nama agent/host mengandung _)."""
79
+ return str(s).replace("_", "\\_")
80
+
81
  data = await _fetch_report_data(hours)
82
  now = datetime.now(timezone.utc)
83
  since = now - timedelta(hours=hours)
 
94
  lines.append("🤖 *Aktivitas agent* (log/Status):")
95
  for a in data["agents"]:
96
  mark = "✅" if (a["fails"] or 0) == 0 else "⚠️"
97
+ lines.append(f" {mark} {md_safe(a['agent'])}: {a['n']} log ({a['fails'] or 0} gagal)")
98
 
99
  lines.append("")
100
  q = data.get("queue") or {}
 
103
  if data["pending_stale"]:
104
  lines.append(f" ⚠️ {data['pending_stale']} task Pending > 2 jam — periksa worker!")
105
 
106
+ lines.append(f"☁️ *briga agent worker*: {await _fetch_worker_status()}")
107
  lines.append("")
108
  lines.append(f"_Dikirim otomatis oleh AI CEO • {now:%d %b %Y %H:%M} UTC_")
109
  return "\n".join(lines)