[Bugfix] Return HTTP 400 instead of 501 for unknown chat roles in DeepSeek encoders (#53071)

Signed-off-by: JC-ut0 <809602657@qq.com>
This commit is contained in:
JC-ut0
2026-08-20 09:23:41 +00:00
committed by GitHub
parent c8de519917
commit 38e9cefdef
4 changed files with 29 additions and 2 deletions
+11
View File
@@ -113,6 +113,17 @@ def test_deepseek_v4_explicitly_disables_thinking(kwargs):
assert prompt == ("<|begin▁of▁sentence|><|User|>Hello<|Assistant|></think>")
def test_deepseek_v4_unknown_role_raises_value_error():
# Invalid roles are client errors: they must surface as ValueError
# (mapped to HTTP 400 by the OpenAI serving layer), not
# NotImplementedError (mapped to HTTP 501).
with pytest.raises(ValueError, match="Invalid role: SYSTEM"):
_tokenizer().apply_chat_template(
[{"role": "SYSTEM", "content": "Hello"}],
tokenize=False,
)
def test_deepseek_v4_uses_v4_tool_prompt_from_request_tools():
tools = [
{