Unverified Commit 22f1ab15 authored by Ayush Agarwal's avatar Ayush Agarwal Committed by GitHub
Browse files

fix(vllm-omni): Fix call to normalize_finish_reason on OmniHandler for main (#6910)


Signed-off-by: default avatarayushag <ayushag@nvidia.com>
parent 844000eb
...@@ -25,6 +25,7 @@ from dynamo.common.protocols.video_protocol import ( ...@@ -25,6 +25,7 @@ from dynamo.common.protocols.video_protocol import (
VideoData, VideoData,
) )
from dynamo.common.storage import upload_to_fs from dynamo.common.storage import upload_to_fs
from dynamo.common.utils.engine_response import normalize_finish_reason
from dynamo.common.utils.output_modalities import RequestType, parse_request_type from dynamo.common.utils.output_modalities import RequestType, parse_request_type
from dynamo.common.utils.video_utils import ( from dynamo.common.utils.video_utils import (
compute_num_frames, compute_num_frames,
...@@ -513,7 +514,7 @@ class OmniHandler(BaseOmniHandler): ...@@ -513,7 +514,7 @@ class OmniHandler(BaseOmniHandler):
"role": "assistant", "role": "assistant",
"content": delta_text, "content": delta_text,
}, },
"finish_reason": self._normalize_finish_reason(output.finish_reason) "finish_reason": normalize_finish_reason(output.finish_reason)
if output.finish_reason if output.finish_reason
else None, else None,
} }
......
...@@ -151,7 +151,6 @@ class TestFormatTextChunk: ...@@ -151,7 +151,6 @@ class TestFormatTextChunk:
def test_finish_reason_included(self): def test_finish_reason_included(self):
"""Final chunk includes finish_reason and usage stats.""" """Final chunk includes finish_reason and usage stats."""
handler = _make_handler() handler = _make_handler()
handler._normalize_finish_reason = lambda r: r
handler._build_completion_usage = lambda ro: { handler._build_completion_usage = lambda ro: {
"prompt_tokens": 3, "prompt_tokens": 3,
"completion_tokens": 1, "completion_tokens": 1,
...@@ -161,6 +160,24 @@ class TestFormatTextChunk: ...@@ -161,6 +160,24 @@ class TestFormatTextChunk:
assert chunk["choices"][0]["finish_reason"] == "stop" assert chunk["choices"][0]["finish_reason"] == "stop"
assert "usage" in chunk assert "usage" in chunk
def test_finish_reason_abort_normalized(self):
"""Abort finish reason is normalized to 'cancelled'."""
handler = _make_handler()
handler._build_completion_usage = lambda ro: {
"prompt_tokens": 3,
"completion_tokens": 1,
}
ro = self._make_output("done", finish_reason="abort")
chunk = handler._format_text_chunk(ro, "req-1", "")
assert chunk["choices"][0]["finish_reason"] == "cancelled"
def test_finish_reason_none_when_not_finished(self):
"""finish_reason is None when output has no finish_reason."""
handler = _make_handler()
ro = self._make_output("partial")
chunk = handler._format_text_chunk(ro, "req-1", "")
assert chunk["choices"][0]["finish_reason"] is None
class TestFormatImageChunk: class TestFormatImageChunk:
@pytest.mark.asyncio @pytest.mark.asyncio
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment