2026-07-11 09:45:06 +02:00
|
|
|
"""Health/observability endpoints (§15)."""
|
|
|
|
|
|
|
|
|
|
from __future__ import annotations
|
|
|
|
|
|
|
|
|
|
from fastapi import APIRouter, Depends
|
|
|
|
|
from sqlalchemy import text
|
|
|
|
|
from sqlalchemy.ext.asyncio import AsyncSession
|
|
|
|
|
|
|
|
|
|
import gogo
|
|
|
|
|
from gogo.db import get_session
|
|
|
|
|
|
|
|
|
|
router = APIRouter()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@router.get("/health")
|
|
|
|
|
async def health():
|
|
|
|
|
return {"status": "ok", "version": gogo.__version__}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@router.get("/health/db")
|
|
|
|
|
async def health_db(session: AsyncSession = Depends(get_session)):
|
|
|
|
|
await session.execute(text("SELECT 1"))
|
|
|
|
|
return {"status": "ok"}
|
M6 + M0: hardening, deploy docs, PoC scripts
- Pipeline-down fallback: dialplan plays gogo-fallback after a failed
AudioSocket (§15) + script to synthesize the Bosnian prompt via TTS
- Voice heartbeat file → /health/voice endpoint + live status in admin panel
- Retention job also purges stale call registrations; chat sessions metered;
100%-usage super-admin alert email (GOGO_ADMIN_ALERT_EMAIL)
- .env.example, docs/DEPLOY.md (compose stack, GPU node, backups pg_dump,
update procedure, security notes)
- §16 Definition of Done as an automated test: softphone-style call → fake
partner availability → request pushed → webhook confirm → console SMS
- M0 PoC scripts: STT accuracy harness (CER/WER + spoken-digit check; dry-run
verified with espeak-ng samples + faster-whisper small on CPU — phone number
extracted exactly), TTS bake-off (Azure vs ElevenLabs, latency+cost), and
end-to-end latency smoke test speaking real AudioSocket to the live pipeline
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-11 11:27:05 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
@router.get("/health/voice")
|
|
|
|
|
async def health_voice():
|
|
|
|
|
"""Voice pipeline liveness via its heartbeat file (shared volume)."""
|
|
|
|
|
import os
|
|
|
|
|
import time
|
|
|
|
|
|
|
|
|
|
from gogo.voice.server import heartbeat_path
|
|
|
|
|
|
|
|
|
|
path = heartbeat_path()
|
|
|
|
|
try:
|
|
|
|
|
age = time.time() - os.path.getmtime(path)
|
|
|
|
|
except OSError:
|
|
|
|
|
return {"status": "down", "detail": "no heartbeat file"}
|
|
|
|
|
if age > 60:
|
|
|
|
|
return {"status": "down", "detail": f"heartbeat {int(age)}s old"}
|
|
|
|
|
return {"status": "ok", "heartbeat_age_s": int(age)}
|