easydel.inference.tools.parsers.minimax_tool_parser#

class easydel.inference.tools.parsers.minimax_tool_parser.MinimaxToolParser(tokenizer: AutoTokenizer)[source]#

Bases: ToolParser

Tool parser for Minimax models.

Comprehensive parser handling tool calls with thinking tags support. Filters tool calls from thinking sections and manages complex streaming state with pending buffers.

Features: - Thinking tag filtering (<think>…</think>) - Stateful streaming with buffer management - Tool boundary detection and validation - Duplicate brace cleaning for arguments - Multi-tool support with index tracking

Format: <tool_calls> {“name”: “func”, “arguments”: {…}} </tool_calls>

The parser maintains extensive state for proper streaming including buffer management, tool indices, and sent status tracking.

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

Extract tool calls from model output for non-streaming mode.

Parameters
  • model_output – Complete model output

  • request – Chat completion request

Returns

ExtractedToolCallInformation containing tool calls and content

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.

preprocess_model_output(model_output: str) str[source]#

Preprocess model output by removing tool calls from thinking tags.

Parameters

model_output – Raw model output string

Returns

Preprocessed model output with tool calls removed from thinking tags