fix(reasoning): guard rfind in ernie45 streaming </response> branch (#46255)

Signed-off-by: Chenglun Hu <chenglunhu@gmail.com>
Co-authored-by: Flora Feng <4florafeng@gmail.com>
This commit is contained in:
hcl
2026-07-01 01:01:14 +00:00
committed by GitHub
co-authored by Flora Feng
parent b1190d03cc
commit 9294dd27eb
+2 -1
View File
@@ -114,7 +114,8 @@ class Ernie45ReasoningParser(BaseThinkingReasoningParser):
content = content[:response_end_idx]
elif self.response_end_token_id in delta_token_ids:
response_end_idx = content.rfind(self.response_end_token)
content = content[:response_end_idx]
if response_end_idx != -1:
content = content[:response_end_idx]
# remove \n after </think> or </response>
if previous_token_ids[-1] in self.parser_token_ids and (
len(delta_token_ids) > 0 and delta_token_ids[0] == self.newline_token_id