Suggested questions after answer feature is not available in some large language models. #4253

Closed
opened 2026-02-21 18:05:24 -05:00 by yindo · 7 comments
Owner

Originally created by @KinWang130 on GitHub (Jun 25, 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).
  • Please do not modify this template :) and fill in all the required fields.

Dify version

0.6.11

Cloud or Self Hosted

Self Hosted (Source)

Steps to reproduce

When the system reasoning model uses Wenxin Yiyan or Zhipu AI, the next step problem suggestion function cannot be used, and the system reports an error. This is because the code has added parameter validation, in which the temperature parameter is set to 0 and cannot be less than the minimum value of the model. However, the temperature range of Wenxin Yiyan and Zhipu AI is (0, 1.0]. Moreover, the minimum value for Wenxin Yiyan is configured as 0.1.

The specific error and verification are as follows:

image
image
image
image

✔️ Expected Behavior

I hope the default value of temperature in api.core.llm_generator.llm_generator.LLMGenerator.generate_suggested_questions_after_answer can be modified to 0.1 or other methods can be used to fix this bug.

The goal is to ensure that the "Next Question Suggestion" function can work normally.

response = model_instance.invoke_llm(
prompt_messages=prompt_messages,
model_parameters={
"max_tokens": 256,
"temperature": 0.1
},
stream=False
)

Actual Behavior

ValueError: Model Parameter temperature should be greater than or equal to 0.1.

image
Originally created by @KinWang130 on GitHub (Jun 25, 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] Please do not modify this template :) and fill in all the required fields. ### Dify version 0.6.11 ### Cloud or Self Hosted Self Hosted (Source) ### Steps to reproduce When the system reasoning model uses Wenxin Yiyan or Zhipu AI, the next step problem suggestion function cannot be used, and the system reports an error. This is because the code has added parameter validation, in which the temperature parameter is set to 0 and cannot be less than the minimum value of the model. However, the temperature range of Wenxin Yiyan and Zhipu AI is (0, 1.0]. Moreover, the minimum value for Wenxin Yiyan is configured as 0.1. The specific error and verification are as follows: ![image](https://github.com/langgenius/dify/assets/33823007/b0f15013-cabe-4e5c-9582-7b77a471cdcb) ![image](https://github.com/langgenius/dify/assets/33823007/caffeaa0-b641-45ca-aed9-f0681869ac10) ![image](https://github.com/langgenius/dify/assets/33823007/4c24eaa0-2395-4418-b8bc-c231ff29c325) <img width="1220" alt="image" src="https://github.com/langgenius/dify/assets/33823007/cb55e1f9-2fa3-4405-9671-2a27a4b9043d"> ### ✔️ Expected Behavior I hope the default value of temperature in api.core.llm_generator.llm_generator.LLMGenerator.generate_suggested_questions_after_answer can be modified to 0.1 or other methods can be used to fix this bug. The goal is to ensure that the "Next Question Suggestion" function can work normally. response = model_instance.invoke_llm( prompt_messages=prompt_messages, model_parameters={ "max_tokens": 256, "temperature": 0.1 }, stream=False ) ### ❌ Actual Behavior ValueError: Model Parameter temperature should be greater than or equal to 0.1. <img width="1350" alt="image" src="https://github.com/langgenius/dify/assets/33823007/b6e0f55e-a972-4591-b52a-1ae9a586dd3d">
yindo added the 🐞 bug label 2026-02-21 18:05:24 -05:00
yindo closed this issue 2026-02-21 18:05:25 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Jun 25, 2024):

@KinWang130 你好! 我是Dosu,一个可以帮助你解决 bug、回答问题并成为贡献者的机器人。欢迎来到这里,我会在等待人类维护者的过程中帮助你。期待能解决你的问题!🤖

To resolve the issue with the "Suggested questions after answer" feature in the Wenxin Yiyan or Zhipu AI models, you need to ensure that the temperature parameter is set within the valid range specified in the configuration. For Wenxin Yiyan and Zhipu AI, the valid range for the temperature parameter is between 0.1 (inclusive) and 1.0 (inclusive).

Here is the relevant part of the configuration for Wenxin Yiyan:

parameter_rules:
  - name: temperature
    use_template: temperature
    default: 0.95
    min: 0.1
    max: 1.0
    help:
      en_US: Sampling temperature, controls the randomness of the output, must be a positive number. The value range is [0.1,1.0], which cannot be equal to 0. The default value is 0.95. The larger the value, the more random and creative the output will be; the smaller the value, the output will be more stable or certain. It is recommended that you adjust the top_p or temperature parameters according to the application scenario, but do not adjust both parameters at the same time.

To fix the issue, ensure that the temperature parameter is set to a value between 0.1 and 1.0. For example, you can set it to the default value of 0.95:

temperature: 0.95

Additionally, ensure that the suggested_questions_after_answer configuration is correctly set up. According to the SuggestedQuestionsAfterAnswerConfigManager class, the configuration should be a dictionary with an enabled key of boolean type:

class SuggestedQuestionsAfterAnswerConfigManager:
    @classmethod
    def validate_and_set_defaults(cls, config: dict) -> tuple[dict, list[str]]:
        if not config.get("suggested_questions_after_answer"):
            config["suggested_questions_after_answer"] = {
                "enabled": False
            }

        if not isinstance(config["suggested_questions_after_answer"], dict):
            raise ValueError("suggested_questions_after_answer must be of dict type")

        if "enabled" not in config["suggested_questions_after_answer"] or not \
        config["suggested_questions_after_answer"]["enabled"]:
            config["suggested_questions_after_answer"]["enabled"] = False

        if not isinstance(config["suggested_questions_after_answer"]["enabled"], bool):
            raise ValueError("enabled in suggested_questions_after_answer must be of boolean type")

        return config, ["suggested_questions_after_answer"]

Ensure that your configuration follows this structure to avoid any validation errors:

suggested_questions_after_answer:
  enabled: true

This should prevent the ValueError due to parameter validation [1][2][3][4][5].

To continue talking to Dosu, mention @dosu.

@dosubot[bot] commented on GitHub (Jun 25, 2024): <!-- Greeting --> @KinWang130 你好! 我是[Dosu](https://dosu.dev),一个可以帮助你解决 bug、回答问题并成为贡献者的机器人。欢迎来到这里,我会在等待人类维护者的过程中帮助你。期待能解决你的问题!🤖 <!-- Answer --> To resolve the issue with the "Suggested questions after answer" feature in the Wenxin Yiyan or Zhipu AI models, you need to ensure that the `temperature` parameter is set within the valid range specified in the configuration. For Wenxin Yiyan and Zhipu AI, the valid range for the `temperature` parameter is between 0.1 (inclusive) and 1.0 (inclusive). Here is the relevant part of the configuration for Wenxin Yiyan: ```yaml parameter_rules: - name: temperature use_template: temperature default: 0.95 min: 0.1 max: 1.0 help: en_US: Sampling temperature, controls the randomness of the output, must be a positive number. The value range is [0.1,1.0], which cannot be equal to 0. The default value is 0.95. The larger the value, the more random and creative the output will be; the smaller the value, the output will be more stable or certain. It is recommended that you adjust the top_p or temperature parameters according to the application scenario, but do not adjust both parameters at the same time. ``` To fix the issue, ensure that the `temperature` parameter is set to a value between 0.1 and 1.0. For example, you can set it to the default value of 0.95: ```yaml temperature: 0.95 ``` Additionally, ensure that the `suggested_questions_after_answer` configuration is correctly set up. According to the `SuggestedQuestionsAfterAnswerConfigManager` class, the configuration should be a dictionary with an `enabled` key of boolean type: ```py class SuggestedQuestionsAfterAnswerConfigManager: @classmethod def validate_and_set_defaults(cls, config: dict) -> tuple[dict, list[str]]: if not config.get("suggested_questions_after_answer"): config["suggested_questions_after_answer"] = { "enabled": False } if not isinstance(config["suggested_questions_after_answer"], dict): raise ValueError("suggested_questions_after_answer must be of dict type") if "enabled" not in config["suggested_questions_after_answer"] or not \ config["suggested_questions_after_answer"]["enabled"]: config["suggested_questions_after_answer"]["enabled"] = False if not isinstance(config["suggested_questions_after_answer"]["enabled"], bool): raise ValueError("enabled in suggested_questions_after_answer must be of boolean type") return config, ["suggested_questions_after_answer"] ``` Ensure that your configuration follows this structure to avoid any validation errors: ```yaml suggested_questions_after_answer: enabled: true ``` This should prevent the `ValueError` due to parameter validation <sup>[[1]](https://github.com/langgenius/dify/blob/main/api/core/model_runtime/model_providers/wenxin/llm/ernie-character-8k-0321.yaml)</sup><sup>[[2]](https://github.com/langgenius/dify/blob/main/api/core/app/app_config/features/suggested_questions_after_answer/manager.py)</sup><sup>[[3]](https://github.com/langgenius/dify/blob/main/api/core/model_runtime/model_providers/zhipuai/llm/chatglm_lite.yaml)</sup><sup>[[4]](https://github.com/langgenius/dify/blob/main/api/core/model_runtime/model_providers/zhipuai/llm/glm_3_turbo.yaml)</sup><sup>[[5]](https://github.com/langgenius/dify/blob/main/api/core/model_runtime/model_providers/zhipuai/llm/glm-4-0520.yaml)</sup>. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
Author
Owner

@KinWang130 commented on GitHub (Jun 25, 2024):

However, the temperature range of the ERNIE Bot API is (0,1], which is greater than 0. The code of Dify is set to 0. Therefore, the verification always fails

response = model_instance.invoke_llm(
prompt_messages=prompt_messages,
model_parameters={
"max_tokens": 256,
"temperature": 0.1
},
stream=False
)

@KinWang130 commented on GitHub (Jun 25, 2024): However, the temperature range of the ERNIE Bot API is (0,1], which is greater than 0. The code of Dify is set to 0. Therefore, the verification always fails response = model_instance.invoke_llm( prompt_messages=prompt_messages, model_parameters={ "max_tokens": 256, "temperature": 0.1 }, stream=False )
Author
Owner

@ouyang-yuxuan commented on GitHub (Jul 18, 2024):

I have the same problem with function calls.
image
image
But it works fine in ordinary applications.
image
image
The models involved are Wenxin Yiyan and qwen(百炼).

@ouyang-yuxuan commented on GitHub (Jul 18, 2024): **I have the same problem with function calls.** ![image](https://github.com/user-attachments/assets/fd1f4285-3f18-46ee-99c2-6643ff18380d) ![image](https://github.com/user-attachments/assets/12f47cf1-c255-4881-9612-6ffd8cb8c94a) **But it works fine in ordinary applications.** ![image](https://github.com/user-attachments/assets/2b16bc0c-edd2-4822-aec1-a348008f690a) ![image](https://github.com/user-attachments/assets/9f4609d5-9a19-41e8-8493-3f83c8c5d78d) **The models involved are Wenxin Yiyan and qwen(百炼).**
Author
Owner

@94163677 commented on GitHub (Aug 13, 2024):

The same problem with:

  1. Create Knowledge.
  2. "Segmenting in Question & Answer format" set to true.

error message:
ERROR [Dummy-137] [app.py:838] - Exception on /console/api/datasets/indexing-estimate [POST]
Traceback (most recent call last):
File "/app/api/controllers/console/datasets/datasets.py", line 388, in post
response = indexing_runner.indexing_estimate(current_user.current_tenant_id, extract_settings,
File "/app/api/core/indexing_runner.py", line 305, in indexing_estimate
response = LLMGenerator.generate_qa_document(current_user.current_tenant_id, preview_texts[0],
File "/app/api/core/llm_generator/llm_generator.py", line 291, in generate_qa_document
response = model_instance.invoke_llm(
File "/app/api/core/model_manager.py", line 123, in invoke_llm
return self._round_robin_invoke(
File "/app/api/core/model_manager.py", line 302, in _round_robin_invoke
return function(*args, **kwargs)
File "/app/api/core/model_runtime/model_providers/__base/large_language_model.py", line 66, in invoke
model_parameters = self._validate_and_filter_model_parameters(model, model_parameters, credentials)
File "/app/api/core/model_runtime/model_providers/__base/large_language_model.py", line 782, in _validate_and_filter_model_parameters
raise ValueError(
ValueError: Model Parameter temperature should be greater than or equal to 0.1.

SourceCode: dify\api\core\llm_generator\llm_generator.py, line 291, it was set temperature to 0.01
image

@94163677 commented on GitHub (Aug 13, 2024): The same problem with: 1. Create Knowledge. 2. "Segmenting in Question & Answer format" set to true. error message: ERROR [Dummy-137] [app.py:838] - Exception on /console/api/datasets/indexing-estimate [POST] Traceback (most recent call last): File "/app/api/controllers/console/datasets/datasets.py", line 388, in post response = indexing_runner.indexing_estimate(current_user.current_tenant_id, extract_settings, File "/app/api/core/indexing_runner.py", line 305, in indexing_estimate response = LLMGenerator.generate_qa_document(current_user.current_tenant_id, preview_texts[0], File "/app/api/core/llm_generator/llm_generator.py", line 291, in generate_qa_document response = model_instance.invoke_llm( File "/app/api/core/model_manager.py", line 123, in invoke_llm return self._round_robin_invoke( File "/app/api/core/model_manager.py", line 302, in _round_robin_invoke return function(*args, **kwargs) File "/app/api/core/model_runtime/model_providers/__base/large_language_model.py", line 66, in invoke model_parameters = self._validate_and_filter_model_parameters(model, model_parameters, credentials) File "/app/api/core/model_runtime/model_providers/__base/large_language_model.py", line 782, in _validate_and_filter_model_parameters raise ValueError( ValueError: Model Parameter temperature should be greater than or equal to 0.1. SourceCode: dify\api\core\llm_generator\llm_generator.py, line 291, it was set temperature to 0.01 ![image](https://github.com/user-attachments/assets/e3645639-c673-4499-a70e-d2ff227d786e)
Author
Owner

@Lyeluo commented on GitHub (Aug 14, 2024):

i use some model like doubao、qwen got suggested is empty 。。like this
'{"result": "success", "data": []}'

@Lyeluo commented on GitHub (Aug 14, 2024): i use some model like doubao、qwen got suggested is empty 。。like this '{"result": "success", "data": []}'
Author
Owner

@thepush2 commented on GitHub (Aug 14, 2024):

Hello, could you please tell me how to add the model on Aliyun Bailian platform? thank you。 (如何添加阿里云百炼平台上的模型到dify~)

@thepush2 commented on GitHub (Aug 14, 2024): Hello, could you please tell me how to add the model on Aliyun Bailian platform? thank you。 (如何添加阿里云百炼平台上的模型到dify~)
Author
Owner

@thepush2 commented on GitHub (Aug 15, 2024):

are the same, change the corresponding key can be

@thepush2 commented on GitHub (Aug 15, 2024): are the same, change the corresponding key can be
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#4253