Support vllm style --tool-call-parser for hermes, qwen35, gemma4 - #162
Merged
Conversation
Gemma 4 protocol tags are all special=True, so they never appear in decoded text; boundaries are detected by token ID only (tool_call=48/49, channel=100/101). - gemma4.py: Gemma4ToolCallParser (incremental OpenAI argument fragments, ramble-detect stop, sequential parallel calls), Gemma4ChannelSplitter (thought-channel reasoning split), Gemma4ToolCallStreamer (StreamerBase, own decode, protocol-ID interception, raw_text reconstruction for non-streaming VLM where decode always strips specials), and a raw-text parse_generation for routes. - streamers.py: ensure_tool_call_parser falls back to the model's load-time registered parser when a request carries none; select_streamer activates the gemma4 engine streamer when tools are present OR thinking is enabled. - vlm.py: gemma4 non-streaming generates through the streamer and returns streamer.raw_text (VLM decode always strips special tags on this wheel). llm.py: raw decode via Tokenizer.decode(skip_special_tokens=False). - registration/CLI/routes: 'gemma4' parser option end to end. - Tests: gemma4 unit section (55 file total), integration (offline streamer contract + live GPU test); 163 unit / 6 integration green; 15/15 openai-library server checks on gemma-4-E4B-it (GPU.0).
…into tool-parse-1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR implements a proper token level parser for reasoning and tool invocation.
The core idea is, we stream raw ids into a buffer, check them for where the boundaries are, slice at those points, then tokenize, then join it all back together into openai compatible buckets. APIs in ovgenai used in this PR are source only, absent in all examples and not used in any code I have researched before. PR 162 may be a reference implementation for
IncrementalParserand a few other classes, at least on the python side.This approach is extremely durable- issues we have had in the past should be gone, and the format of per model tool parser and load time selection will be the standard going forward.
How to use
openarc addnow accepts--tool-call-parserjust like vllm! hermes style still scans text and should be used for models older than qwen3. Just add this arg to your qwen35/36/38 or gemma4 config entry and