Skip to content

Parse output and stream as Open Responses for all models in MLXChatExample app - #475

Closed
DePasqualeOrg wants to merge 8 commits into
ml-explore:mainfrom
DePasqualeOrg:lm-response-parser-demo
Closed

DePasqualeOrg wants to merge 8 commits into
ml-explore:mainfrom
DePasqualeOrg:lm-response-parser-demo

Conversation

@DePasqualeOrg

Copy link
Copy Markdown
Contributor

Building on the changes in PR #474, this PR demonstrates how Swift LM Response Parser enables output parsing and streaming as Open Responses for the full range of models implemented in MLX Swift LM.

There are currently model-implementation issues with some of the models available in the app (notably Gemma 3n and Gemma 4, for which there are open PRs), and some of the smaller, less-recent models aren't reliable for tool use or aren't capable of it at all. But the app can now serve as a testing ground for reasoning and tool use in a variety of models.

I've added two tools with no side effects for demonstration purposes: get_current_datetime and save_file (the latter of which is a no-op but showcases streaming tool calls).

The streamed Open Responses items make it possible to represent the interleaved reasoning and tool-use output emitted by many newer models in real time. The app now shows these content blocks in the correct sequence in the UI. Notably, this includes streaming tool-use content.

I'd like to test Swift LM Response Parser with a broader range of models. The library includes an integration with MLX Swift LM, which is used in the example app, so it should be easy to integrate into any project using MLX Swift LM. If you're able to try it out, please respond with your feedback here or in the repo so that I can continue to improve it.

trimmed.mov

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant