@tduncan / Nvidia-Optimization-Stack-VLLM Mirror · read-only / commits / 7d4aedae7c
Fork 0

A high-throughput and memory-efficient inference and serving engine for LLMs

Mirrored from https://github.com/tduncan-lum/Nvidia-Optimization-Stack---VLLM.git

Synced Nov 15, 11:00 UTC

Handle error when `str` passed to `/v1/audio/transcriptions` (#17909)

Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>

Harry Mellor committed May 9, 2025 at 20:23 UTC 7d4aedae7c3e1ff4a1b1dea1f8df3257a7878d0a
1 file changed +9 -2
vllm/entrypoints/openai/protocol.py
+9 -2
@@ -5,10 +5,11 @@
5 import json
6 import re
7 import time
8 +from http import HTTPStatus
9 from typing import Annotated, Any, ClassVar, Literal, Optional, Union
10
11 import torch
11 -from fastapi import UploadFile
12 +from fastapi import HTTPException, UploadFile
13 from pydantic import (BaseModel, ConfigDict, Field, TypeAdapter,
14 ValidationInfo, field_validator, model_validator)
15 from typing_extensions import TypeAlias
@@ -1727,7 +1728,13 @@ class TranscriptionRequest(OpenAIBaseModel):
1728
1729 @model_validator(mode="before")
1730 @classmethod
1730 - def validate_stream_options(cls, data):
1731 + def validate_transcription_request(cls, data):
1732 + if isinstance(data.get("file"), str):
1733 + raise HTTPException(
1734 + status_code=HTTPStatus.UNPROCESSABLE_ENTITY,
1735 + detail="Expected 'file' to be a file-like object, not 'str'.",
1736 + )
1737 +
1738 stream_opts = ["stream_include_usage", "stream_continuous_usage_stats"]
1739 stream = data.get("stream", False)
1740 if any(bool(data.get(so, False)) for so in stream_opts) and not stream: