Add KimiK2Detector with tool interruption support (#19696)
Signed-off-by: Xinyuan Tong <xinyuantong.cs@gmail.com>
This commit is contained in:
@@ -268,6 +268,34 @@ class KimiDetector(BaseReasoningFormatDetector):
|
||||
)
|
||||
|
||||
|
||||
class KimiK2Detector(BaseReasoningFormatDetector):
|
||||
"""
|
||||
Detector for Kimi K2 models.
|
||||
Assumes reasoning format:
|
||||
(<think>)*(.*)</think>
|
||||
|
||||
Kimi K2 can switch from reasoning to tool-call section with
|
||||
`<|tool_calls_section_begin|>` before emitting `</think>`.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
stream_reasoning: bool = True,
|
||||
force_reasoning: bool = False,
|
||||
continue_final_message: bool = False,
|
||||
previous_content: str = "",
|
||||
):
|
||||
super().__init__(
|
||||
"<think>",
|
||||
"</think>",
|
||||
force_reasoning=force_reasoning,
|
||||
stream_reasoning=stream_reasoning,
|
||||
tool_start_token="<|tool_calls_section_begin|>",
|
||||
continue_final_message=continue_final_message,
|
||||
previous_content=previous_content,
|
||||
)
|
||||
|
||||
|
||||
class Glm45Detector(BaseReasoningFormatDetector):
|
||||
"""
|
||||
Detector for GLM-4.5 models.
|
||||
@@ -431,7 +459,7 @@ class ReasoningParser:
|
||||
"glm45": Glm45Detector,
|
||||
"gpt-oss": GptOssDetector,
|
||||
"kimi": KimiDetector,
|
||||
"kimi_k2": Qwen3Detector,
|
||||
"kimi_k2": KimiK2Detector,
|
||||
"qwen3": Qwen3Detector,
|
||||
"qwen3-thinking": Qwen3Detector,
|
||||
"minimax": Qwen3Detector,
|
||||
|
||||
Reference in New Issue
Block a user