Error Occurs When Sending Images to Gemma 3:27b Model with Ollama Provider #12082

Closed
opened 2026-02-21 19:05:40 -05:00 by yindo · 1 comment
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 Dify with the Ollama provider and sending an image to the gemma3:27b model, the following error occurs:

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.

✔️ Expected Behavior

vision answer

Actual Behavior

error: 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.

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 Dify with the Ollama provider and sending an image to the gemma3:27b model, the following error occurs: 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. ### ✔️ Expected Behavior vision answer ### ❌ Actual Behavior error: 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.
yindo added the 🐞 bug label 2026-02-21 19:05:40 -05:00
yindo closed this issue 2026-02-21 19:05:40 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Mar 25, 2025):

To resolve the "Query or prefix prompt is too long" error when using the Gemma 3:27b model with the Ollama provider in Dify version 1.1.3, consider the following steps:

  1. Upload a Smaller Image: Since images are encoded as base64, they consume a significant portion of the available context tokens. By uploading a smaller image, you can reduce the number of tokens used.

  2. Lower the 'Max Token' Value: Adjust the 'Max token' value in the parameter settings on the orchestration page to ensure that the total of prompt tokens and max tokens stays within the model's context size limit.

  3. Reduce the Prefix Prompt: Decrease the size of the prefix prompt to free up more tokens for the image data.

  4. Switch to a Model with a Larger Token Limit: If possible, switch to a language model that supports a larger token limit size to accommodate the image data and prompt [1][2][3].

The maximum token limit for the Gemma 3:27b model when using the Ollama provider is 8192 tokens [1].

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

@dosubot[bot] commented on GitHub (Mar 25, 2025): <!-- Answer --> To resolve the "Query or prefix prompt is too long" error when using the Gemma 3:27b model with the Ollama provider in Dify version 1.1.3, consider the following steps: 1. **Upload a Smaller Image**: Since images are encoded as base64, they consume a significant portion of the available context tokens. By uploading a smaller image, you can reduce the number of tokens used. 2. **Lower the 'Max Token' Value**: Adjust the 'Max token' value in the parameter settings on the orchestration page to ensure that the total of prompt tokens and max tokens stays within the model's context size limit. 3. **Reduce the Prefix Prompt**: Decrease the size of the prefix prompt to free up more tokens for the image data. 4. **Switch to a Model with a Larger Token Limit**: If possible, switch to a language model that supports a larger token limit size to accommodate the image data and prompt <sup>[[1]](https://github.com/langgenius/dify/issues/15788)</sup><sup>[[2]](https://github.com/langgenius/dify/issues/15806)</sup><sup>[[3]](https://github.com/langgenius/dify/issues/14854)</sup>. The maximum token limit for the Gemma 3:27b model when using the Ollama provider is 8192 tokens <sup>[[1]](https://github.com/langgenius/dify/issues/15788)</sup>. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.* --- <sup>Help Dosu learn! Give it feedback: [Great Response](https://app.dosu.dev/response-feedback/5cf88d93-1e06-405c-aea3-c45d288712d0?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/5cf88d93-1e06-405c-aea3-c45d288712d0?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/5cf88d93-1e06-405c-aea3-c45d288712d0?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/5cf88d93-1e06-405c-aea3-c45d288712d0?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/5cf88d93-1e06-405c-aea3-c45d288712d0?feedback_type=hallucination) | [Bug Report](https://app.dosu.dev/response-feedback/5cf88d93-1e06-405c-aea3-c45d288712d0?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/5cf88d93-1e06-405c-aea3-c45d288712d0?feedback_type=other)</sup>
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#12082