easydel.inference.tools.parsers.qwen3coder_tool_parser#

class easydel.inference.tools.parsers.qwen3coder_tool_parser.Qwen3CoderToolParser(tokenizer: AutoTokenizer)[source]#

Bases: ToolParser

Tool parser for Qwen3 Coder models.

Handles XML-style tool calls with function names and parameter tags. Supports complex parameter value conversion based on type definitions.

Features: - XML tag-based parsing (<tool_call>, <function=…>, <parameter=…>) - Automatic type conversion (string, int, float, bool, object) - Streaming with JSON fragment generation - Parameter value escaping for JSON compatibility - State tracking for multi-parameter functions

Format: <tool_call> <function=name> <parameter=param1>value1</parameter> <parameter=param2>value2</parameter> </function> </tool_call>

Maintains extensive streaming state including current parameter tracking, JSON assembly, and completion detection.

extract_tool_calls(model_output: str, request: ChatCompletionRequest) ExtractedToolCallInformation[source]#

Extract tool calls from complete model output (batch mode).

Parses the entire model response to identify and extract tool/function calls. This method is used for non-streaming responses where the complete output is available.

Parameters
  • model_output – Complete text generated by the model

  • request – Original request containing tool definitions

Returns

Parsed tool calls and remaining content

Return type

ExtractedToolCallInformation

Raises

NotImplementedError – Must be implemented by subclasses

Note

This method is stateless - it doesn’t use instance state. Each parser implements model-specific extraction logic.

extract_tool_calls_streaming(previous_text: str, current_text: str, delta_text: str, previous_token_ids: Sequence[int], current_token_ids: Sequence[int], delta_token_ids: Sequence[int], request: ChatCompletionRequest) easydel.inference.openai_api_modules.DeltaMessage | None[source]#

Extract tool calls from streaming model output.

Processes incremental model output to identify partial tool calls and emit appropriate streaming updates. Maintains state across calls to handle incomplete JSON/XML structures.

Parameters
  • previous_text – Text accumulated up to previous call

  • current_text – Text accumulated including current chunk

  • delta_text – New text in current chunk

  • previous_token_ids – Token IDs up to previous call

  • current_token_ids – Token IDs including current chunk

  • delta_token_ids – New token IDs in current chunk

  • request – Original request with tool definitions

Returns

Incremental tool call update, or None if no update

Return type

DeltaMessage

Raises

NotImplementedError – Must be implemented by subclasses

Note

This method is stateful - it uses instance variables to track parsing progress across streaming chunks.