-
Notifications
You must be signed in to change notification settings - Fork 5
Add support for Mistral 3 series templates #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
984caf1
f5d8662
85f324f
ac1bfb1
2d4d7c3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,6 +40,8 @@ struct chat_template_caps { | |
| bool requires_object_arguments = false; | ||
| // CohereForAI/c4ai-command-r-plus simple variant | ||
| bool requires_non_null_content = false; | ||
| // mistralai/Ministral-3-14B-Reasoning-2512 | ||
| bool requires_non_empty_content = false; | ||
| // MiniMaxAI/MiniMax-Text-01 special | ||
| bool requires_typed_content = false; | ||
| }; | ||
|
|
@@ -171,13 +173,24 @@ class chat_template { | |
| }; | ||
| auto out_empty = render_with_content(""); | ||
| auto out_null = render_with_content(json()); | ||
| caps_.requires_non_null_content = contains(out_empty, user_needle) && !contains(out_null, user_needle); | ||
|
|
||
| auto out_nonempty = render_with_content("<Assistant Needle>"); | ||
| caps_.requires_non_empty_content = contains(out_nonempty, user_needle) && !contains(out_empty, user_needle) && !contains(out_null, user_needle); | ||
| caps_.requires_non_null_content = (contains(out_empty, user_needle) && !contains(out_null, user_needle)) || caps_.requires_non_empty_content; | ||
|
|
||
| json j_null; | ||
| auto assistant_content = [&](const json & content) { | ||
| if (content.is_null() && caps_.requires_non_null_content) { | ||
| return json(""); | ||
| } | ||
| if ((content.is_null() || (content.is_string() && content.empty())) && caps_.requires_non_empty_content) { | ||
| return json("<Assitant Needle>"); | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please extract a constant (+ fix typo) above next to the others const std::string assistant_needle = "<Assistant Needle>";
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm disturbed by this needle. The semantics here is you need a non-empty content, not that you need a needle to be found from outside (otherwise someone would have passed the needle explicitly). Just use
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you agree there is no need to extract a constant if I use |
||
| } | ||
| return content; | ||
| }; | ||
| auto make_tool_calls_msg = [&](const json & tool_calls) { | ||
| return json { | ||
| {"role", "assistant"}, | ||
| {"content", caps_.requires_non_null_content? "" : j_null}, | ||
| {"content", assistant_content(j_null)}, | ||
| {"tool_calls", tool_calls}, | ||
| }; | ||
| }; | ||
|
|
@@ -250,7 +263,7 @@ class chat_template { | |
| }; | ||
| const json tool_call_msg { | ||
| {"role", "assistant"}, | ||
| {"content", caps_.requires_non_null_content ? "" : j_null}, | ||
| {"content", assistant_content(j_null)}, | ||
| {"tool_calls", json::array({ | ||
| { | ||
| // TODO: detect if requires numerical id or fixed length == 6 like Nemo | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.