mirror of
https://github.com/HKUDS/nanobot.git
synced 2026-05-01 23:35:52 +00:00
fix: strip <thought> blocks from Gemma 4 and similar models
This commit is contained in:
parent
69d748bf8f
commit
6b7e78a8e0
@ -15,9 +15,12 @@ from loguru import logger
|
|||||||
|
|
||||||
|
|
||||||
def strip_think(text: str) -> str:
|
def strip_think(text: str) -> str:
|
||||||
"""Remove <think>…</think> blocks and any unclosed trailing <think> tag."""
|
"""Remove thinking blocks and any unclosed trailing tag."""
|
||||||
text = re.sub(r"<think>[\s\S]*?</think>", "", text)
|
text = re.sub(r"<think>[\s\S]*?</think>", "", text)
|
||||||
text = re.sub(r"<think>[\s\S]*$", "", text)
|
text = re.sub(r"<think>[\s\S]*$", "", text)
|
||||||
|
# Gemma 4 and similar models use <thought>...</thought> blocks
|
||||||
|
text = re.sub(r"<thought>[\s\S]*?</thought>", "", text)
|
||||||
|
text = re.sub(r"<thought>[\s\S]*$", "", text)
|
||||||
return text.strip()
|
return text.strip()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user