[DSV4] Support max reasoning effort (#40982)

Signed-off-by: Bugen Zhao <i@bugenzhao.com>
This commit is contained in:
Bugen Zhao
2026-04-29 11:03:47 +00:00
committed by GitHub
parent 37e288214b
commit 33f36d4260
6 changed files with 126 additions and 6 deletions
@@ -182,7 +182,19 @@ class ChatCompletionRequest(OpenAIBaseModel):
| ChatCompletionNamedToolChoiceParam
| None
) = "none"
reasoning_effort: Literal["none", "low", "medium", "high"] | None = None
reasoning_effort: (
Literal["none", "minimal", "low", "medium", "high", "xhigh", "max"] | None
) = Field(
default=None,
description=(
"Constrains effort on reasoning for reasoning models. "
"Currently supported values are none, minimal, low, medium, "
"high, xhigh, and max. Reducing reasoning effort can result in "
"faster responses and fewer tokens used on reasoning in a response. "
"Note that 'max' is specific to the DeepSeek V4 series and is not "
"part of the standard OpenAI API specification."
),
)
thinking_token_budget: int | None = None
include_reasoning: bool = True
parallel_tool_calls: bool | None = True
@@ -3,7 +3,6 @@
import datetime
from collections.abc import Iterable, Sequence
from typing import Literal
from openai.types.responses.tool import Tool
from openai_harmony import (
@@ -66,7 +65,7 @@ def get_encoding():
def get_system_message(
model_identity: str | None = None,
reasoning_effort: Literal["high", "medium", "low"] | None = None,
reasoning_effort: str | None = None,
start_date: str | None = None,
browser_description: str | None = None,
python_description: str | None = None,
@@ -84,6 +83,12 @@ def get_system_message(
)
sys_msg_content = sys_msg_content.with_model_identity(new_identity)
if reasoning_effort is not None:
if reasoning_effort not in REASONING_EFFORT:
supported_values = ", ".join(REASONING_EFFORT)
raise ValueError(
f"reasoning_effort={reasoning_effort!r} is not supported by "
f"Harmony. Supported values are: {supported_values}."
)
sys_msg_content = sys_msg_content.with_reasoning_effort(
REASONING_EFFORT[reasoning_effort]
)