Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions tests/tool_use/test_kimi_k2_tool_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ def assert_tool_calls(
assert actual_tool_call.type == "function"
assert actual_tool_call.function == expected_tool_call.function

# assert tool call id format
assert actual_tool_call.id.startswith("functions.")
# assert tool call id format: should contain function name and numeric index
# Format can be either "functions.func_name:0" or "func_name:0"
assert actual_tool_call.id.split(":")[-1].isdigit()
assert (
actual_tool_call.id.split(".")[1].split(":")[0]
actual_tool_call.id.split(":")[0].split(".")[-1]
== expected_tool_call.function.name
)

Expand Down
8 changes: 4 additions & 4 deletions vllm/entrypoints/openai/tool_parsers/kimi_k2_tool_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ def extract_tool_calls(
tool_calls = []
for match in function_call_tuples:
function_id, function_args = match
# function_id: functions.get_weather:0
function_name = function_id.split(".")[1].split(":")[0]
# function_id: functions.get_weather:0 or get_weather:0
function_name = function_id.split(":")[0].split(".")[-1]
tool_calls.append(
ToolCall(
id=function_id,
Expand Down Expand Up @@ -254,7 +254,7 @@ def extract_tool_calls_streaming(
)
if current_tool_call_matches:
tool_id, tool_args = current_tool_call_matches.groups()
tool_name = tool_id.split(".")[1].split(":")[0]
tool_name = tool_id.split(":")[0].split(".")[-1]
current_tool_call["id"] = tool_id
current_tool_call["name"] = tool_name
current_tool_call["arguments"] = tool_args
Expand All @@ -264,7 +264,7 @@ def extract_tool_calls_streaming(
)
if current_tool_call_name_matches:
(tool_id_str,) = current_tool_call_name_matches.groups()
tool_name = tool_id_str.split(".")[1].split(":")[0]
tool_name = tool_id_str.split(":")[0].split(".")[-1]
current_tool_call["id"] = tool_id_str
current_tool_call["name"] = tool_name
current_tool_call["arguments"] = ""
Expand Down