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.66k stars 6.42k forks source link

The problem classifier will output all the strings in the directly replied nodes of the connection #8282

Closed MIM1993 closed 5 days ago

MIM1993 commented 5 days ago

Self Checks

Dify version

0.8.0

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

image

✔️ Expected Behavior

Only output the string corresponding to the direct reply

❌ Actual Behavior

All the strings in the direct replies have been printed out

dosubot[bot] commented 5 days ago

@MIM1993 Hello there! I'm here to assist you with bugs, questions, or becoming a contributor. I'm Dosu, a bot designed to help you while waiting for a human maintainer.

The problem classifier in Dify version 0.8.0 is outputting all the strings in the directly replied nodes instead of only the string corresponding to the direct reply because the QUESTION_CLASSIFIER_COMPLETION_PROMPT includes an example section that contains multiple user-assistant interactions. This example section is likely being interpreted as part of the response, causing the classifier to output all the strings from the example interactions.

Here is the relevant part of the QUESTION_CLASSIFIER_COMPLETION_PROMPT:

### Example
Here is the chat example between human and assistant, inside <example></example> XML tags.
<example>
User:{{"input_text": ["I recently had a great experience with your company. The service was prompt and the staff was very friendly."], "categories": [{{"category_id":"f5660049-284f-41a7-b301-fd24176a711c","category_name":"Customer Service"}},{{"category_id":"8d007d06-f2c9-4be5-8ff6-cd4381c13c60","category_name":"Satisfaction"}},{{"category_id":"5fbbbb18-9843-466d-9b8e-b9bfbb9482c8","category_name":"Sales"}},{{"category_id":"23623c75-7184-4a2e-8226-466c2e4631e4","category_name":"Product"}}], "classification_instructions": ["classify the text based on the feedback provided by customer"]}}
Assistant:{{"keywords": ["recently", "great experience", "company", "service", "prompt", "staff", "friendly"],"category_id": "f5660049-284f-41a7-b301-fd24176a711c","category_name": "Customer Service"}}
User:{{"input_text": ["bad service, slow to bring the food"], "categories": [{{"category_id":"80fb86a0-4454-4bf5-924c-f253fdd83c02","category_name":"Food Quality"}},{{"category_id":"f6ff5bc3-aca0-4e4a-8627-e760d0aca78f","category_name":"Experience"}},{{"category_id":"cc771f63-74e7-4c61-882e-3eda9d8ba5d7","category_name":"Price"}}], "classification_instructions": []}}
Assistant:{{"keywords": ["bad service", "slow", "food", "tip", "terrible", "waitresses"],"category_id": "f6ff5bc3-aca0-4e4a-8627-e760d0aca78f","category_name": "Experience"}}
</example>

To fix this issue, you should ensure that the example section is not included in the response or modify the prompt to clearly separate the example section from the actual response [1].

To continue talking to Dosu, mention @dosu.

crazywoola commented 5 days ago

Fixed in https://github.com/langgenius/dify/pull/8225