[router][grpc] Add dependencies in Cargo.toml to support chat template rendering#11342
[router][grpc] Add dependencies in Cargo.toml to support chat template rendering#11342
Conversation
**Context** Chat template requires `tojson` filter to parse tool calls. This is available in `json` and `builtins` features in minijinja - Add features to Cargo.toml
Summary of ChangesHello @CatherineSue, 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 PR addresses a critical bug in the gRPC router preventing proper tool call handling for certain models by enabling required Highlights
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.
Code Review
Thank you for this contribution! The primary change to enable tojson and builtins features for minijinja is a great fix for the tool-calling issue with Llama-3.1 models.
I've reviewed the refactoring part of your changes where you remove the duplicate has_tool_call functions. While this is a good cleanup, I've found a couple of potential regressions in the new implementation of has_tool_markers that could cause tool calls to be missed during streaming. My comments below provide more details and suggestions to address this. Please take a look!
9f14331 to
dd511b1
Compare
Motivation
The current grpc router would fail with tool call request.
Error:
RCA:
The model being tested is Llama-3.1-8B-Instruct. Its chat template requires
tojsonfilter to parse tool call. See https://huggingface.co/meta-llama/Llama-3.1-8B-Instruct?chat_template=default#L38This is available in
jsonandbuiltinsfeatures in minijinja crate.Modifications
jsonandbuiltinsfor minijinja inCargo.tomlhas_tool_callinjson_parser.rsandllama_parser.rsAccuracy Tests
non-stream, tool_choice = "auto"

non-stream, tool_choice = "required"

Benchmarking and Profiling
Checklist