mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-07 02:59:05 +00:00
openai(video): use GET for /videos/{id}/content by returning empty params; add tests to assert GET (#16672)
This commit is contained in:
parent
63994e302e
commit
f599a462c1
2 changed files with 52 additions and 5 deletions
|
|
@ -178,10 +178,10 @@ class OpenAIVideoConfig(BaseVideoConfig):
|
|||
# Construct the URL for video content download
|
||||
url = f"{api_base.rstrip('/')}/{original_video_id}/content"
|
||||
|
||||
# Add video_id as query parameter
|
||||
params = {"video_id": original_video_id}
|
||||
|
||||
return url, params
|
||||
# No additional data needed for GET content request
|
||||
data: Dict[str, Any] = {}
|
||||
|
||||
return url, data
|
||||
|
||||
def transform_video_remix_request(
|
||||
self,
|
||||
|
|
@ -404,4 +404,4 @@ class OpenAIVideoConfig(BaseVideoConfig):
|
|||
if isinstance(image, BufferedReader):
|
||||
files_list.append((field_name, (image.name, image, image_content_type)))
|
||||
else:
|
||||
files_list.append((field_name, ("input_reference.png", image, image_content_type)))
|
||||
files_list.append((field_name, ("input_reference.png", image, image_content_type)))
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import litellm
|
|||
from litellm.types.videos.main import VideoObject, VideoResponse
|
||||
from litellm.videos.main import video_generation, avideo_generation, video_status, avideo_status
|
||||
from litellm.llms.openai.videos.transformation import OpenAIVideoConfig
|
||||
from litellm.llms.custom_httpx.llm_http_handler import BaseLLMHTTPHandler
|
||||
from litellm.cost_calculator import default_video_cost_calculator
|
||||
from litellm.litellm_core_utils.litellm_logging import Logging as LitellmLogging
|
||||
from litellm.integrations.custom_logger import CustomLogger
|
||||
|
|
@ -713,5 +714,51 @@ class TestVideoLogging:
|
|||
# The important thing is that the logging payload is created and recognized
|
||||
|
||||
|
||||
def test_openai_transform_video_content_request_empty_params():
|
||||
"""OpenAI content transform should return empty params to ensure GET is used."""
|
||||
config = OpenAIVideoConfig()
|
||||
url, params = config.transform_video_content_request(
|
||||
video_id="video_123",
|
||||
api_base="https://api.openai.com/v1/videos",
|
||||
litellm_params={},
|
||||
headers={},
|
||||
)
|
||||
|
||||
assert url == "https://api.openai.com/v1/videos/video_123/content"
|
||||
assert params == {}
|
||||
|
||||
|
||||
def test_video_content_handler_uses_get_for_openai():
|
||||
"""HTTP handler must use GET (not POST) for OpenAI content download."""
|
||||
handler = BaseLLMHTTPHandler()
|
||||
config = OpenAIVideoConfig()
|
||||
|
||||
mock_client = MagicMock()
|
||||
mock_response = MagicMock()
|
||||
mock_response.content = b"mp4-bytes"
|
||||
mock_client.get.return_value = mock_response
|
||||
|
||||
with patch(
|
||||
"litellm.llms.custom_httpx.llm_http_handler._get_httpx_client",
|
||||
return_value=mock_client,
|
||||
):
|
||||
result = handler.video_content_handler(
|
||||
video_id="video_abc",
|
||||
video_content_provider_config=config,
|
||||
custom_llm_provider="openai",
|
||||
litellm_params={"api_base": "https://api.openai.com/v1"},
|
||||
logging_obj=MagicMock(),
|
||||
timeout=5.0,
|
||||
api_key="sk-test",
|
||||
_is_async=False,
|
||||
)
|
||||
|
||||
assert result == b"mp4-bytes"
|
||||
mock_client.get.assert_called_once()
|
||||
assert not mock_client.post.called
|
||||
called_url = mock_client.get.call_args.kwargs["url"]
|
||||
assert called_url == "https://api.openai.com/v1/videos/video_abc/content"
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
pytest.main([__file__])
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue