Skip to content

Commit 8a40374

Browse files
authored
[BugFix] Fix ernie4_5_vl_processor.py and qwen_vl_processor.py can not disable thinking (#4762)
* fix ernie4_5_vl_processor.py and qwen_vl_processor.py * add unit test
1 parent 007ee71 commit 8a40374

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

fastdeploy/input/ernie4_5_vl_processor/ernie4_5_vl_processor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ def process_request_dict(self, request, max_model_len=None):
233233
if chat_template_kwargs:
234234
if isinstance(chat_template_kwargs, dict):
235235
for k, v in chat_template_kwargs.items():
236-
if k not in request:
236+
if k not in request or request[k] is None:
237237
request[k] = v
238238
else:
239239
raise ValueError("Invalid input: chat_template_kwargs must be a dict")

fastdeploy/input/qwen_vl_processor/qwen_vl_processor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ def process_request_dict(self, request, max_model_len=None):
237237
if chat_template_kwargs:
238238
if isinstance(chat_template_kwargs, dict):
239239
for k, v in chat_template_kwargs.items():
240-
if k not in request:
240+
if k not in request or request[k] is None:
241241
request[k] = v
242242
else:
243243
raise ValueError("Invalid input: chat_template_kwargs must be a dict")

tests/input/test_qwen_vl_processor.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,26 @@ def test_process_request_dict(self):
204204
result["multimodal_inputs"]["image_type_ids"].shape[0], result["multimodal_inputs"]["grid_thw"][:, 0].sum()
205205
)
206206

207+
def test_process_request_dict_enable_thinking(self):
208+
num_completion_token_ids = 10
209+
request = {
210+
"request_id": "12345",
211+
"completion_token_ids": [1] * num_completion_token_ids,
212+
"stop": ["stop", "eof"],
213+
"messages": [
214+
{
215+
"role": "user",
216+
"content": [
217+
{"type": "text", "text": "Hello"},
218+
],
219+
}
220+
],
221+
"chat_template_kwargs": {"enable_thinking": True},
222+
}
223+
224+
result = self.processor.process_request_dict(request, 100)
225+
self.assertEqual(result.get("enable_thinking"), False)
226+
207227
def test_prompt(self):
208228
"""
209229
Test processing of prompt with image and video placeholders

0 commit comments

Comments
 (0)