Download routers/coaching.py from brocode12/wavvy: direct link, hf CLI and curl.
- Browser
- Download file 1.94 kB
-
https://huggingface.co/spaces/brocode12/wavvy/resolve/main/routers/coaching.py
- Command line
-
hf download hf://spaces/brocode12/wavvy/routers/coaching.py
-
curl -L -o coaching.py https://huggingface.co/spaces/brocode12/wavvy/resolve/main/routers/coaching.py
1.94 kB
| import logging | |
| from fastapi import APIRouter, HTTPException | |
| from coaching import coaching_manager | |
| logger = logging.getLogger(__name__) | |
| router = APIRouter() | |
| # ββ Voice AI coaching (primary) βββββββββββββββββββββββββββββββββββββββββββββββ | |
| async def voice_ai_stats(): | |
| """Aggregate performance stats for all Voice AI scored calls.""" | |
| try: | |
| return await coaching_manager.get_voice_ai_stats() | |
| except Exception as e: | |
| logger.error(f"Error fetching Voice AI coaching stats: {e}") | |
| raise HTTPException(status_code=500, detail=str(e)) | |
| async def voice_ai_packs(): | |
| """Return all Voice AI coaching packs, newest first.""" | |
| try: | |
| return await coaching_manager.get_voice_ai_packs() | |
| except Exception as e: | |
| logger.error(f"Error fetching Voice AI coaching packs: {e}") | |
| raise HTTPException(status_code=500, detail=str(e)) | |
| async def generate_voice_ai_pack(): | |
| """ | |
| Generate a new Voice AI coaching pack from the most recent scored calls. | |
| Requires >= 3 scored Voice AI calls (agent_id IS NULL in eval_scores). | |
| """ | |
| try: | |
| return await coaching_manager.generate_voice_ai_pack() | |
| except ValueError as e: | |
| raise HTTPException(status_code=422, detail=str(e)) | |
| except Exception as e: | |
| logger.error(f"Error generating Voice AI coaching pack: {e}") | |
| raise HTTPException(status_code=500, detail=str(e)) | |
| async def get_coaching_pack(pack_id: str): | |
| """Return a single coaching pack by ID.""" | |
| pack = await coaching_manager.get_pack_by_id(pack_id) | |
| if not pack: | |
| raise HTTPException(status_code=404, detail="Coaching pack not found") | |
| return pack | |