Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve MIME type detection for image URLs #6531

Merged
merged 1 commit into from
Aug 25, 2024

Conversation

Seayon
Copy link
Contributor

@Seayon Seayon commented Jul 22, 2024

Implement fallback to content-based detection using Pillow when URL-based guess fails, enhancing accuracy while maintaining efficiency.

Checklist:

Important

Please review the checklist below before submitting your pull request.

  • Please open an issue before creating a PR or link to an existing issue
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I ran dev/reformat(backend) and cd web && npx lint-staged(frontend) to appease the lint gods

Description

Describe the big picture of your changes here to communicate to the maintainers why we should accept this pull request. If it fixes a bug or resolves a feature request, be sure to link to that issue. Close issue syntax: Fixes #<issue number>, see documentation for more details.

Fixes #6529

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update, included: Dify Document
  • Improvement, including but not limited to code refactoring, performance optimization, and UI/UX improvement
  • Dependency upgrade

Testing Instructions

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Test A
  • I uploaded an image to Aliyun OSS that was actually in JPEG format but had a PNG file extension. When I tried to use Anthropic's LLM for image recognition, it resulted in an error.
    After making the modifications, I used the same image again, and the API call was successful. Everything worked normally.
  • Test B

@dosubot dosubot bot added size:S This PR changes 10-29 lines, ignoring generated files. ⚙️ feat:model-runtime 💪 enhancement New feature or request labels Jul 22, 2024
@laipz8200
Copy link
Member

Hello @Seayon, sorry for replying so late, could you please sync your branch with the main branch first? I think this PR could be merged.

@Seayon Seayon force-pushed the feature/optimize-mimetype-guess branch 3 times, most recently from 242d7ab to a908eaa Compare August 25, 2024 05:13
Implement fallback to content-based detection using Pillow when URL-based guess fails, enhancing accuracy while maintaining efficiency.
@Seayon Seayon force-pushed the feature/optimize-mimetype-guess branch from a908eaa to bd32dd9 Compare August 25, 2024 05:21
@Seayon
Copy link
Contributor Author

Seayon commented Aug 25, 2024

Hello @Seayon, sorry for replying so late, could you please sync your branch with the main branch first? I think this PR could be merged.

Hello @laipz8200

Thank you for your review. I've synced the branch with the main branch and performed some cleanup. The branch should now be up-to-date, and the commits are clean. I look forward to your approval for merging this PR.

Let me know if you need any further information or changes.

Copy link
Member

@laipz8200 laipz8200 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Aug 25, 2024
@laipz8200 laipz8200 merged commit 561a61e into langgenius:main Aug 25, 2024
6 checks passed
cuiks pushed a commit to cuiks/dify that referenced this pull request Sep 2, 2024
idonotknow pushed a commit to AceDataCloud/Dify that referenced this pull request Nov 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💪 enhancement New feature or request ⚙️ feat:model-runtime lgtm This PR has been approved by a maintainer size:S This PR changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enhance MIME type detection for image URLs to improve robustness
2 participants