[ROCm][CI] Stabilize 400 error return code for invalid schema inputs (#43016)
Signed-off-by: Andreas Karatzas <akaratza@amd.com>
This commit is contained in:
@@ -1818,12 +1818,28 @@ def _postprocess_messages(messages: list[ConversationMessage]) -> None:
|
||||
continue
|
||||
|
||||
for item in tool_calls:
|
||||
if not isinstance(item, dict):
|
||||
raise VLLMValidationError(
|
||||
"assistant tool_calls entries must be objects.",
|
||||
parameter="tool_calls",
|
||||
)
|
||||
|
||||
function = item.get("function")
|
||||
if item.get("type", "function") != "function" or not isinstance(
|
||||
function, dict
|
||||
):
|
||||
raise VLLMValidationError(
|
||||
"chat completions only support assistant tool_calls "
|
||||
"of type 'function'.",
|
||||
parameter="tool_calls",
|
||||
)
|
||||
|
||||
# if arguments is None or empty string, set to {}
|
||||
if content := item["function"].get("arguments"):
|
||||
if content := function.get("arguments"):
|
||||
if not isinstance(content, (dict, list)):
|
||||
item["function"]["arguments"] = json.loads(content)
|
||||
function["arguments"] = json.loads(content)
|
||||
else:
|
||||
item["function"]["arguments"] = {}
|
||||
function["arguments"] = {}
|
||||
|
||||
|
||||
def parse_chat_messages(
|
||||
|
||||
Reference in New Issue
Block a user