easydel.inference.tools.parsers.phi4mini_tool_parser#
- class easydel.inference.tools.parsers.phi4mini_tool_parser.Phi4MiniJsonToolParser(tokenizer: PreTrainedTokenizerBase)[source]#
Bases:
ToolParserTool call parser for Phi-4-mini models.
Handles the functools format used by Phi-4-mini models. Extracts function calls from functools[…] wrapper with JSON array content. Currently supports non-streaming extraction only.
Features: - Regex-based extraction of functools wrapper - JSON array parsing of function calls - Support for both ‘arguments’ and ‘parameters’ fields - Automatic tool ID generation
Format: functools[{“name”: “func”, “arguments”: {…}}, …]
Used when –enable-auto-tool-choice –tool-call-parser phi4_mini_json are all set.
Note: Streaming extraction is not yet implemented (returns None).
- extract_tool_calls(model_output: str, request: ChatCompletionRequest) ExtractedToolCallInformation[source]#
Extract the tool calls from a complete model response.
- 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
- Raises
NotImplementedError – Must be implemented by subclasses
Note
This method is stateful - it uses instance variables to track parsing progress across streaming chunks.