add: lfm2/2.5 tool parser#1246
Open
jbuchananr wants to merge 1 commit intoml-explore:mainfrom
Open
Conversation
|
I actually found that LFM 2.5 worked with the existing Pythonic function call format parser. it just wasn't being automatically mapped due to the parser inference only looking at the chat template. I extended the inference to also consider the vocab: #1260 Perhaps we should combine? |
Author
|
@blairhudson Yes! Let me run your PR through some of my internal tests this weekend |
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.
Issue
LFM2 / LFM2.5 models emit tool calls as
<|tool_call_start|>[fn(args)]<|tool_call_end|>, but no parser was registered for thisformat, so tool calls leaked into
message.contentinstead oftool_calls.The existing
pythonicparser also couldn't have handled real outputs: its regexrejects dotted names like
grocery.orderIngredientsand breaks on nested list/dictargs.
Changes
mlx_lm/tool_parsers/lfm2.py— parses the payload withastso dotted names,nested args, and multi-call lists all work.
_infer_tool_parserroutes chat templates containing"List of tools:"to the newparser (matches both LFM2 and LFM2.5).
Testing
mlx_lm.server: single call, multi-tool selection, nestedargs, declined call, streaming, multi-turn round-trip, parallel calls