Signed-off-by: Yida Weng <84164537+YidaWeng@users.noreply.github.com> Signed-off-by: Flora Feng <4florafeng@gmail.com> Co-authored-by: Flora Feng <4florafeng@gmail.com>
This commit is contained in:
@@ -4,6 +4,7 @@ from typing import Annotated, Any, Literal, TypeAlias
|
||||
|
||||
from pydantic import (
|
||||
BaseModel,
|
||||
ConfigDict,
|
||||
Discriminator,
|
||||
Field,
|
||||
NonNegativeInt,
|
||||
@@ -147,6 +148,16 @@ class MultiModalFeatures(BaseModel):
|
||||
return self
|
||||
|
||||
|
||||
class ReasoningParserKwargs(BaseModel):
|
||||
"""Kwargs for the engine-side reasoning parser that gates structured
|
||||
outputs. Typed so clients cannot pass arbitrary constructor kwargs."""
|
||||
|
||||
model_config = ConfigDict(extra="forbid")
|
||||
|
||||
chat_template_kwargs: dict[str, Any] = Field(default_factory=dict)
|
||||
"""The effective chat template kwargs the prompt was rendered with."""
|
||||
|
||||
|
||||
class GenerateRequest(BaseModel):
|
||||
request_id: str = Field(
|
||||
default_factory=lambda: f"{random_uuid()}",
|
||||
@@ -212,6 +223,15 @@ class GenerateRequest(BaseModel):
|
||||
|
||||
model: str | None = None
|
||||
|
||||
reasoning_ended: bool | None = None
|
||||
"""Whether reasoning has ended before the first generated token, as
|
||||
resolved by /render. `True` applies structured outputs from the first
|
||||
token; `None` lets the engine check the prompt with its reasoning parser."""
|
||||
|
||||
reasoning_parser_kwargs: ReasoningParserKwargs | None = None
|
||||
"""Set by /render when it has a reasoning parser, so the engine-side
|
||||
parser agrees with the frontend on flags such as `enable_thinking`."""
|
||||
|
||||
return_token_ids: bool | None = Field(
|
||||
default=None,
|
||||
description=(
|
||||
|
||||
@@ -349,6 +349,12 @@ class ServingTokens(GenerateBaseServing):
|
||||
priority=request.priority,
|
||||
data_parallel_rank=data_parallel_rank,
|
||||
session_id=session_id,
|
||||
reasoning_ended=request.reasoning_ended,
|
||||
reasoning_parser_kwargs=(
|
||||
request.reasoning_parser_kwargs.model_dump()
|
||||
if request.reasoning_parser_kwargs is not None
|
||||
else None
|
||||
),
|
||||
)
|
||||
|
||||
assert result_generator is not None
|
||||
|
||||
Reference in New Issue
Block a user