Spaces:
Paused
Paused
Download apps/api/src/app/routes/settings.py from nathycodes/presentercoach: direct link, hf CLI and curl.
- Browser
- Download file 1.63 kB
-
https://huggingface.co/spaces/nathycodes/presentercoach/resolve/main/apps/api/src/app/routes/settings.py
- Command line
-
hf download hf://spaces/nathycodes/presentercoach/apps/api/src/app/routes/settings.py
-
curl -L -o settings.py https://huggingface.co/spaces/nathycodes/presentercoach/resolve/main/apps/api/src/app/routes/settings.py
1.63 kB
| from fastapi import APIRouter, Depends | |
| from fastapi import HTTPException | |
| from app import models, schemas, transcription | |
| from app.auth import get_current_user | |
| from app.local_inference import check_engine, get_all_engine_statuses | |
| router = APIRouter(prefix="/settings", tags=["settings"]) | |
| def get_transcription_settings(current_user: models.User = Depends(get_current_user)): | |
| return { | |
| "default_backend": transcription.get_default_transcription_backend(), | |
| "backends": transcription.get_transcription_backends(), | |
| "text_inference_engines": get_all_engine_statuses(), | |
| } | |
| def download_transcription_model( | |
| payload: schemas.TranscriptionModelDownloadRequest, | |
| current_user: models.User = Depends(get_current_user), | |
| ): | |
| try: | |
| return transcription.download_transcription_model(payload.backend, payload.model) | |
| except ValueError as exc: | |
| raise HTTPException(status_code=400, detail=str(exc)) from exc | |
| except RuntimeError as exc: | |
| raise HTTPException(status_code=503, detail=str(exc)) from exc | |
| def check_local_inference( | |
| payload: schemas.InferenceEngineCheckRequest, | |
| current_user: models.User = Depends(get_current_user), | |
| ): | |
| try: | |
| return check_engine(payload.engine_id, payload.base_url) | |
| except ValueError as exc: | |
| raise HTTPException(status_code=400, detail=str(exc)) from exc | |