#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum FormatStyle {
Brackets,
Xml,
}
pub const DEFAULT_FORMAT_STYLE: FormatStyle = FormatStyle::Xml;
/// An instant as it reaches the model. The implementation lives beside the runtime that stores
/// the stamps, so the prompt and the record cannot render the same instant two ways.
#[must_use]
pub fn format_instant(ms: i64) -> String {
klbr_runtime::instant::format_instant(ms)
}
pub fn format_context_summary_block(summary: &str, timestamp: &str, style: FormatStyle) -> String {
let note = "Compressed recollection of older conversation turns. If anything conflicts, trust newer raw messages.";
match style {
FormatStyle::Brackets => format!(
"[[context recollection]]\n{note}\n[[segments]]\n[[llm-recollection {timestamp}]]\n{}",
summary.trim()
),
FormatStyle::Xml => format!(
"<context_recollection note=\"{note}\">\n<llm_recollection timestamp=\"{timestamp}\">\n{}\n</llm_recollection>\n</context_recollection>",
summary.trim()
),
}
}