|
32 | 32 | from vllm_router.service_discovery import get_service_discovery |
33 | 33 | from vllm_router.services.request_service.request import ( |
34 | 34 | route_general_request, |
35 | | - route_general_transcriptions, |
36 | 35 | route_sleep_wakeup_request, |
37 | 36 | ) |
| 37 | + |
| 38 | +# Transcriptions support is optional; older deployed versions may not yet define |
| 39 | +# route_general_transcriptions. Make the import guarded so the rest of the |
| 40 | +# router (and CI) isn't blocked by the new audio endpoint when the helper is |
| 41 | +# absent. This prevents ImportError: cannot import name 'route_general_transcriptions'. |
| 42 | +try: # pragma: no cover - simple availability guard |
| 43 | + from vllm_router.services.request_service.request import ( |
| 44 | + route_general_transcriptions, # type: ignore |
| 45 | + ) |
| 46 | + |
| 47 | + _transcriptions_available = True |
| 48 | +except ImportError: # pragma: no cover |
| 49 | + route_general_transcriptions = None # type: ignore |
| 50 | + _transcriptions_available = False |
38 | 51 | from vllm_router.stats.engine_stats import get_engine_stats_scraper |
39 | 52 | from vllm_router.version import __version__ |
40 | 53 |
|
@@ -264,11 +277,17 @@ async def health() -> Response: |
264 | 277 | return JSONResponse(content={"status": "healthy"}, status_code=200) |
265 | 278 |
|
266 | 279 |
|
267 | | -@main_router.post("/v1/audio/transcriptions") |
268 | | -async def route_v1_audio_transcriptions( |
269 | | - request: Request, background_tasks: BackgroundTasks |
270 | | -): |
271 | | - """Handles audio transcription requests.""" |
272 | | - return await route_general_transcriptions( |
273 | | - request, "/v1/audio/transcriptions", background_tasks |
274 | | - ) |
| 280 | +if _transcriptions_available: |
| 281 | + @main_router.post("/v1/audio/transcriptions") |
| 282 | + async def route_v1_audio_transcriptions( |
| 283 | + request: Request, background_tasks: BackgroundTasks |
| 284 | + ): |
| 285 | + """Handles audio transcription requests (enabled).""" |
| 286 | + return await route_general_transcriptions( # type: ignore |
| 287 | + request, "/v1/audio/transcriptions", background_tasks |
| 288 | + ) |
| 289 | +else: |
| 290 | + # Provide a stub endpoint only if you prefer a 404 instead of the route being absent. |
| 291 | + # For now we omit registering the path when support is unavailable to avoid |
| 292 | + # advertising a non-functional operation in the OpenAPI schema. |
| 293 | + pass |
0 commit comments