[Bugfix] Avoid leaking Pydantic repr in tool_choice error message (#47028)
Signed-off-by: muhammadfawaz1 <135441198+muhammadfawaz1@users.noreply.github.com> Co-authored-by: Mahad Durrani <114791389+mahadrehmann@users.noreply.github.com>
This commit is contained in:
co-authored by
Mahad Durrani
parent
c0e8e1f12a
commit
d35eba302f
@@ -12,6 +12,7 @@ from vllm.entrypoints.chat_utils import (
|
||||
ConversationMessage,
|
||||
)
|
||||
from vllm.entrypoints.openai.chat_completion.protocol import (
|
||||
ChatCompletionNamedToolChoiceParam,
|
||||
ChatCompletionRequest,
|
||||
)
|
||||
from vllm.entrypoints.openai.completion.protocol import (
|
||||
@@ -134,8 +135,12 @@ class OnlineRenderer:
|
||||
)
|
||||
elif request.tool_choice != "auto":
|
||||
# "required" or named tool requires tool parser
|
||||
if isinstance(request.tool_choice, ChatCompletionNamedToolChoiceParam):
|
||||
tool_choice_desc = f'function "{request.tool_choice.function.name}"'
|
||||
else:
|
||||
tool_choice_desc = f'"{request.tool_choice}"'
|
||||
return self.create_error_response(
|
||||
f'tool_choice="{request.tool_choice}" requires '
|
||||
f"tool_choice={tool_choice_desc} requires "
|
||||
"--tool-call-parser to be set"
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user