mirror of
https://github.com/langgenius/dify-official-plugins.git
synced 2026-07-21 17:45:23 -04:00
[PR #1567] [MERGED] fix(gemini): filter unsupported file types before uploading to Gemini API #1960
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/langgenius/dify-official-plugins/pull/1567
Author: @QIN2DIM
Created: 8/23/2025
Status: ✅ Merged
Merged: 8/24/2025
Merged by: @crazywoola
Base:
main← Head:fix-files-memory📝 Commits (10+)
d10b5e9refactor(llm): restructure GoogleLargeLanguageModel methods for better organization22e9ebefix(llm): filter unsupported file types before uploading to Gemini API8e602fffix(gemini): update manifest version to 0.5.109d4789Update llm.pyfdf327ftest(gemini): add comprehensive document filtering tests for Gemini API1cf232dfix(gemini): resolve file memory issues and update test configurations1c80c3cfix(test): update file URI assertion in document filtering test900d33fdocs(tests): add comprehensive test instructions for gemini document filteringb0c7470fix(models): resolve file memory issues and rename test class66d13d1fix(gemini): update uv command in claude settings📊 Changes
9 files changed (+1256 additions, -180 deletions)
View changed files
📝
models/gemini/.claude/settings.local.json(+1 -1)📝
models/gemini/manifest.yaml(+1 -1)📝
models/gemini/models/llm/llm.py(+179 -161)📝
models/gemini/models/llm/utils.py(+42 -0)➕
models/gemini/models/tests/TEST_INSTRUCTIONS.md(+131 -0)➕
models/gemini/models/tests/test_document_filtering.py(+814 -0)📝
models/gemini/models/tests/test_feature_compatibility.py(+44 -6)📝
models/gemini/models/tests/test_llm.py(+11 -11)📝
models/gemini/pyproject.toml(+33 -0)📄 Description
Related Issues or Context
Title: feat: Enhance Document Filtering and Add Comprehensive Tests for Gemini API
Description
This pull request addresses a significant memory and performance issue by introducing a robust pre-upload filtering mechanism for documents sent to the Gemini API. It prevents unsupported file types (e.g., Microsoft Office, OpenDocument formats) from being uploaded, which reduces unnecessary API calls, prevents potential errors, and improves overall efficiency.
To ensure the reliability of this new functionality, a complete and comprehensive test suite has been added. Additionally, the core
GoogleLargeLanguageModelclass has been refactored for better code clarity and maintainability.Key Changes:
MemoryFileCache) to enable efficient testing without disk persistence.GoogleLargeLanguageModelclass to improve the logical flow, making the code easier to understand and maintain. This change is purely internal and does not affect the external API.0.5.1to incorporate these fixes.This PR contains Changes to Non-Plugin
This PR contains Changes to Non-LLM Models Plugin
This PR contains Changes to LLM Models Plugin
Version Control (Any Changes to the Plugin Will Require Bumping the Version)
VersionField, Not in Meta Section)Dify Plugin SDK Version
dify_plugin>=0.3.0,<0.5.0is in requirements.txt (SDK docs)Environment Verification (If Any Code Changes)
Local Deployment Environment
SaaS Environment
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.