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

[Feature] Reasoning model API support #3043

Open
2 tasks done
lambert0312 opened this issue Jan 22, 2025 · 3 comments
Open
2 tasks done

[Feature] Reasoning model API support #3043

lambert0312 opened this issue Jan 22, 2025 · 3 comments
Assignees
Labels
help wanted Extra attention is needed

Comments

@lambert0312
Copy link

Checklist

Motivation

In order to better support reasoning models, such as DeepSeek-R1, etc., the API needs to support the reasoning_effort parameter. In addition, it is recommended to add reasoning_content to the output field mentioned in reasoning_model , used to display step information of reasoning thinking.
Similar to the dialogue completion interface parameters provided by openai. The parameter reasoning_effort support o1 model: "constrains effort on reasoning for reasoning models. Currently supported values are low, medium, and high. Reducing reasoning effort can result in faster responses and fewer tokens used on reasoning in a response."

Related resources

No response

@zhaochenyang20
Copy link
Collaborator

@lambert0312 I am pondering whether OpenAI has this parameter? SGLang aligns directly with OpenAI API.

@gaocegege
Copy link
Contributor

As far as I know, there isn't such a parameter for OpenAI's reasoning model because it doesn't show the CoT tokens.

Ref https://github.com/openai/openai-openapi/blob/master/openapi.yaml

However, this doesn't break API compatibility since it's a newly added parameter. The code below still works even though the response.choices[0].message's data class, ChatCompletionMessage, doesn't include such a parameter. Given that, I think it’s safe to add such a parameter, especially since more reasoning models will likely output CoT tokens soon.

from openai import OpenAI
client = OpenAI(api_key="", base_url="https://api.deepseek.com")

# Round 1
messages = [{"role": "user", "content": "9.11 and 9.8, which is greater?"}]
response = client.chat.completions.create(
    model="deepseek-reasoner",
    messages=messages
)

+ reasoning_content = response.choices[0].message.reasoning_content
content = response.choices[0].message.content
class ChatCompletionMessage(BaseModel):
    content: Optional[str] = None
    """The contents of the message."""

    refusal: Optional[str] = None
    """The refusal message generated by the model."""

    role: Literal["assistant"]
    """The role of the author of this message."""

    audio: Optional[ChatCompletionAudio] = None
    """
    If the audio output modality is requested, this object contains data about the
    audio response from the model.
    [Learn more](https://platform.openai.com/docs/guides/audio).
    """

    function_call: Optional[FunctionCall] = None
    """Deprecated and replaced by `tool_calls`.

    The name and arguments of a function that should be called, as generated by the
    model.
    """

    tool_calls: Optional[List[ChatCompletionMessageToolCall]] = None
    """The tool calls generated by the model, such as function calls."""

@zhaochenyang20 zhaochenyang20 self-assigned this Jan 23, 2025
@zhaochenyang20 zhaochenyang20 added the help wanted Extra attention is needed label Jan 23, 2025
@zhaochenyang20
Copy link
Collaborator

We will see if someone would love to work on this. Thansk!

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
Projects
None yet
Development

No branches or pull requests

3 participants