Add --chat-template-file to mount custom chat template (fixes #1783)#2476
Add --chat-template-file to mount custom chat template (fixes #1783)#2476rhatdan wants to merge 1 commit into
Conversation
Reviewer's GuideAdds support for a new --chat-template-file CLI option that mounts a user-provided chat template file into the container and wires it through to the llama.cpp engine, preferring the user’s file over the model’s default template when provided. File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the inference engine's flexibility by allowing users to supply custom chat templates directly from their local filesystem. This change enables the use of fixed or personalized templates without requiring a model re-download, streamlining the process of experimenting with different conversational formats and improving user control over the model's output structure. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- In
setup_mounts, the--mountentries forchat_template_fileusesrc={container_chat_template}; for a bind mount thesrcshould be the host path, so consider using the originalchat_template_fileassrcandMNT_CHAT_TEMPLATE_FILEasdestinationrather than the container-mapped path. - The
chat_template_filemounting logic is duplicated in two branches ofsetup_mounts; consider extracting this into a small helper or shared block to reduce repetition and keep the behavior consistent if it needs to change later.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `setup_mounts`, the `--mount` entries for `chat_template_file` use `src={container_chat_template}`; for a bind mount the `src` should be the host path, so consider using the original `chat_template_file` as `src` and `MNT_CHAT_TEMPLATE_FILE` as `destination` rather than the container-mapped path.
- The `chat_template_file` mounting logic is duplicated in two branches of `setup_mounts`; consider extracting this into a small helper or shared block to reduce repetition and keep the behavior consistent if it needs to change later.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
There was a problem hiding this comment.
Code Review
This pull request introduces a new --chat-template-file command-line option, allowing users to specify a custom chat template. The changes are well-implemented across the CLI argument parsing, command context, and the inference engine specification. My review includes one suggestion to refactor a piece of duplicated code in ramalama/transports/base.py to improve long-term maintainability.
| if chat_template_file and os.path.isfile(chat_template_file): | ||
| container_chat_template = get_container_mount_path(chat_template_file) | ||
| self.engine.add( | ||
| [f"--mount=type=bind,src={container_chat_template},destination={MNT_CHAT_TEMPLATE_FILE},ro{self.engine.relabel()}"] |
There was a problem hiding this comment.
IIRC it's more complex than just bind mounting - have to consider oci images, kube/quadlet etc...
There was a problem hiding this comment.
Another option might be to support overriding the chat template in the ramalama convert cli - use it to generate an oci image/artifact with an overridden template? That would work in all cases I expect
…ers#1783) Users can pass a host path to a chat template file; it is mounted into the container at /mnt/models/chat_template.file and passed to the inference engine. Enables using fixed or custom templates without redownloading the model. - CLI: --chat-template-file for run, serve, perplexity - Transport: bind-mount in setup_mounts (helper), quadlet/kube/compose generation - Plugin: prefer user path (MNT_CHAT_TEMPLATE_FILE in container, host path otherwise) - Man pages: document option in run, serve, perplexity Signed-off-by: Daniel J Walsh <dwalsh@redhat.com> Made-with: Cursor Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
|
A friendly reminder that this PR had no activity for 30 days. |
Users can pass a host path to a chat template file; it is mounted into the container at /mnt/models/chat_template.file and passed to the inference engine. Enables using fixed or custom templates without redownloading the model.
Made-with: Cursor
Fixes: #1783
Summary by Sourcery
Add support for providing a host chat template file that is mounted into the container and passed through to the inference engine.
New Features:
Enhancements: