glm-4v series max_tokens wrong #5337

Closed
opened 2026-02-21 18:10:29 -05:00 by yindo · 1 comment
Owner

Originally created by @orangeclk on GitHub (Sep 1, 2024).

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

0.7.2

Cloud or Self Hosted

Self Hosted (Source)

Steps to reproduce

  1. Use the glm4v series model and adjust max_tokens to above 1024.
  2. Type anything.

✔️ Expected Behavior

No response

Actual Behavior

image

Originally created by @orangeclk on GitHub (Sep 1, 2024). ### 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 0.7.2 ### Cloud or Self Hosted Self Hosted (Source) ### Steps to reproduce 1. Use the glm4v series model and adjust max_tokens to above 1024. 2. Type anything. ### ✔️ Expected Behavior _No response_ ### ❌ Actual Behavior ![image](https://github.com/user-attachments/assets/d0754651-c4b5-4e3b-a913-0d2a17ebeb5a)
yindo added the 🐞 bug label 2026-02-21 18:10:29 -05:00
yindo closed this issue 2026-02-21 18:10:29 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Sep 1, 2024):

I found two similar discussions that might be relevant to your issue:

  1. Max Token Limits Incorrect? (open) [1]
  2. Error when I modify the max_tokens of the custom Maximum chunk length from 1000 to 2000 (open) [2]

To resolve the "[zhipuai] Error: RetryError(<Future at 0x7fd05a3c41f0 state=finished raised APIRequestFailedError>)" when setting max_tokens above 1024 in the glm-4v series model, ensure that the max_tokens parameter is set within the allowed range specified in the configuration. According to the provided YAML configuration, the max_tokens parameter has a range from 1 to 8192.

Here is the relevant part of the configuration:

- name: max_tokens
  use_template: max_tokens
  default: 1024
  min: 1
  max: 8192

Make sure that the value you are setting for max_tokens does not exceed 8192. If you are setting it within this range and still encountering the error, it might be due to other constraints or limitations imposed by the API or the environment in which the model is running. Additionally, ensure that other parameters such as temperature and top_p are set correctly, as improper settings might also contribute to the issue [3][4].

To continue talking to Dosu, mention @dosu.

@dosubot[bot] commented on GitHub (Sep 1, 2024): <!-- Answer --> I found two similar discussions that might be relevant to your issue: 1. [Max Token Limits Incorrect?](https://github.com/langgenius/dify/discussions/7243) (open) <sup>[[1]](https://github.com/langgenius/dify/discussions/7243)</sup> 2. [Error when I modify the max_tokens of the custom Maximum chunk length from 1000 to 2000](https://github.com/langgenius/dify/discussions/4080) (open) <sup>[[2]](https://github.com/langgenius/dify/discussions/4080)</sup> To resolve the "[zhipuai] Error: RetryError(<Future at 0x7fd05a3c41f0 state=finished raised APIRequestFailedError>)" when setting `max_tokens` above 1024 in the glm-4v series model, ensure that the `max_tokens` parameter is set within the allowed range specified in the configuration. According to the provided YAML configuration, the `max_tokens` parameter has a range from 1 to 8192. Here is the relevant part of the configuration: ```yaml - name: max_tokens use_template: max_tokens default: 1024 min: 1 max: 8192 ``` Make sure that the value you are setting for `max_tokens` does not exceed 8192. If you are setting it within this range and still encountering the error, it might be due to other constraints or limitations imposed by the API or the environment in which the model is running. Additionally, ensure that other parameters such as `temperature` and `top_p` are set correctly, as improper settings might also contribute to the issue <sup>[[3]](https://github.com/langgenius/dify/blob/main/api/core/model_runtime/model_providers/zhipuai/llm/glm_4v.yaml)</sup><sup>[[4]](https://github.com/langgenius/dify/blob/main/api/core/model_runtime/model_providers/zhipuai/llm/glm-4-airx.yaml)</sup>. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#5337