Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Chatflow] All classes with "Answer" block are triggered in "Knowledge Classifier" #8222

Closed
5 tasks done
AnotiaWang opened this issue Sep 10, 2024 · 3 comments · Fixed by #8225
Closed
5 tasks done
Labels
🐞 bug Something isn't working

Comments

@AnotiaWang
Copy link

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

  1. Create a Chatflow chatbot
  2. Create the following chatflow:
截屏2024-09-10 19 40 40 3. Preview the chatbot, and ask anything, e.g. "2".

✔️ Expected Behavior

The bot should answer "Response from 2".

❌ Actual Behavior

The bot answered "Response from 1Response from 2Response from 3".

截屏2024-09-10 19 43 41

I'm not sure whether all classes are triggered in the classifier, or just the ones that have Answers, since other classes are not shown in the log.

Copy link

dosubot bot commented Sep 10, 2024

All classes with the "Answer" block are being triggered in the "Knowledge Classifier" in your Chatflow chatbot, resulting in concatenated responses because the "Answer" block is defined to handle response content in a Chatflow process. This means that whenever the "Knowledge Classifier" node classifies a user input, it triggers the "Answer" block to generate a response, leading to multiple "Answer" blocks being activated and their responses concatenated.

To address this, you can configure the issue classifier to direct the flow to different paths based on the classification results. By setting up specific classification labels/descriptions and corresponding downstream nodes, you can ensure that only the relevant "Answer" block is triggered for each classified input. This can be done by:

  1. Selecting Input Variable: Define the content to be classified, usually the user's question.
  2. Choosing Inference Model: Select an appropriate model to enhance classification effectiveness.
  3. Writing Classification Labels/Descriptions: Add multiple classifications with keywords or descriptive statements for each category.
  4. Choosing Corresponding Downstream Nodes: Direct the flow to different paths based on the classification results.

By configuring these steps, you can prevent multiple "Answer" blocks from being triggered simultaneously, thereby avoiding concatenated responses.

Additionally, the QuestionClassifierNode in Dify's platform uses a structured approach to classify questions and direct the flow accordingly. It extracts variables, fetches model configurations, and processes the input through a series of prompt messages. The node then determines the appropriate category based on the classification results and directs the flow to the corresponding downstream node. This ensures that only the relevant "Answer" block is triggered, preventing concatenated responses.

The QUESTION_CLASSIFIER_SYSTEM_PROMPT in Dify's platform specifies that the classifier should assign only one category to the input text and extract keywords related to the classification. This constraint helps in ensuring that only the most relevant "Answer" block is triggered, thus avoiding the issue of concatenated responses [1][2][3][4][5].

To continue talking to Dosu, mention @dosu.

@AnotiaWang
Copy link
Author

Maybe #8221 fixes this issue

@crazywoola
Copy link
Member

image Seems fixed in latest branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working
Projects
None yet
2 participants