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

Using multiple roles with the R1 model. #8

Closed
Vein05 opened this issue Jan 26, 2025 · 1 comment
Closed

Using multiple roles with the R1 model. #8

Vein05 opened this issue Jan 26, 2025 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@Vein05
Copy link
Collaborator

Vein05 commented Jan 26, 2025

Currently the api returns a 400 error when trying to use multiple roles and contents with the r1 model.

Image Image
	request := &deepseek.ChatCompletionRequest{
		Model: deepseek.DeepSeekReasoner,
		Messages: []deepseek.ChatCompletionMessage{
			{Role: constants.ChatMessageRoleUser, Content: "How are you?"},
			{Role: constants.ChatMessageRoleSystem, Content: "Talk like an anime girl."},
		},
		Temperature: 1.0,
		ResponseFormat: &deepseek.ResponseFormat{
			Type: "text",
		},
	}

Find out the reason why, and update the docs as needed!

@Vein05 Vein05 added the bug Something isn't working label Jan 26, 2025
@Vein05 Vein05 self-assigned this Jan 26, 2025
@Vein05
Copy link
Collaborator Author

Vein05 commented Jan 27, 2025

There are some constraints about using the new R-1 model.

Constraints:
First Message: The first message (excluding system messages) must be a user message. The API does not accept an assistant message as the first message.

Last Message: The last message must be a user message or an assistant message with prefix mode enabled.

Correct Usage Examples:

  1. Using System and User Messages:
    If you want to include a system message, it should be the first message, followed by a user message.
request := &deepseek.ChatCompletionRequest{
    Model: deepseek.DeepSeekReasoner,
    Messages: []deepseek.ChatCompletionMessage{
        {Role: constants.ChatMessageRoleSystem, Content: "You are a helpful assistant."},
        {Role: constants.ChatMessageRoleUser, Content: "How are you?"},
    },
}
  1. Using User Messages Only:
    If you only need to use user messages, ensure that the last message is from the user.
request := &deepseek.ChatCompletionRequest{
    Model: deepseek.DeepSeekReasoner,
    Messages: []deepseek.ChatCompletionMessage{
        {Role: constants.ChatMessageRoleUser, Content: "How are you?"},
    },
}

Incorrect Usage Examples:

  1. Assistant Message as First Message:
    This will result in an error because the first message must be a user message.
request := &deepseek.ChatCompletionRequest{
    Model: deepseek.DeepSeekReasoner,
    Messages: []deepseek.ChatCompletionMessage{
        {Role: constants.ChatMessageRoleAssistant, Content: "You are a helpful assistant."},
        {Role: constants.ChatMessageRoleUser, Content: "How are you?"},
    },
}
  1. System Message as Last Message:
    This will result in an error because the last message must be a user message or an assistant message with prefix mode.
request := &deepseek.ChatCompletionRequest{
    Model: deepseek.DeepSeekReasoner,
    Messages: []deepseek.ChatCompletionMessage{
        {Role: constants.ChatMessageRoleUser, Content: "How are you?"},
        {Role: constants.ChatMessageRoleSystem, Content: "Talk like an anime girl."},
    },
}

Errors

{
  "error": {
    "message": "The first message (except the system message) of deepseek-reasoner must be a user message, but an assistant message detected.",
    "type": "invalid_request_error",
    "param": null,
    "code": "invalid_request_error"
  }
}
{
  "error": {
    "message": "The last message of deepseek-reasoner must be a user message, or an assistant message with prefix mode on (refer to https://api-docs.deepseek.com/guides/chat_prefix_completion).",
    "type": "invalid_request_error",
    "param": null,
    "code": "invalid_request_error"
  }
}

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