feat: 시스템 상태에 큐 정보 + Gemma busy 안내

- 상태 조회: 처리 중/대기 건수 표시
- Gemma route 시 큐에 다른 작업 있으면 "조금 걸릴 수 있어" 안내

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Hyungi Ahn
2026-04-06 15:13:02 +09:00
parent a057e9a358
commit ee31f06601

View File

@@ -152,10 +152,20 @@ def _pre_route(message: str) -> dict | None:
# 시스템 상태 질문
if any(k in msg for k in ["추론 모델", "gemma", "젬마", "상태", "서버 상태", "시스템"]) and any(k in msg for k in ["돌아", "일하", "작동", "상태", "건강", "살아"]):
health = backend_registry.health_summary()
from services import job_queue as jq_module
queue = jq_module.job_queue.stats if jq_module.job_queue else {"pending": 0, "active": 0}
lines = []
for role, info in health.items():
status = "✅ 정상" if info["healthy"] else "❌ 연결 안 됨"
lines.append(f"{info['name']} ({role}): {status} ({info['latency_ms']:.0f}ms)")
line = f"{info['name']} ({role}): {status} ({info['latency_ms']:.0f}ms)"
lines.append(line)
# 큐 정보
active = queue.get("active", 0)
pending = queue.get("pending", 0)
if active > 0 or pending > 0:
lines.append(f"\n작업 현황: 처리 중 {active}건, 대기 {pending}")
else:
lines.append(f"\n작업 현황: 유휴 상태 (대기 없음)")
status_text = "\n".join(lines)
return {"action": "direct", "response": f"현재 시스템 상태야:\n{status_text}", "prompt": ""}
@@ -324,6 +334,13 @@ async def run(job: Job) -> None:
rewritten_message = (route_prompt or job.message)[:MAX_PROMPT_LENGTH]
job.rewritten_message = rewritten_message
# Gemma busy 안내 (큐에 다른 작업이 있으면)
from services import job_queue as jq_module
if jq_module.job_queue:
q = jq_module.job_queue.stats
if q.get("active", 0) > 1 and job.callback == "synology":
await send_to_synology(f"⏳ 추론 모델이 현재 다른 작업도 처리 중이라 조금 걸릴 수 있어... (대기 {q.get('pending', 0)}건)", raw=True)
if job.callback != "synology":
await state_stream.push(job.id, "rewrite", {"content": rewritten_message})
else: