Incorrect Handling of Image Input for gemma3:27b with Ollama Provider #12086

Closed
opened 2026-02-21 19:05:42 -05:00 by yindo · 0 comments
Owner

Originally created by @codeMonkey-shin on GitHub (Mar 25, 2025).

Self Checks

  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

1.1.3

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

When using the gemma3:27b model with the Ollama provider in Dify, an error occurs when attempting to send an image. The error message states:

Query or prefix prompt is too long, you can reduce the prefix prompt, or shrink the max token, or switch to a llm with a larger token limit size.
This issue occurs because images are currently being converted to base64 and included in the prompt. However, Ollama does not process images in this manner. Instead, images should be sent via multipart form-data or referenced using a URL.

The previous issue regarding this problem was closed as a duplicate, with the suggestion to reduce image size. However, this is not the correct solution. The actual fix requires modifying the code to properly handle image input according to Ollama’s expected format.

Steps to Reproduce

  1. Use Dify with the Ollama provider and gemma3:27b model.
  2. Send an image in a request.
  3. Observe the error message indicating that the query is too long.

Please do not suggest an incorrect solution such as further reducing an image that is already under 10KB or minimizing the token size of a base64-encoded image. The issue is not about image size but rather the incorrect method of handling image inputs. Images should be sent via multipart form-data or referenced using a URL, as Ollama does not process base64-encoded images in the prompt.

I checked the API request, and it actually uploads the image first and retrieves the image ID. Then, the request is sent with the image ID attached.

✔️ Expected Behavior

Dify should properly send images using multipart form-data or a URL, ensuring correct processing by Ollama.

Actual Behavior

Modify the implementation so that images are sent in a format supported by Ollama, rather than converting them to base64 and embedding them in the prompt.

Please reconsider this issue as it is not simply a duplicate but requires a code-level fix.

Originally created by @codeMonkey-shin on GitHub (Mar 25, 2025). ### Self Checks - [x] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [x] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [x] I confirm that I am using English to submit this report (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)). - [x] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:) - [x] Please do not modify this template :) and fill in all the required fields. ### Dify version 1.1.3 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce When using the gemma3:27b model with the Ollama provider in Dify, an error occurs when attempting to send an image. The error message states: Query or prefix prompt is too long, you can reduce the prefix prompt, or shrink the max token, or switch to a llm with a larger token limit size. This issue occurs because images are currently being converted to base64 and included in the prompt. However, Ollama does not process images in this manner. Instead, images should be sent via multipart form-data or referenced using a URL. The previous issue regarding this problem was closed as a duplicate, with the suggestion to reduce image size. However, this is not the correct solution. The actual fix requires modifying the code to properly handle image input according to Ollama’s expected format. Steps to Reproduce 1. Use Dify with the Ollama provider and gemma3:27b model. 2. Send an image in a request. 3. Observe the error message indicating that the query is too long. Please do not suggest an incorrect solution such as further reducing an image that is already under 10KB or minimizing the token size of a base64-encoded image. The issue is not about image size but rather the incorrect method of handling image inputs. Images should be sent via multipart form-data or referenced using a URL, as Ollama does not process base64-encoded images in the prompt. I checked the API request, and it actually uploads the image first and retrieves the image ID. Then, the request is sent with the image ID attached. ### ✔️ Expected Behavior Dify should properly send images using multipart form-data or a URL, ensuring correct processing by Ollama. ### ❌ Actual Behavior Modify the implementation so that images are sent in a format supported by Ollama, rather than converting them to base64 and embedding them in the prompt. Please reconsider this issue as it is not simply a duplicate but requires a code-level fix.
yindo added the 🐞 bug label 2026-02-21 19:05:42 -05:00
yindo closed this issue 2026-02-21 19:05:42 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#12086