Unverified Commit 8a6e108e authored by tlipoca9's avatar tlipoca9 Committed by GitHub
Browse files

fix: kimi_k2 return empty tool call list (#22149)


Signed-off-by: default avatartlipoca9 <tlipoca9@gmail.com>
parent d7b28f34
...@@ -38,15 +38,15 @@ class KimiK2ToolParser(ToolParser): ...@@ -38,15 +38,15 @@ class KimiK2ToolParser(ToolParser):
self.tool_call_end_token: str = "<|tool_call_end|>" self.tool_call_end_token: str = "<|tool_call_end|>"
self.tool_call_regex = re.compile( self.tool_call_regex = re.compile(
r"<\|tool_call_begin\|>\s*(?P<tool_call_id>[\w\.]+:\d+)\s*<\|tool_call_argument_begin\|>\s*(?P<function_arguments>.*?)\s*<\|tool_call_end\|>" r"<\|tool_call_begin\|>\s*(?P<tool_call_id>.+:\d+)\s*<\|tool_call_argument_begin\|>\s*(?P<function_arguments>.*?)\s*<\|tool_call_end\|>"
) )
self.stream_tool_call_portion_regex = re.compile( self.stream_tool_call_portion_regex = re.compile(
r"(?P<tool_call_id>[\w\.]+:\d+)\s*<\|tool_call_argument_begin\|>\s*(?P<function_arguments>.*)" r"(?P<tool_call_id>.+:\d+)\s*<\|tool_call_argument_begin\|>\s*(?P<function_arguments>.*)"
) )
self.stream_tool_call_name_regex = re.compile( self.stream_tool_call_name_regex = re.compile(
r"(?P<tool_call_id>[\w\.]+:\d+)\s*") r"(?P<tool_call_id>.+:\d+)\s*")
if not self.model_tokenizer: if not self.model_tokenizer:
raise ValueError( raise ValueError(
...@@ -374,4 +374,4 @@ class KimiK2ToolParser(ToolParser): ...@@ -374,4 +374,4 @@ class KimiK2ToolParser(ToolParser):
except Exception: except Exception:
logger.exception("Error trying to handle streaming tool call.") logger.exception("Error trying to handle streaming tool call.")
return None # do not stream a delta. skip this token ID. return None # do not stream a delta. skip this token ID.
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment