"vscode:/vscode.git/clone" did not exist on "0d81e543a2b048d7b1f558fb1006d10a062a6e9e"
Unverified Commit 0ef583b7 authored by GavinZhu-GMI's avatar GavinZhu-GMI Committed by GitHub
Browse files

fix: allow user to specify function as role (#9635)

parent f7881a27
......@@ -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")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment