Close context sections with </NAME> + blank line so boundaries are explicit
The Inkling template renders message content verbatim with no separator, so closing tags were glued to <|end_message|> and the model did not perceive section boundaries. compose() now emits each static section as <NAME>... </NAME> followed by a blank line, and DIALOG opener/closer on their own lines. Added an #[ignore] ground-truth test rendering the composed context through the REAL chat_template.jinja asserting </SYSTEM_PROMPT>\n\n, </TOOL_USE>\n\n and </DIALOG> survive. Live probe: model now cites </TOOL_USE> + blank line and </DIALOG>. 140 tests green, clippy/fmt clean.
This commit is contained in:
1 parent
a4722b7379
commit
840410a08f
3 files changed
+57
-10
No files matched your search
+13
-7
@@ -714,14 +714,17 @@ mod tests {
|
||||
assert!(t0.starts_with("<SYSTEM_PROMPT>"));
|
||||
assert!(t0.contains("Pippo") && t0.contains("/tmp/pippo"));
|
||||
assert!(t0.contains("sii breve"));
|
||||
assert!(t0.ends_with("</SYSTEM_PROMPT>"));
|
||||
assert_eq!(req.messages[1].text().unwrap(), "<DIALOG>");
|
||||
assert!(t0.ends_with("</SYSTEM_PROMPT>\n\n"));
|
||||
assert_eq!(req.messages[1].text().unwrap(), "<DIALOG>\n");
|
||||
let user = &req.messages[req.messages.len() - 2];
|
||||
assert!(matches!(user.role, Role::User));
|
||||
// The new user turn carries the human speaker tag.
|
||||
assert!(user.text().unwrap().starts_with("[SPEAKER: Federico - "));
|
||||
assert!(user.text().unwrap().ends_with("ciao"));
|
||||
assert_eq!(req.messages.last().unwrap().text().unwrap(), "</DIALOG>");
|
||||
assert_eq!(
|
||||
req.messages.last().unwrap().text().unwrap(),
|
||||
"\n</DIALOG>\n\n"
|
||||
);
|
||||
}
|
||||
|
||||
fn sp_section() -> ContextSection {
|
||||
@@ -862,12 +865,15 @@ mod tests {
|
||||
assert!(req.messages[0]
|
||||
.text()
|
||||
.unwrap()
|
||||
.ends_with("</SYSTEM_PROMPT>"));
|
||||
.ends_with("</SYSTEM_PROMPT>\n\n"));
|
||||
assert_eq!(
|
||||
req.messages[1].text().unwrap(),
|
||||
"<TOOL_USE>\nmanuale\n</TOOL_USE>"
|
||||
"<TOOL_USE>\nmanuale\n</TOOL_USE>\n\n"
|
||||
);
|
||||
assert_eq!(req.messages[2].text().unwrap(), "<DIALOG>\n");
|
||||
assert_eq!(
|
||||
req.messages.last().unwrap().text().unwrap(),
|
||||
"\n</DIALOG>\n\n"
|
||||
);
|
||||
assert_eq!(req.messages[2].text().unwrap(), "<DIALOG>");
|
||||
assert_eq!(req.messages.last().unwrap().text().unwrap(), "</DIALOG>");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user