core.tokenizers.text.parsers.qwen3_coder_tool_parser#
Module Contents#
Classes#
Parser for Qwen3 Coder style tool calls. |
Data#
API#
- core.tokenizers.text.parsers.qwen3_coder_tool_parser.logger#
‘getLogger(…)’
- core.tokenizers.text.parsers.qwen3_coder_tool_parser.ToolCall#
None
- core.tokenizers.text.parsers.qwen3_coder_tool_parser.FunctionCall#
None
- core.tokenizers.text.parsers.qwen3_coder_tool_parser.ChatCompletionToolsParam#
None
- core.tokenizers.text.parsers.qwen3_coder_tool_parser.ChatCompletionRequest#
None
- core.tokenizers.text.parsers.qwen3_coder_tool_parser.ExtractedToolCallInformation#
None
- class core.tokenizers.text.parsers.qwen3_coder_tool_parser._Qwen3CoderToolParser#
- tool_call_start_token: str#
‘<tool_call>’
- tool_call_end_token: str#
‘</tool_call>’
- tool_call_prefix: str#
‘<function=’
- tool_call_complete_regex#
‘compile(…)’
- tool_call_regex#
‘compile(…)’
- tool_call_function_regex#
‘compile(…)’
- tool_call_parameter_regex#
‘compile(…)’
- _generate_tool_call_id() str#
Generate a unique tool call ID.
- _get_arguments_config(
- func_name: str,
- tools: list[core.tokenizers.text.parsers.qwen3_coder_tool_parser.ChatCompletionToolsParam] | None,
Extract argument configuration for a function.
- _convert_param_value(
- param_value: str,
- param_name: str,
- param_config: dict,
- func_name: str,
Convert parameter value based on its type in the schema.
- _parse_xml_function_call(
- function_call_str: str,
- tools: list[core.tokenizers.text.parsers.qwen3_coder_tool_parser.ChatCompletionToolsParam] | None,
- _get_function_calls(model_output: str) list[str]#
- extract_tool_calls(
- model_output: str,
- tools: list[core.tokenizers.text.parsers.qwen3_coder_tool_parser.ChatCompletionToolsParam] | None,
Extracts the tool calls from the text using <tool_call>…</tool_call> tags.
- class core.tokenizers.text.parsers.qwen3_coder_tool_parser.Qwen3CoderToolParser#
Bases:
megatron.core.tokenizers.text.parsers.base_parser.BaseParserParser for Qwen3 Coder style tool calls.
- static parse(text: str, **kwargs) tuple[str, dict[str, list[dict]]]#
Extracts the tool calls from the text using <tool_call>…</tool_call> tags. Uses the _Qwen3CoderToolParser class (copied from vLLM) to extract the tool calls.
- Parameters:
text (str) – The text to parse.
- Returns:
A tuple containing the unprocessed text and a dictionary with the extracted tool calls.
- Return type:
tuple[str, dict[str, str]]