[Feature] integrate Structural Tag in xgrammar backend for function calling (#3566)

Co-authored-by: shuaills <shishuaiuoe@gmail.com>
This commit is contained in:
mlmz
2025-02-28 15:33:41 +08:00
committed by GitHub
parent eec3f6d1eb
commit bac414ab53
5 changed files with 44 additions and 1 deletions

View File

@@ -994,10 +994,17 @@ def v1_chat_generate_request(
"ignore_eos": request.ignore_eos,
"skip_special_tokens": request.skip_special_tokens,
}
if request.response_format and request.response_format.type == "json_schema":
sampling_params["json_schema"] = convert_json_schema_to_str(
request.response_format.json_schema.schema_
)
elif (
request.response_format and request.response_format.type == "structural_tag"
):
sampling_params["structural_tag"] = convert_json_schema_to_str(
request.response_format.model_dump(by_alias=True)
)
sampling_params_list.append(sampling_params)
image_data_list.append(image_data)