Scheduled removal of guided_* config fields (#29326)
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
This commit is contained in:
@@ -652,62 +652,6 @@ class ChatCompletionRequest(OpenAIBaseModel):
|
||||
default=None,
|
||||
description="Additional kwargs for structured outputs",
|
||||
)
|
||||
guided_json: str | dict | BaseModel | None = Field(
|
||||
default=None,
|
||||
description=(
|
||||
"`guided_json` is deprecated. "
|
||||
"This will be removed in v0.12.0 or v1.0.0, whichever is soonest. "
|
||||
"Please pass `json` to `structured_outputs` instead."
|
||||
),
|
||||
)
|
||||
guided_regex: str | None = Field(
|
||||
default=None,
|
||||
description=(
|
||||
"`guided_regex` is deprecated. "
|
||||
"This will be removed in v0.12.0 or v1.0.0, whichever is soonest. "
|
||||
"Please pass `regex` to `structured_outputs` instead."
|
||||
),
|
||||
)
|
||||
guided_choice: list[str] | None = Field(
|
||||
default=None,
|
||||
description=(
|
||||
"`guided_choice` is deprecated. "
|
||||
"This will be removed in v0.12.0 or v1.0.0, whichever is soonest. "
|
||||
"Please pass `choice` to `structured_outputs` instead."
|
||||
),
|
||||
)
|
||||
guided_grammar: str | None = Field(
|
||||
default=None,
|
||||
description=(
|
||||
"`guided_grammar` is deprecated. "
|
||||
"This will be removed in v0.12.0 or v1.0.0, whichever is soonest. "
|
||||
"Please pass `grammar` to `structured_outputs` instead."
|
||||
),
|
||||
)
|
||||
structural_tag: str | None = Field(
|
||||
default=None,
|
||||
description=(
|
||||
"`structural_tag` is deprecated. "
|
||||
"This will be removed in v0.12.0 or v1.0.0, whichever is soonest. "
|
||||
"Please pass `structural_tag` to `structured_outputs` instead."
|
||||
),
|
||||
)
|
||||
guided_decoding_backend: str | None = Field(
|
||||
default=None,
|
||||
description=(
|
||||
"`guided_decoding_backend` is deprecated. "
|
||||
"This will be removed in v0.12.0 or v1.0.0, whichever is soonest. "
|
||||
"Please remove it from your request."
|
||||
),
|
||||
)
|
||||
guided_whitespace_pattern: str | None = Field(
|
||||
default=None,
|
||||
description=(
|
||||
"`guided_whitespace_pattern` is deprecated. "
|
||||
"This will be removed in v0.12.0 or v1.0.0, whichever is soonest. "
|
||||
"Please pass `whitespace_pattern` to `structured_outputs` instead."
|
||||
),
|
||||
)
|
||||
priority: int = Field(
|
||||
default=0,
|
||||
description=(
|
||||
@@ -841,20 +785,6 @@ class ChatCompletionRequest(OpenAIBaseModel):
|
||||
if prompt_logprobs is None and self.echo:
|
||||
prompt_logprobs = self.top_logprobs
|
||||
|
||||
# Forward deprecated guided_* parameters to structured_outputs
|
||||
if self.structured_outputs is None:
|
||||
kwargs = dict[str, Any](
|
||||
json=self.guided_json,
|
||||
regex=self.guided_regex,
|
||||
choice=self.guided_choice,
|
||||
grammar=self.guided_grammar,
|
||||
whitespace_pattern=self.guided_whitespace_pattern,
|
||||
structural_tag=self.structural_tag,
|
||||
)
|
||||
kwargs = {k: v for k, v in kwargs.items() if v is not None}
|
||||
if len(kwargs) > 0:
|
||||
self.structured_outputs = StructuredOutputsParams(**kwargs)
|
||||
|
||||
response_format = self.response_format
|
||||
if response_format is not None:
|
||||
# If structured outputs wasn't already enabled,
|
||||
@@ -863,24 +793,23 @@ class ChatCompletionRequest(OpenAIBaseModel):
|
||||
self.structured_outputs = StructuredOutputsParams()
|
||||
|
||||
# Set structured output params for response format
|
||||
if response_format is not None:
|
||||
if response_format.type == "json_object":
|
||||
self.structured_outputs.json_object = True
|
||||
elif response_format.type == "json_schema":
|
||||
json_schema = response_format.json_schema
|
||||
assert json_schema is not None
|
||||
self.structured_outputs.json = json_schema.json_schema
|
||||
elif response_format.type == "structural_tag":
|
||||
structural_tag = response_format
|
||||
assert structural_tag is not None and isinstance(
|
||||
structural_tag,
|
||||
(
|
||||
LegacyStructuralTagResponseFormat,
|
||||
StructuralTagResponseFormat,
|
||||
),
|
||||
)
|
||||
s_tag_obj = structural_tag.model_dump(by_alias=True)
|
||||
self.structured_outputs.structural_tag = json.dumps(s_tag_obj)
|
||||
if response_format.type == "json_object":
|
||||
self.structured_outputs.json_object = True
|
||||
elif response_format.type == "json_schema":
|
||||
json_schema = response_format.json_schema
|
||||
assert json_schema is not None
|
||||
self.structured_outputs.json = json_schema.json_schema
|
||||
elif response_format.type == "structural_tag":
|
||||
structural_tag = response_format
|
||||
assert structural_tag is not None and isinstance(
|
||||
structural_tag,
|
||||
(
|
||||
LegacyStructuralTagResponseFormat,
|
||||
StructuralTagResponseFormat,
|
||||
),
|
||||
)
|
||||
s_tag_obj = structural_tag.model_dump(by_alias=True)
|
||||
self.structured_outputs.structural_tag = json.dumps(s_tag_obj)
|
||||
|
||||
extra_args: dict[str, Any] = self.vllm_xargs if self.vllm_xargs else {}
|
||||
if self.kv_transfer_params:
|
||||
@@ -1140,58 +1069,6 @@ class CompletionRequest(OpenAIBaseModel):
|
||||
default=None,
|
||||
description="Additional kwargs for structured outputs",
|
||||
)
|
||||
guided_json: str | dict | BaseModel | None = Field(
|
||||
default=None,
|
||||
description=(
|
||||
"`guided_json` is deprecated. "
|
||||
"This will be removed in v0.12.0 or v1.0.0, whichever is soonest. "
|
||||
"Please pass `json` to `structured_outputs` instead."
|
||||
),
|
||||
)
|
||||
guided_regex: str | None = Field(
|
||||
default=None,
|
||||
description=(
|
||||
"`guided_regex` is deprecated. "
|
||||
"This will be removed in v0.12.0 or v1.0.0, whichever is soonest. "
|
||||
"Please pass `regex` to `structured_outputs` instead."
|
||||
),
|
||||
)
|
||||
guided_choice: list[str] | None = Field(
|
||||
default=None,
|
||||
description=(
|
||||
"`guided_choice` is deprecated. "
|
||||
"This will be removed in v0.12.0 or v1.0.0, whichever is soonest. "
|
||||
"Please pass `choice` to `structured_outputs` instead."
|
||||
),
|
||||
)
|
||||
guided_grammar: str | None = Field(
|
||||
default=None,
|
||||
description=(
|
||||
"`guided_grammar` is deprecated. "
|
||||
"This will be removed in v0.12.0 or v1.0.0, whichever is soonest. "
|
||||
"Please pass `grammar` to `structured_outputs` instead."
|
||||
),
|
||||
)
|
||||
structural_tag: str | None = Field(
|
||||
default=None,
|
||||
description=("If specified, the output will follow the structural tag schema."),
|
||||
)
|
||||
guided_decoding_backend: str | None = Field(
|
||||
default=None,
|
||||
description=(
|
||||
"`guided_decoding_backend` is deprecated. "
|
||||
"This will be removed in v0.12.0 or v1.0.0, whichever is soonest. "
|
||||
"Please remove it from your request."
|
||||
),
|
||||
)
|
||||
guided_whitespace_pattern: str | None = Field(
|
||||
default=None,
|
||||
description=(
|
||||
"`guided_whitespace_pattern` is deprecated. "
|
||||
"This will be removed in v0.12.0 or v1.0.0, whichever is soonest. "
|
||||
"Please pass `whitespace_pattern` to `structured_outputs` instead."
|
||||
),
|
||||
)
|
||||
priority: int = Field(
|
||||
default=0,
|
||||
description=(
|
||||
@@ -1336,35 +1213,31 @@ class CompletionRequest(OpenAIBaseModel):
|
||||
|
||||
echo_without_generation = self.echo and self.max_tokens == 0
|
||||
|
||||
guided_json_object = None
|
||||
if self.response_format is not None:
|
||||
if self.response_format.type == "json_object":
|
||||
guided_json_object = True
|
||||
elif self.response_format.type == "json_schema":
|
||||
json_schema = self.response_format.json_schema
|
||||
response_format = self.response_format
|
||||
if response_format is not None:
|
||||
# If structured outputs wasn't already enabled,
|
||||
# we must enable it for these features to work
|
||||
if self.structured_outputs is None:
|
||||
self.structured_outputs = StructuredOutputsParams()
|
||||
|
||||
# Set structured output params for response format
|
||||
if response_format.type == "json_object":
|
||||
self.structured_outputs.json_object = True
|
||||
elif response_format.type == "json_schema":
|
||||
json_schema = response_format.json_schema
|
||||
assert json_schema is not None
|
||||
self.guided_json = json_schema.json_schema
|
||||
elif self.response_format.type == "structural_tag":
|
||||
structural_tag = self.response_format
|
||||
self.structured_outputs.json = json_schema.json_schema
|
||||
elif response_format.type == "structural_tag":
|
||||
structural_tag = response_format
|
||||
assert structural_tag is not None and isinstance(
|
||||
structural_tag, StructuralTagResponseFormat
|
||||
structural_tag,
|
||||
(
|
||||
LegacyStructuralTagResponseFormat,
|
||||
StructuralTagResponseFormat,
|
||||
),
|
||||
)
|
||||
s_tag_obj = structural_tag.model_dump(by_alias=True)
|
||||
self.structural_tag = json.dumps(s_tag_obj)
|
||||
|
||||
# Forward deprecated guided_* parameters to structured_outputs
|
||||
if self.structured_outputs is None:
|
||||
kwargs = dict[str, Any](
|
||||
json=self.guided_json,
|
||||
json_object=guided_json_object,
|
||||
regex=self.guided_regex,
|
||||
choice=self.guided_choice,
|
||||
grammar=self.guided_grammar,
|
||||
whitespace_pattern=self.guided_whitespace_pattern,
|
||||
)
|
||||
kwargs = {k: v for k, v in kwargs.items() if v is not None}
|
||||
if len(kwargs) > 0:
|
||||
self.structured_outputs = StructuredOutputsParams(**kwargs)
|
||||
self.structured_outputs.structural_tag = json.dumps(s_tag_obj)
|
||||
|
||||
extra_args: dict[str, Any] = self.vllm_xargs if self.vllm_xargs else {}
|
||||
if self.kv_transfer_params:
|
||||
|
||||
Reference in New Issue
Block a user