[Fix] Resolve VLM test image placeholders from the model's own chat template (#33509)

This commit is contained in:
Liangsheng Yin
2026-08-04 02:01:39 -07:00
committed by GitHub
parent 26a542722f
commit b6d548afd7
7 changed files with 110 additions and 48 deletions
+16
View File
@@ -183,6 +183,22 @@ def download_image_with_retry(image_url: str, max_retries: int = 3) -> Image.Ima
time.sleep(2**i)
def build_vlm_image_prompt(processor, question: str) -> str:
# Take the image placeholder from the model's own HF chat template: a
# hand-written one silently degrades to a text-only prompt on any model
# whose placeholder differs.
return processor.apply_chat_template(
[
{
"role": "user",
"content": [{"type": "image"}, {"type": "text", "text": question}],
}
],
tokenize=False,
add_generation_prompt=True,
)
def is_in_ci():
"""Return whether it is in CI runner."""
return get_bool_env_var("SGLANG_IS_IN_CI")