Add additionalContext support to MLXLanguageModel#145
Add additionalContext support to MLXLanguageModel#145mattt merged 9 commits intohuggingface:mainfrom
additionalContext support to MLXLanguageModel#145Conversation
|
Hi @mattt , can you take a look at this. Thanks! |
df19229 to
d27310d
Compare
There was a problem hiding this comment.
Pull request overview
Adds support for passing an additionalContext dictionary through GenerationOptions into MLXLMCommon’s chat-template rendering context, enabling callers to inject custom variables for Jinja2-based templates.
Changes:
- Extends
MLXLanguageModel.CustomGenerationOptionswithadditionalContextand threads it intoMLXLMCommon.UserInputconstruction paths. - Adds a basic MLX test that exercises setting
additionalContextviaGenerationOptions.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
Sources/AnyLanguageModel/Models/MLXLanguageModel.swift |
Introduces additionalContext custom option and forwards it into MLX user input creation for standard, streaming, and structured generation flows. |
Tests/AnyLanguageModelTests/MLXLanguageModelTests.swift |
Adds a regression test ensuring additionalContext can be set and a response is produced. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@noorbhatia Alright, I think this is in really good shape now! Thanks for your help on this and your patience 🙇 |
|
Amazing, thanks @mattt !! |
Add
CustomGenerationOptionsstruct toMLXLanguageModelwith anadditionalContext: [String: JSONValue]?property for injecting variables into Jinja2 chat templatesUsage