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

Support model APIs that require strict alternating user-assistant roles #5965

Open
ekzhu opened this issue Mar 16, 2025 · 0 comments
Open

Support model APIs that require strict alternating user-assistant roles #5965

ekzhu opened this issue Mar 16, 2025 · 0 comments
Labels
help wanted Extra attention is needed proj-agentchat
Milestone

Comments

@ekzhu
Copy link
Collaborator

ekzhu commented Mar 16, 2025

          For the 400 server error about alternating user-assistant roles in messages, we need to handle this outside of model client, i.e., in `AssistantAgent` and `SelectorGroupChat`, where the model clients are used. Based on the model family in `model_info` field, we should inject an empty user message when there are consecutive assistant messages.

Originally posted by @ekzhu in #5961 (comment)

Reference of 400 error:

openai.BadRequestError: Error code: 400 - {'error': {'message': 'deepseek-reasoner does not support successive user or assistant messages (messages[1] and messages[2] in your input). You should interleave the user/assistant messages in the message sequence.', 'type': 'invalid_request_error', 'param': None, 'code': 'invalid_request_error'}}

Steps:

  1. Investigate what are the model families that require this strict alternating user-assistant roles? (DeepSeek R1, Mistral AI)
  2. In AssistantAgent and SelectorGroupChat, where model client is used, ensure the messages are following the strict order when the above model families are involved. We can do this by concatenation of messages with repeated roles, or injecting empty message -- need to test them.
@ekzhu ekzhu added the help wanted Extra attention is needed label Mar 16, 2025
@ekzhu ekzhu changed the title Injecting empty user/assistant message when the model API requires strict alternating user-assistant roles Support model APIs that requires strict alternating user-assistant roles Mar 16, 2025
@ekzhu ekzhu changed the title Support model APIs that requires strict alternating user-assistant roles Support model APIs that require strict alternating user-assistant roles Mar 16, 2025
@ekzhu ekzhu added this to the 0.4.x-python milestone Mar 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed proj-agentchat
Projects
None yet
Development

No branches or pull requests

1 participant