fix: normalize Gemma 4 thought-channel output (#2224)

This commit is contained in:
RaresKeY
2026-06-04 20:26:58 +03:00
committed by GitHub
parent 7ce6ec7f50
commit c12c2aa233
7 changed files with 249 additions and 41 deletions
+19
View File
@@ -23,3 +23,22 @@ def test_strip_think_cases():
# 6. Multiple blocks (closed + unclosed)
assert strip_think("Hello! <think> closed </think> Here is the answer. <think> unclosed") == "Hello! Here is the answer."
def test_strip_think_handles_thought_tags():
assert strip_think("<thought>internal reasoning</thought>Final answer.") == "Final answer."
def test_strip_think_handles_gemma4_thought_channel():
text = "<|channel>thought\ninternal reasoning<channel|>Final answer."
assert strip_think(text) == "Final answer."
def test_strip_think_handles_empty_gemma4_thought_channel():
text = "<|channel>thought\n<channel|>Final answer."
assert strip_think(text) == "Final answer."
def test_strip_think_unwraps_gemma4_response_channel():
text = "<|channel>thought\ninternal reasoning<channel|><|channel>response\nFinal answer.<channel|>"
assert strip_think(text) == "Final answer."