langgenius / dify

Dify is an open-source LLM app development platform. Dify's intuitive interface combines AI workflow, RAG pipeline, agent capabilities, model management, observability features and more, letting you quickly go from prototype to production.
https://dify.ai
Other
45.58k stars 6.41k forks source link

Knowledge Retrieval component. Switching the "score" switch does not save the "score" value. #7919

Open MrXionGe opened 1 week ago

MrXionGe commented 1 week ago

Self Checks

Dify version

0.7.3

Cloud or Self Hosted

Cloud

Steps to reproduce

  1. Select an app (chatbot with workflow)
  2. Enter the workflow editing page
  3. Select the Knowledge Retrieval component
  4. Recall Settings
  5. Change the "score" value
  6. Turn off the "score" switch / turn on the "score" switch

✔️ Expected Behavior

Turn off the "score" switch, and the "score" value will turn gray. Turn on the "score" switch and the value will be restored. Because in the knowledge base settings, retrieval settings, the "score" value is like this.

❌ Actual Behavior

Turn off the "score" switch, and the "score" value will be cleared. Turn on the "score" switch, and the value will return to the default value "0.8".

https://github.com/user-attachments/assets/968d426d-1830-420a-8f8d-6c37029dd8d1

dosubot[bot] commented 1 week ago

Switching the "score" switch in the Knowledge Retrieval component does not save the "score" value in Dify version 7.0.3 because the handleSwitch function is designed to only handle the score_threshold_enabled key. It explicitly ignores the top_k key and does not handle any other keys.

Here's the relevant code snippet:

const handleSwitch = (key: string, enable: boolean) => {
    if (key === 'top_k')
        return

    onChange({
        ...datasetConfigs,
        score_threshold_enabled: enable,
    })
}

To save the "score" value, you would need to modify the handleSwitch function to handle the appropriate key and update the dataset configuration accordingly [1].

To continue talking to Dosu, mention @dosu.

MrXionGe commented 1 week ago

In the knowledge base settings, retrieval settings. Switching the "score" switch is more in line with usage habits. I think.

https://github.com/user-attachments/assets/16ccb9a6-76a8-458f-b42d-224771125dd9