You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(mtmd): expand vision chat template media support
- Recognize Muse Glimmer's <|patch|> marker in the generic MTMD handler.
- Update Qwen3VL rendering to inject image and video URLs for MTMD processing.
- Enable Qwen3.5 video inputs and handle string or {"url": ...} values.
- Add regression tests for the supported media input formats.
Signed-off-by: JamePeng <jame_peng@sina.com>
@@ -2079,6 +2079,7 @@ class GenericMTMDChatHandler(MTMDChatHandler):
2079
2079
"<|image|>",
2080
2080
"<|audio|>",
2081
2081
"<|video|>",
2082
+
"<|patch|>", # Muse Glimmer used
2082
2083
2083
2084
# LLaVA / LFM / Mistral-style placeholders.
2084
2085
"<image>",
@@ -4031,84 +4032,157 @@ class Qwen3VLChatHandler(MTMDChatHandler):
4031
4032
QWEN3_VL_EOS_TOKEN="<|im_end|>"
4032
4033
4033
4034
CHAT_FORMAT= (
4034
-
"{{- '<|im_start|>system\n' -}}"
4035
-
"{%- if messages[0].content is string and messages[0].role == 'system' -%}"
4036
-
"{{- messages[0].content -}}"
4037
-
"{%- elif messages[0].role == 'system' -%}"
4038
-
"{%- if 'text' in messages[0].content -%}"
4039
-
"{{- messages[0].content.text -}}"
4040
-
"{%- else -%}"
4041
-
"{{- 'You are a helpful assistant.' -}}"
4042
-
"{%- endif -%}"
4043
-
"{%- endif -%}"
4044
-
"{%- if tools -%}"
4045
-
"{{- '\n\n' -}}"
4046
-
"{{- '# Tools\n\nYou may call one or more functions to assist with the user query.\n\nYou are provided with function signatures within <tools></tools> XML tags:\n<tools>' -}}"
4047
-
"{%- for tool in tools -%}"
4048
-
"{{- '\n' -}}"
4049
-
"{{- tool | tojson -}}"
4050
-
"{%- endfor -%}"
4051
-
"{{- '\n</tools>\n\nFor each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:\n<tool_call>\n{\"name\": <function-name>, \"arguments\": <arguments-json-object>}\n</tool_call>\n\nYou can also return a response for the user alongside a function call:\nRESPONSE FOR THE USER HERE\n<tool_call>\n{\"name\": <function-name>, \"arguments\": <arguments-json-object>}\n</tool_call>' -}}"
4052
-
"{%- endif -%}"
4053
-
"{{- '<|im_end|>\n' -}}"
4054
4035
"{%- set image_count = namespace(value=0) -%}"
4055
-
#"{%- set video_count = namespace(value=0) -%}"
4056
-
"{%- for message in messages -%}"
4057
-
"{%- if message.role == 'tool' -%}"
4058
-
"{{- '<|im_start|>user\n<tool_response>\n' -}}"
4059
-
"{%- elif message.role != 'system' -%}"
4060
-
"{{- '<|im_start|>' + message.role + '\n' -}}"
4061
-
"{%- endif -%}"
4062
-
"{%- if message.content is string and message.role != 'system' -%}"
4063
-
"{{- message.content -}}"
4064
-
"{%- elif message.role != 'system' -%}"
4065
-
"{%- for content in message.content -%}"
4066
-
"{%- if 'image_url' in content -%}"
4067
-
"{%- set image_count.value = image_count.value + 1 -%}"
"{{- '# Tools\n\nYou may call one or more functions to assist with the user query.\n\nYou are provided with function signatures within <tools></tools> XML tags:\n<tools>' -}}"
4107
+
"{%- for tool in tools -%}"
4108
+
"{{- '\n' -}}"
4109
+
"{{- tool | tojson -}}"
4110
+
"{%- endfor -%}"
4111
+
"{{- '\n</tools>\n\nFor each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:\n<tool_call>\n{\"name\": <function-name>, \"arguments\": <args-json-object>}\n</tool_call><|im_end|>\n' -}}"
0 commit comments