Fixed TypeError: generate_step() got an unexpected keyword argument from 'formatter' in MLXPipeline
#374
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.
Bug Fix:
Problem Description
The
_call()function inside oflangchain_community/llms/mlx_pipeline.pywas creating a variable calledformatterfrom thepipeline_kwargsargument. This variable was then being passed as a kwarg tomlx_lm.generate.mlx_lm.generatedoes not take in aformatterargument and this was leading to failures in thegeneratecall downstream.Integration tests
I did not change any of these however I noticed these all failed due to the issue mentioned above (at least on my machine with all dependencies installed).
Unit Test
I have created a single unit test:
tests/unit_tests/llms/test_mlx_pipeline_no_formatter_kwarg.pywhich utilizes the demo code as listed hereFix
Simply removed the
formattervariable from being created in the_call()function of theMLXPipelineclassAlso removed the passing of the
formattervariable from thegenerate()call at the end of the_call()function.Misc Media
I found it interesting that the given integration tests for the module were also not passing so I thought I would include a reference photo / I know the main requirement is via unit testing.
Aside
This is my first contribution to an open source project. So any feedback about my methodology, formatting, and documentation is super welcome. Thank you :)