[Feature][Frontend] Add granite_thinking_parser reasoning parser for Granite 4.2 (#55957)

Signed-off-by: Yousaf shah <yousaf.shah@gmail.com>
Co-authored-by: sfeng33 <4florafeng@gmail.com>
This commit is contained in:
Yousaf
2026-09-25 20:43:08 +00:00
committed by GitHub
co-authored by sfeng33
parent e440b75bb6
commit 83db8c8390
9 changed files with 834 additions and 2 deletions
+12 -1
View File
@@ -327,7 +327,18 @@ _TOOL_CALL_SAMPLES = [
def _tool_suppression_expectations(
sample, think_end: str, tool_start: str, *, include_tool_block: bool
) -> tuple[str, str]:
"""Expected (reasoning, content) when tool calls are not extracted.
reasoning, content = _raw_tool_suppression_expectations(
sample, think_end, tool_start, include_tool_block=include_tool_block
)
if sample.content_lstrip:
content = content.lstrip(sample.content_lstrip)
return reasoning, content
def _raw_tool_suppression_expectations(
sample, think_end: str, tool_start: str, *, include_tool_block: bool
) -> tuple[str, str]:
"""Expected (reasoning, content) from the raw token text.
With ``include_tool_block=True`` (skip_tool_parsing / reasoning
adapter first pass), tool terminal text is preserved as content so