diff --git a/python/sglang/srt/entrypoints/openai/protocol.py b/python/sglang/srt/entrypoints/openai/protocol.py index d36a7f80c..7c1b07318 100644 --- a/python/sglang/srt/entrypoints/openai/protocol.py +++ b/python/sglang/srt/entrypoints/openai/protocol.py @@ -327,7 +327,7 @@ class ToolCall(BaseModel): class ChatCompletionMessageGenericParam(BaseModel): - role: Literal["system", "assistant", "tool"] + role: Literal["system", "assistant", "tool", "function"] content: Union[str, List[ChatCompletionMessageContentTextPart], None] = Field( default=None ) @@ -341,9 +341,9 @@ class ChatCompletionMessageGenericParam(BaseModel): def _normalize_role(cls, v): if isinstance(v, str): v_lower = v.lower() - if v_lower not in {"system", "assistant", "tool"}: + if v_lower not in {"system", "assistant", "tool", "function"}: raise ValueError( - "'role' must be one of 'system', 'assistant', or 'tool' (case-insensitive)." + "'role' must be one of 'system', 'assistant', 'tool', or 'function' (case-insensitive)." ) return v_lower raise ValueError("'role' must be a string")