Bug: The step setting of the top_k parameter of Spark series models in the web frontend is incorrect. #5438

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

Originally created by @AAEE86 on GitHub (Sep 6, 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.8.0

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

The bug I reported is that the step setting in the front end is incorrect. It should be set to step="1".
<input class="shrink-0 block ml-4 pl-3 w-16 h-8 appearance-none outline-none rounded-lg bg-gray-100 text-[13px] text-gra-900" max="6" min="1" step="0.1" type="number" data-tabindex="" tabindex="-1">

✔️ Expected Behavior

No response

Actual Behavior

No response

Originally created by @AAEE86 on GitHub (Sep 6, 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.8.0 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce The bug I reported is that the step setting in the front end is incorrect. It should be set to step="1". `<input class="shrink-0 block ml-4 pl-3 w-16 h-8 appearance-none outline-none rounded-lg bg-gray-100 text-[13px] text-gra-900" max="6" min="1" step="0.1" type="number" data-tabindex="" tabindex="-1">` ### ✔️ Expected Behavior _No response_ ### ❌ Actual Behavior _No response_
yindo added the 🐞 bug label 2026-02-21 18:10:58 -05:00
yindo closed this issue 2026-02-21 18:10:58 -05:00
Author
Owner

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

To fix the incorrect step setting of the top_k parameter in the web frontend of Spark series models in Dify version 0.8.0, you need to ensure that the TopKItem component correctly handles the step setting and passes the appropriate values to the handleParamChange function.

Here is the relevant code snippet from the TopKItem component:

const VALUE_LIMIT = {
  default: 2,
  step: 1,
  min: 1,
  max: 10,
}

const key = 'top_k'
const TopKItem: FC<Props> = ({
  className,
  value,
  enable,
  onChange,
}) => {
  const { t } = useTranslation()
  const handleParamChange = (key: string, value: number) => {
    let notOutRangeValue = parseFloat(value.toFixed(2))
    notOutRangeValue = Math.max(VALUE_LIMIT.min, notOutRangeValue)
    notOutRangeValue = Math.min(VALUE_LIMIT.max, notOutRangeValue)
    onChange(key, notOutRangeValue)
  }
  return (
    <ParamItem
      className={className}
      id={key}
      name={t(`appDebug.datasetConfig.${key}`)}
      tip={t(`appDebug.datasetConfig.${key}Tip`) as string}
      {...VALUE_LIMIT}
      value={value}
      enable={enable}
      onChange={handleParamChange}
    />
  )
}

Ensure that the TopKItem component is correctly passing the key and value parameters to the handleParamChange function. The VALUE_LIMIT object defines the step, minimum, and maximum values for the top_k parameter. If the step setting is incorrect, you might need to adjust the step value within the VALUE_LIMIT object [1].

Additionally, ensure that the TopK parameter is correctly configured in the retrieval settings of your application. The TopK parameter filters the text segments that are most similar to the user's question, and the system dynamically adjusts the number of segments based on the context window size of the selected model. The default value is 3, meaning a higher value results in more text segments being recalled. Adjust this parameter based on your specific needs for precision versus recall [2].

To continue talking to Dosu, mention @dosu.

@dosubot[bot] commented on GitHub (Sep 6, 2024): <!-- Answer --> To fix the incorrect step setting of the `top_k` parameter in the web frontend of Spark series models in Dify version 0.8.0, you need to ensure that the `TopKItem` component correctly handles the step setting and passes the appropriate values to the `handleParamChange` function. Here is the relevant code snippet from the `TopKItem` component: ```tsx const VALUE_LIMIT = { default: 2, step: 1, min: 1, max: 10, } const key = 'top_k' const TopKItem: FC<Props> = ({ className, value, enable, onChange, }) => { const { t } = useTranslation() const handleParamChange = (key: string, value: number) => { let notOutRangeValue = parseFloat(value.toFixed(2)) notOutRangeValue = Math.max(VALUE_LIMIT.min, notOutRangeValue) notOutRangeValue = Math.min(VALUE_LIMIT.max, notOutRangeValue) onChange(key, notOutRangeValue) } return ( <ParamItem className={className} id={key} name={t(`appDebug.datasetConfig.${key}`)} tip={t(`appDebug.datasetConfig.${key}Tip`) as string} {...VALUE_LIMIT} value={value} enable={enable} onChange={handleParamChange} /> ) } ``` Ensure that the `TopKItem` component is correctly passing the `key` and `value` parameters to the `handleParamChange` function. The `VALUE_LIMIT` object defines the step, minimum, and maximum values for the `top_k` parameter. If the step setting is incorrect, you might need to adjust the `step` value within the `VALUE_LIMIT` object <sup>[[1]](https://github.com/langgenius/dify/blob/main/web/app/components/base/param-item/top-k-item.tsx)</sup>. Additionally, ensure that the `TopK` parameter is correctly configured in the retrieval settings of your application. The `TopK` parameter filters the text segments that are most similar to the user's question, and the system dynamically adjusts the number of segments based on the context window size of the selected model. The default value is 3, meaning a higher value results in more text segments being recalled. Adjust this parameter based on your specific needs for precision versus recall <sup>[[2]](https://github.com/langgenius/dify-docs/blob/main/en/guides/knowledge-base/integrate-knowledge-within-application.md)</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#5438