Open
Description
Checklist
- 1. If the issue you raised is not a feature but a question, please raise a discussion at https://github.com/sgl-project/sglang/discussions/new/choose Otherwise, it will be closed.
- 2. Please use English, otherwise it will be closed.
Motivation
According to the https://platform.openai.com/docs/api-reference/chat/create OpenAI Platform, when there is tool_calls
, the content
could be optional. But the current implementation could cause 400 Bad Request when content
filed is missed under tool_calls
situation.
class ChatCompletionMessageGenericParam(BaseModel):
role: Literal["system", "assistant", "tool"]
content: Union[str, List[ChatCompletionMessageContentTextPart], None]
tool_call_id: Optional[str] = None
name: Optional[str] = None
reasoning_content: Optional[str] = None
tool_calls: Optional[List[ToolCall]] = Field(default=None, examples=[None])
@field_validator("role", mode="before")
@classmethod
def _normalize_role(cls, v):
if isinstance(v, str):
v_lower = v.lower()
if v_lower not in {"system", "assistant", "tool"}:
raise ValueError(
"'role' must be one of 'system', 'assistant', or 'tool' (case-insensitive)."
)
return v_lower
raise ValueError("'role' must be a string")

Related resources
No response
Metadata
Metadata
Assignees
Labels
No labels