[Frontend] Support reasoning content for deepseek r1 (#12473)
Signed-off-by: Ce Gao <cegao@tensorchord.ai> Co-authored-by: Rafael Vasquez <rafvasq21@gmail.com> Co-authored-by: Cyrus Leung <cyrus.tl.leung@gmail.com> Co-authored-by: Michael Goin <mgoin@redhat.com>
This commit is contained in:
co-authored by
Rafael Vasquez
Cyrus Leung
Michael Goin
parent
fbb5bd4cef
commit
a7e3eba66f
@@ -12,6 +12,7 @@ from typing import List, Optional, Sequence, Union, get_args
|
||||
from vllm.engine.arg_utils import AsyncEngineArgs, nullable_str
|
||||
from vllm.entrypoints.chat_utils import (ChatTemplateContentFormatOption,
|
||||
validate_chat_template)
|
||||
from vllm.entrypoints.openai.reasoning_parsers import ReasoningParserManager
|
||||
from vllm.entrypoints.openai.serving_models import (LoRAModulePath,
|
||||
PromptAdapterPath)
|
||||
from vllm.entrypoints.openai.tool_parsers import ToolParserManager
|
||||
@@ -208,6 +209,23 @@ def make_arg_parser(parser: FlexibleArgumentParser) -> FlexibleArgumentParser:
|
||||
default=False,
|
||||
help="Enable auto tool choice for supported models. Use "
|
||||
"``--tool-call-parser`` to specify which parser to use.")
|
||||
parser.add_argument(
|
||||
"--enable-reasoning",
|
||||
action="store_true",
|
||||
default=False,
|
||||
help="Whether to enable reasoning_content for the model. "
|
||||
"If enabled, the model will be able to generate reasoning content.")
|
||||
|
||||
valid_reasoning_parsers = ReasoningParserManager.reasoning_parsers.keys()
|
||||
parser.add_argument(
|
||||
"--reasoning-parser",
|
||||
type=str,
|
||||
metavar="{" + ",".join(valid_reasoning_parsers) + "}",
|
||||
default=None,
|
||||
help=
|
||||
"Select the reasoning parser depending on the model that you're using."
|
||||
" This is used to parse the reasoning content into OpenAI API "
|
||||
"format. Required for ``--enable-reasoning``.")
|
||||
|
||||
valid_tool_parsers = ToolParserManager.tool_parsers.keys()
|
||||
parser.add_argument(
|
||||
@@ -267,6 +285,18 @@ def validate_parsed_serve_args(args: argparse.Namespace):
|
||||
raise TypeError("Error: --enable-auto-tool-choice requires "
|
||||
"--tool-call-parser")
|
||||
|
||||
# Enable reasoning needs a reasoning parser to be valid
|
||||
if args.enable_reasoning and not args.reasoning_parser:
|
||||
raise TypeError("Error: --enable-reasoning requires "
|
||||
"--reasoning-parser")
|
||||
|
||||
# Ref https://api-docs.deepseek.com/guides/reasoning_model
|
||||
# tool call and reasoning cannot be enabled at the same time.
|
||||
if args.enable_auto_tool_choice and args.enable_reasoning:
|
||||
raise TypeError(
|
||||
"Error: --enable-auto-tool-choice and "
|
||||
"--enable-reasoning cannot be enabled at the same time")
|
||||
|
||||
|
||||
def create_parser_for_docs() -> FlexibleArgumentParser:
|
||||
parser_for_docs = FlexibleArgumentParser(
|
||||
|
||||
Reference in New Issue
Block a user