from fastapi import HTTPException, Request from src.inference.transcribe import WhisperTranscriber from src.inference.analyze_call import CallAnalyzer def get_transcriber(request: Request) -> WhisperTranscriber: transcriber = getattr(request.app.state, "transcriber", None) if transcriber is None: raise HTTPException( status_code=503, detail="Whisper model is not loaded. Check server logs and MODEL_PATH.", ) return transcriber def get_analyzer(request: Request) -> CallAnalyzer: analyzer = getattr(request.app.state, "analyzer", None) if analyzer is None: raise HTTPException( status_code=503, detail=( "Gemini analyzer is not available. " "Set GEMINI_API_KEY in the environment to enable this endpoint." ), ) return analyzer