From 11dd7420ec7e0b3d15c4b476291389d42c5fb5aa Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 29 Jan 2026 02:19:04 +0000 Subject: [PATCH 1/3] Initial plan From b4cd7c479f00cc12c2f254d263350d1750dd04f7 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 29 Jan 2026 02:22:47 +0000 Subject: [PATCH 2/3] Fix vLLM AudioMediaIO compatibility issue Add try-except blocks to handle both old and new vLLM versions where AudioMediaIO may not exist or may have been moved. This fixes the AttributeError when using newer vLLM versions. - Handle missing AudioMediaIO by creating standalone implementation - Add fallback for utils module patching - Maintain backward compatibility with older vLLM versions Co-authored-by: donglixp <1070872+donglixp@users.noreply.github.com> --- vllm_plugin/model.py | 66 +++++++++++++++++++++++++++++++++----------- 1 file changed, 50 insertions(+), 16 deletions(-) diff --git a/vllm_plugin/model.py b/vllm_plugin/model.py index bcb4ca3..535e02c 100644 --- a/vllm_plugin/model.py +++ b/vllm_plugin/model.py @@ -73,26 +73,60 @@ def _ffmpeg_load_file(filepath) -> tuple[np.ndarray, int]: # Register FFmpeg-based audio loader import vllm.multimodal.audio as _vllm_audio_module -_OriginalAudioMediaIO = _vllm_audio_module.AudioMediaIO -class _PatchedAudioMediaIO(_OriginalAudioMediaIO): - """AudioMediaIO implementation using FFmpeg for audio decoding.""" +# Handle both old and new vLLM versions +# In newer versions, AudioMediaIO may not exist or may have been moved +try: + _OriginalAudioMediaIO = _vllm_audio_module.AudioMediaIO - def load_bytes(self, data: bytes) -> tuple[np.ndarray, int]: - return _ffmpeg_load_bytes(data, media_type=None) + class _PatchedAudioMediaIO(_OriginalAudioMediaIO): + """AudioMediaIO implementation using FFmpeg for audio decoding.""" + + def load_bytes(self, data: bytes) -> tuple[np.ndarray, int]: + return _ffmpeg_load_bytes(data, media_type=None) + + def load_base64(self, media_type: str, data: str) -> tuple[np.ndarray, int]: + return _ffmpeg_load_bytes(base64.b64decode(data), media_type=media_type) + + def load_file(self, filepath) -> tuple[np.ndarray, int]: + return _ffmpeg_load_file(filepath) - def load_base64(self, media_type: str, data: str) -> tuple[np.ndarray, int]: - return _ffmpeg_load_bytes(base64.b64decode(data), media_type=media_type) + # Replace globally + _vllm_audio_module.AudioMediaIO = _PatchedAudioMediaIO - def load_file(self, filepath) -> tuple[np.ndarray, int]: - return _ffmpeg_load_file(filepath) - -# Replace globally -_vllm_audio_module.AudioMediaIO = _PatchedAudioMediaIO - -# Also patch in utils module where it's imported -import vllm.multimodal.utils as _vllm_utils_module -_vllm_utils_module.AudioMediaIO = _PatchedAudioMediaIO + # Also patch in utils module where it's imported + try: + import vllm.multimodal.utils as _vllm_utils_module + _vllm_utils_module.AudioMediaIO = _PatchedAudioMediaIO + except (ImportError, AttributeError): + pass # Utils module may not have AudioMediaIO in newer versions + +except AttributeError: + # AudioMediaIO doesn't exist in this vLLM version + # Define our own standalone implementation + class _PatchedAudioMediaIO: + """Standalone AudioMediaIO implementation using FFmpeg for audio decoding. + + This is used when vLLM doesn't provide AudioMediaIO or it's been moved/removed. + """ + + def __init__(self, **kwargs): + pass + + def load_bytes(self, data: bytes) -> tuple[np.ndarray, int]: + return _ffmpeg_load_bytes(data, media_type=None) + + def load_base64(self, media_type: str, data: str) -> tuple[np.ndarray, int]: + return _ffmpeg_load_bytes(base64.b64decode(data), media_type=media_type) + + def load_file(self, filepath) -> tuple[np.ndarray, int]: + return _ffmpeg_load_file(filepath) + + # Try to register it in the module if possible + try: + _vllm_audio_module.AudioMediaIO = _PatchedAudioMediaIO + except (AttributeError, TypeError): + pass # Can't set attribute, audio loading will use our functions directly # ============================================================================ From 61ecb098d6b6ff33f4cc82f0ac83d375f26b2d88 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 29 Jan 2026 02:24:53 +0000 Subject: [PATCH 3/3] Improve error handling and logging for AudioMediaIO compatibility - Add warnings to inform users which compatibility mode is being used - Handle both AttributeError and ImportError for better coverage - Add __init__ method to inherited class for consistency - Provide clear diagnostic messages when patching fails Co-authored-by: donglixp <1070872+donglixp@users.noreply.github.com> --- vllm_plugin/model.py | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/vllm_plugin/model.py b/vllm_plugin/model.py index 535e02c..454236f 100644 --- a/vllm_plugin/model.py +++ b/vllm_plugin/model.py @@ -73,6 +73,7 @@ def _ffmpeg_load_file(filepath) -> tuple[np.ndarray, int]: # Register FFmpeg-based audio loader import vllm.multimodal.audio as _vllm_audio_module +import warnings # Handle both old and new vLLM versions # In newer versions, AudioMediaIO may not exist or may have been moved @@ -82,6 +83,11 @@ def _ffmpeg_load_file(filepath) -> tuple[np.ndarray, int]: class _PatchedAudioMediaIO(_OriginalAudioMediaIO): """AudioMediaIO implementation using FFmpeg for audio decoding.""" + def __init__(self, **kwargs): + # Call parent constructor if it exists + if hasattr(super(), '__init__'): + super().__init__(**kwargs) + def load_bytes(self, data: bytes) -> tuple[np.ndarray, int]: return _ffmpeg_load_bytes(data, media_type=None) @@ -98,12 +104,18 @@ def load_file(self, filepath) -> tuple[np.ndarray, int]: try: import vllm.multimodal.utils as _vllm_utils_module _vllm_utils_module.AudioMediaIO = _PatchedAudioMediaIO - except (ImportError, AttributeError): - pass # Utils module may not have AudioMediaIO in newer versions + except (ImportError, AttributeError) as e: + warnings.warn(f"Could not patch AudioMediaIO in vllm.multimodal.utils: {e}", UserWarning) -except AttributeError: +except (AttributeError, ImportError) as e: # AudioMediaIO doesn't exist in this vLLM version # Define our own standalone implementation + warnings.warn( + f"AudioMediaIO not found in vllm.multimodal.audio ({e}). " + "Using standalone FFmpeg-based implementation for compatibility.", + UserWarning + ) + class _PatchedAudioMediaIO: """Standalone AudioMediaIO implementation using FFmpeg for audio decoding. @@ -125,8 +137,12 @@ def load_file(self, filepath) -> tuple[np.ndarray, int]: # Try to register it in the module if possible try: _vllm_audio_module.AudioMediaIO = _PatchedAudioMediaIO - except (AttributeError, TypeError): - pass # Can't set attribute, audio loading will use our functions directly + except (AttributeError, TypeError) as e: + warnings.warn( + f"Could not register AudioMediaIO in vllm.multimodal.audio: {e}. " + "Audio loading will use FFmpeg functions directly.", + UserWarning + ) # ============================================================================