fix: Resolve Gemini video file upload error #5166
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
[fix] Resolve Gemini video file upload error
Description
This PR fixes the video file upload error when using Gemini models with file inputs, addressing issue #4857.
Problem
Users were encountering a 400 INVALID_ARGUMENT error when trying to upload video files to Gemini models. The error occurred because:
Video(content=video_file)instead ofVideo(url=video_file.uri)Solution
1. Fixed Video Constructor Usage:
Video(content=video_file)toVideo(url=video_file.uri)in the cookbook example2. Added Robust Error Handling:
files.list()when file information is missing from upload responsesChanges Made
Files Modified:
cookbook/models/google/gemini/video_input_file_upload.py: Fixed Video constructor usagelibs/agno/agno/models/google/gemini.py: Added error handling for Google library bugsKey Changes:
Video(content=video_file)toVideo(url=video_file.uri)Testing
ruffmypytype checkingImpact
Related Issues
Fixes #4857
Checklist
./scripts/format.bat./scripts/validate.bat[fix] Resolve Gemini video file upload errorfixes #4857