Skip to content

Commit 7c964a2

Browse files
committed
Update anti_truncation.py
1 parent c511484 commit 7c964a2

1 file changed

Lines changed: 4 additions & 23 deletions

File tree

src/anti_truncation.py

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -315,31 +315,12 @@ async def _handle_non_streaming_response(self, response) -> bytes:
315315
}).encode()
316316

317317
def _check_done_marker_in_text(self, text: str) -> bool:
318-
"""检查文本中是否包含done标记(严格检测)"""
318+
"""检测文本中是否包含DONE_MARKER(只检测指定标记)"""
319319
if not text:
320320
return False
321-
322-
# 支持的done标记变体
323-
done_variants = [
324-
"[done]",
325-
"[DONE]",
326-
"[Done]",
327-
"【done】",
328-
"【DONE】",
329-
"[完成]",
330-
"[结束]"
331-
]
332-
333-
# 分行检查,每行去掉空白后检查
334-
lines = text.strip().split('\n')
335-
for line in lines:
336-
line_clean = line.strip()
337-
# 检查整行是否就是done标记的任何变体
338-
for variant in done_variants:
339-
if line_clean == variant or line_clean.endswith(variant):
340-
return True
341-
342-
return False
321+
322+
# 只要文本中出现DONE_MARKER即可
323+
return DONE_MARKER in text
343324

344325
def _check_done_marker_in_chunk_content(self, content: str) -> bool:
345326
"""检查单个chunk内容中是否包含done标记"""

0 commit comments

Comments
 (0)