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
@@ -109,3 +109,44 @@ fn real_template_renders_a_turn() {
|
||||
"{out0}"
|
||||
);
|
||||
}
|
||||
|
||||
/// Ground truth: the composed context, rendered by the REAL template, must keep
|
||||
/// each section's closing tag followed by a blank line (what the model reads).
|
||||
#[test]
|
||||
#[ignore = "needs the real Inkling chat_template.jinja"]
|
||||
fn real_prompt_closes_sections_with_blank_line() {
|
||||
use strata_ctl::context;
|
||||
use strata_ctl::store::{ContextSection, Session, SessionSettings};
|
||||
let dir = std::env::var("STRATA_TOK_DIR")
|
||||
.unwrap_or_else(|_| "/home/federico/.config/strata-inkling/inkling-tok".to_string());
|
||||
let src = std::fs::read_to_string(format!("{dir}/chat_template.jinja")).unwrap();
|
||||
let t = ChatTemplate::new(&src).unwrap();
|
||||
let sess = Session {
|
||||
id: "s".into(),
|
||||
title: "Nebula".into(),
|
||||
model: "m".into(),
|
||||
settings: SessionSettings::default(),
|
||||
name_locked: true,
|
||||
folder: None,
|
||||
created_at: 0,
|
||||
updated_at: 0,
|
||||
};
|
||||
let sections = vec![
|
||||
ContextSection {
|
||||
name: "SYSTEM_PROMPT".into(),
|
||||
content: "{identity}{speaker_note}\n{session_prompt}".into(),
|
||||
position: 0,
|
||||
},
|
||||
ContextSection {
|
||||
name: "TOOL_USE".into(),
|
||||
content: "manuale".into(),
|
||||
position: 1,
|
||||
},
|
||||
];
|
||||
let msgs = context::compose(&sess, &[], "ciao", &[], "Federico", §ions);
|
||||
let val = serde_json::to_value(&msgs).unwrap();
|
||||
let out = t.render(&val, None, Some("low")).unwrap();
|
||||
assert!(out.contains("</SYSTEM_PROMPT>\n\n"), "{out}");
|
||||
assert!(out.contains("</TOOL_USE>\n\n"), "{out}");
|
||||
assert!(out.contains("</DIALOG>"), "{out}");
|
||||
}
|
||||
Reference in new issue
Block a user