feat: add call history API endpoints and TTS service client

Adds read-only access to persisted call records for the dashboard
and implements a client for the Rhema text-to-speech service.

- api/call_history.py: New router providing paged call lists
  and detailed call records with transcript metadata.
- services/tts.py: Async client for OpenAI-compatible TTS
  endpoints (Rhema/Kokoro) used for call-flow steps.
This commit is contained in:
2026-05-22 06:28:33 -04:00
parent dbdb03beb9
commit 63f1a270bb
28 changed files with 2275 additions and 11 deletions

15
main.py
View File

@@ -18,7 +18,7 @@ from contextlib import asynccontextmanager
from fastapi import FastAPI
from fastapi.staticfiles import StaticFiles
from api import calls, call_flows, devices, websocket
from api import call_flows, call_history, calls, devices, routing, websocket
from config import get_settings
from core.gateway import AIPSTNGateway
from db.database import close_db, init_db
@@ -114,6 +114,7 @@ async def lifespan(app: FastAPI):
recording_svc = RecordingService()
await recording_svc.start()
app.state.recording_service = recording_svc
gateway._recording_service = recording_svc
analytics_svc = CallAnalytics()
app.state.analytics_service = analytics_svc
@@ -171,10 +172,22 @@ app = FastAPI(
# === API Routes ===
app.include_router(calls.router, prefix="/api/calls", tags=["Calls"])
app.include_router(call_history.router, prefix="/api/calls", tags=["Call History"])
app.include_router(call_flows.router, prefix="/api/call-flows", tags=["Call Flows"])
app.include_router(devices.router, prefix="/api/devices", tags=["Devices"])
app.include_router(routing.router, prefix="/api/routing", tags=["Routing"])
app.include_router(websocket.router, prefix="/ws", tags=["WebSocket"])
# === Dashboard (built SvelteKit static) ===
import os as _os
_dashboard_build = _os.path.join(_os.path.dirname(__file__), "dashboard", "build")
if _os.path.isdir(_dashboard_build):
app.mount(
"/dashboard",
StaticFiles(directory=_dashboard_build, html=True),
name="dashboard",
)
# === Root Endpoint ===
@app.get("/", tags=["System"])