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

[bedrock] Error: ValidationException: A conversation must start with a user message. Try again with a conversation that starts with a user message. #12340

Open
5 tasks done
luckylhb90 opened this issue Jan 3, 2025 · 3 comments
Assignees
Labels
🐞 bug Something isn't working 🤔 cant-reproduce We can not reproduce it or the information is limited

Comments

@luckylhb90
Copy link
Contributor

luckylhb90 commented Jan 3, 2025

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.10.2

Cloud or Self Hosted

Self Hosted (Source)

Steps to reproduce

  1. When we use sonnet3.5 with memory enabled, this error is always reported when we call it.

[bedrock] Error: ValidationException: A conversation must start with a user message. Try again with a conversation that starts with a user message.

image
  1. I analyzed the code and guessed that it might have something to do with checking tokens here. For the other models, I didn't think there was a problem, but for sonnet, if we removed a prompt, it would cause this error.
image
  1. I try to modify the configuration of the model, but again I get input token overrun issues.
    context_size: 20000000

Is there any relevant experience you can provide for our reference?

✔️ Expected Behavior

Even if the memory function is enabled, users will not be affected.

❌ Actual Behavior

Always get the following error:

image image
Copy link

dosubot bot commented Jan 3, 2025

I found a similar unsolved discussion that might be relevant to your issue: Error using large language model [1].

Regarding your issue, it seems that the error "A conversation must start with a user message" is related to how the conversation is initiated in the Dify platform. To start a conversation with a user message, you need to ensure that the initial message in the conversation is from the user. This can be done using the create_chat_message method from the ChatClient class, where you specify the query as the user's message and leave the conversation_id empty to start a new conversation [2].

Additionally, the token_buffer_memory.py script is responsible for managing the conversation history while respecting token limits. It retrieves and formats past messages, ensuring that the total number of tokens does not exceed a specified limit. If the token count exceeds the limit, it prunes messages from the start of the list [3].

For the 'Claude 3.5 Sonnet' model, the default max_tokens is set to 8192. If you're encountering input token overrun issues, you might need to adjust this parameter to prevent exceeding the token limit [4].

Ensure that your initial user message is correctly formatted and that the token limits are configured appropriately to avoid these errors.

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 🐞 bug Something isn't working 🤔 cant-reproduce We can not reproduce it or the information is limited labels Jan 3, 2025
@crazywoola
Copy link
Member

Can you try it in the latest version?

@crazywoola crazywoola self-assigned this Jan 3, 2025
@luckylhb90
Copy link
Contributor Author

Can you try it in the latest version?

We're upgrading, too. Let me test it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working 🤔 cant-reproduce We can not reproduce it or the information is limited
Projects
None yet
Development

No branches or pull requests

2 participants