Skip to content

Commit d9455d3

Browse files
committed
feat(component,ai,gemini): implement automatic format conversion for unsupported media types (#1128)
Because - Users had to manually convert media formats or use special syntax (`:png`, `:pdf`, etc.) when working with formats not directly supported by Gemini API - The existing validation system only provided error messages suggesting manual conversion, creating friction in the user experience - The complex `formatSupport` struct and validation logic made the codebase harder to maintain and understand This commit - Implements automatic format conversion for unsupported MIME types in Gemini AI component: - **Images**: Automatically converts GIF, BMP, TIFF → PNG - **Videos**: Automatically converts MKV → MP4 - **Audio**: Automatically converts M4A, WMA → FLAC - **Documents**: Automatically converts Office formats (DOC, DOCX, PPT, PPTX, XLS, XLSX) → PDF, and processes text-based formats (HTML, Markdown, CSV) as plain text - Refactors format definitions by removing the complex `formatSupport` struct and replacing it with simple arrays for Gemini-supported and convertible formats - Removes the `validateFormat` function that only provided error messages, replacing it with direct format checking and conversion logic - Provides clear error messages for truly unsupported formats that cannot be converted - Ensures consistent behavior across all media processing paths (both inline data and File API)
1 parent b3c3699 commit d9455d3

File tree

2 files changed

+315
-240
lines changed

2 files changed

+315
-240
lines changed

0 commit comments

Comments
 (0)