fix(frontend): return 400 for missing completions json_schema (#28090)

Signed-off-by: Ting Sun <suntcrick@gmail.com>
This commit is contained in:
Ting SUN
2026-06-22 15:47:05 -07:00
committed by GitHub
parent 6c212a5d6b
commit e00703bb2a
2 changed files with 18 additions and 3 deletions
@@ -164,9 +164,13 @@ class OpenAIServingCompletion(OpenAIServingBase):
# Handle response_format constraints
if request.response_format and request.response_format.type == "json_schema":
sampling_params["json_schema"] = convert_json_schema_to_str(
request.response_format.json_schema.schema_
)
json_schema = request.response_format.json_schema
schema = getattr(json_schema, "schema_", None)
if schema is None:
raise ValueError(
"schema_ is required for json_schema response format request."
)
sampling_params["json_schema"] = convert_json_schema_to_str(schema)
elif request.response_format and request.response_format.type == "json_object":
sampling_params["json_schema"] = '{"type": "object"}'
elif (