[BugFix] Fix leftovers of the legacy OpenAI realtime API event names (#7426)
Signed-off-by: Nick Cao <ncao@redhat.com> Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
1 parent
78e1a0ae5c
commit
d3493384cf
10 files changed
+103
-48
No files matched your search
@@ -14,6 +14,7 @@ import weakref
|
||||
from typing import Any
|
||||
|
||||
import pytest
|
||||
import torch
|
||||
from PIL import Image
|
||||
|
||||
from vllm_omni.entrypoints.openai import video_stream_base, video_stream_envs
|
||||
@@ -457,6 +458,54 @@ async def test_async_chunk_mode_is_read_by_engine_path_at_runtime(monkeypatch):
|
||||
assert not any(m.get("type") == "response.text.delta" for m in ws_off.sent)
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.parametrize("async_chunk_mode", ["on", "off"])
|
||||
async def test_audio_events_use_output_audio_names(monkeypatch, async_chunk_mode):
|
||||
class AudioEngine:
|
||||
def generate(self, **_kwargs):
|
||||
async def _gen():
|
||||
yield _audio_result([torch.zeros(1)])
|
||||
|
||||
return _gen()
|
||||
|
||||
class AudioHandler(QwenOmniStreamingVideoHandler):
|
||||
async def _preprocess_to_engine_prompt(self, request):
|
||||
return {"prompt": "x"}
|
||||
|
||||
monkeypatch.setenv("VLLM_VIDEO_ASYNC_CHUNK", async_chunk_mode)
|
||||
monkeypatch.setattr(
|
||||
OmniStreamingVideoHandler,
|
||||
"_encode_audio_wav_b64",
|
||||
staticmethod(lambda _audio: "audio-b64"),
|
||||
)
|
||||
|
||||
ws = MockWebSocket()
|
||||
handler = AudioHandler(chat_service=object(), engine_client=AudioEngine())
|
||||
config = StreamingVideoSessionConfig(model="test", modalities=["text", "audio"])
|
||||
|
||||
await handler._process_query_engine(
|
||||
ws,
|
||||
config,
|
||||
[_b64(_make_jpeg())],
|
||||
bytearray(),
|
||||
[],
|
||||
"describe",
|
||||
"req-audio-events",
|
||||
asyncio.Event(),
|
||||
{},
|
||||
)
|
||||
|
||||
audio_events = [message for message in ws.sent if "audio" in message.get("type", "")]
|
||||
assert audio_events == [
|
||||
{
|
||||
"type": "response.output_audio.delta",
|
||||
"data": "audio-b64",
|
||||
"format": "wav",
|
||||
},
|
||||
{"type": "response.output_audio.done"},
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_query_without_engine_client_sends_error():
|
||||
ws = MockWebSocket()
|
||||
|
||||
Reference in new issue
Block a user