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

【classifier issue】 Run failed: [wenxin] Bad Request Error, The number of messages should be odd. #11776

Closed
5 tasks done
luciferYu opened this issue Dec 18, 2024 · 3 comments
Labels
🐞 bug Something isn't working

Comments

@luciferYu
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.14.0

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

I want to use a classifier to classify problems
but classifier always return “Run failed: [wenxin] Bad Request Error, The number of messages should be odd.“

following is my input
{
"sys.query": "1+1=几?",
"sys.files": [],
"sys.conversation_id": "fdc4b4d2-ea19-4f4b-a29a-eb821277cb81",
"sys.user_id": "6f3c4ffb-1b06-4aa2-860d-68f3fef96acb",
"sys.dialogue_count": 0,
"sys.app_id": "1d22e606-28d2-46ec-880f-36a465f80588",
"sys.workflow_id": "904fc580-b948-4035-9403-fa7bbe39df3a",
"sys.workflow_run_id": "1a80fe03-ece7-44b5-b6bf-c3ebee26d8af"
}

following is the screenshot

image
image
issue01
issue02
image

✔️ Expected Behavior

I have set up two categories for Chinese language problems and math problems. When I input 1+1=what? I hope it can be classified as a mathematical problem

❌ Actual Behavior

It always raise an exception that Run failed: [wenxin] Bad Request Error, The number of messages should be odd.“
image

@luciferYu luciferYu changed the title 【classifier issue】 【classifier issue】 Run failed: [wenxin] Bad Request Error, The number of messages should be odd. Dec 18, 2024
Copy link

dosubot bot commented Dec 18, 2024

Hey @luciferYu! 👋 I'm here to help you with any bugs, questions, or contributions you have for Dify. Let's tackle this issue together!

To resolve the "Run failed: [wenxin] Bad Request Error, The number of messages should be odd" issue, ensure that the number of messages you are sending is odd. This requirement is enforced in the _build_chat_request_body method, which raises a BadRequestError if the number of messages is even. You should adjust your message list to have an odd count, starting with a user message. Here is the relevant code snippet:

if len(messages) % 2 == 0:
    raise BadRequestError("The number of messages should be odd.")
if messages[0].role != "user":
    raise BadRequestError("The first message should be user message.")

Make sure your message list adheres to these conditions to avoid the error [1].

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other

@dosubot dosubot bot added the 🐞 bug Something isn't working label Dec 18, 2024
@luciferYu
Copy link
Author

Hello dosu
I noticed that this message cannot be odd, but I don't quite understand what message is?
I output the sys. query variable as input to the classifier at the start node. I see a selection model in the classifier node, set the classification. Afterwards, the variable class_name will be output to next node. But I don't know where the classifier node can control the parity of messages. Could you please tell me?

Best Regards

@luciferYu
Copy link
Author

I have tried to use gpt4-turbo model it worked, But baidu ERNIE model that didn't worked
image

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
Development

No branches or pull requests

1 participant