fix multiple issues

This commit is contained in:
2026-06-26 17:23:55 +08:00
parent 810874ddb8
commit f89bc60d59
2 changed files with 92 additions and 11 deletions

View File

@@ -320,12 +320,20 @@ class ChatCompletionRequest(OpenAIBaseModel):
prompt_logprobs = self.top_logprobs
guided_json_object = None
if (self.response_format is not None
and self.response_format.type == "json_object"):
guided_json_object = True
guided_json_from_schema = 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"
and self.response_format.json_schema is not None
and self.response_format.json_schema.json_schema is not None):
guided_json_from_schema = \
self.response_format.json_schema.json_schema
guided_decoding = GuidedDecodingParams.from_optional(
json=self._get_guided_json_from_tool() or self.guided_json,
json=(self._get_guided_json_from_tool()
or self.guided_json
or guided_json_from_schema),
regex=self.guided_regex,
choice=self.guided_choice,
grammar=self.guided_grammar,
@@ -398,6 +406,10 @@ class ChatCompletionRequest(OpenAIBaseModel):
normalized.append(msg)
continue
if msg.get("content") is None:
if msg.get("reasoning_content") is None:
raise ValueError(
"Each message must have at least one of 'content' or "
"'reasoning_content'.")
msg = {**msg, "content": ""}
normalized.append(msg)
data = {**data, "messages": normalized}
@@ -639,12 +651,18 @@ class CompletionRequest(OpenAIBaseModel):
echo_without_generation = self.echo and self.max_tokens == 0
guided_json_object = None
if (self.response_format is not None
and self.response_format.type == "json_object"):
guided_json_object = True
guided_json_from_schema = 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"
and self.response_format.json_schema is not None
and self.response_format.json_schema.json_schema is not None):
guided_json_from_schema = \
self.response_format.json_schema.json_schema
guided_decoding = GuidedDecodingParams.from_optional(
json=self.guided_json,
json=self.guided_json or guided_json_from_schema,
regex=self.guided_regex,
choice=self.guided_choice,
grammar=self.guided_grammar,