easydel.inference.tools.parsers.granite_20b_fc_tool_parser#
- class easydel.inference.tools.parsers.granite_20b_fc_tool_parser.Granite20bFCToolParser(tokenizer: AutoTokenizer)[source]#
Bases:
ToolParserTool call parser for Granite 20B function calling model.
Designed for the granite-20b-functioncalling model and intended for use with the examples/tool_chat_template_granite20b_fc.jinja template.
Features: - Handles <function_call> token markers - Supports multiple function calls in sequence - Uses partial JSON parsing for streaming - Tracks completion state for proper argument streaming
Format: <function_call>{“name”: “func”, “arguments”: {…}}<function_call>{…}
Used when –enable-auto-tool-choice –tool-call-parser granite-20b-fc are all set.
- 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
- 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
- Raises
NotImplementedError – Must be implemented by subclasses
Note
This method is stateful - it uses instance variables to track parsing progress across streaming chunks.