Restore entry labels in context tree: role, tool calls, memory keys
ConversationEntry::label() provides descriptive labels matching the old entry_sections format: - "Kent: what about..." / "Aria: [tool_call: memory_search, ...]" - "mem: [memory: key-name score:0.73]" - "dmn: [heartbeat]" / "system: [system prompt]" Uses config names (assistant_name, user_name) not generic "asst"/"user". Widget renderer uses label() instead of raw content preview. Co-Authored-By: Proof of Concept <poc@bcachefs.org>
This commit is contained in:
parent
5523752a15
commit
a20f3e3642
2 changed files with 44 additions and 8 deletions
|
|
@ -347,6 +347,44 @@ impl ConversationEntry {
|
|||
matches!(self, Self::Log(_))
|
||||
}
|
||||
|
||||
/// Short description for the debug UI.
|
||||
pub fn label(&self) -> String {
|
||||
let cfg = crate::config::get();
|
||||
match self {
|
||||
Self::System(_) => "system: [system prompt]".to_string(),
|
||||
Self::Dmn(_) => "dmn: [heartbeat]".to_string(),
|
||||
Self::Log(text) => {
|
||||
let preview: String = text.chars().take(60).collect();
|
||||
format!("log: {}", preview.replace('\n', " "))
|
||||
}
|
||||
Self::Memory { key, score, .. } => {
|
||||
let role = "mem".to_string();
|
||||
match score {
|
||||
Some(s) => format!("{}: [memory: {} score:{:.1}]", role, key, s),
|
||||
None => format!("{}: [memory: {}]", role, key),
|
||||
}
|
||||
}
|
||||
Self::Message(m) => {
|
||||
let role = match m.role {
|
||||
Role::Assistant => cfg.assistant_name.clone(),
|
||||
Role::User => cfg.user_name.clone(),
|
||||
Role::Tool => "tool".to_string(),
|
||||
Role::System => "system".to_string(),
|
||||
};
|
||||
if let Some(tc) = &m.tool_calls {
|
||||
let names: Vec<_> = tc.iter().map(|c| c.function.name.as_str()).collect();
|
||||
format!("{}: [tool_call: {}]", role, names.join(", "))
|
||||
} else {
|
||||
let text = m.content_text();
|
||||
let preview: String = text.chars().take(60).collect();
|
||||
let preview = preview.replace('\n', " ");
|
||||
if text.len() > 60 { format!("{}: {}...", role, preview) }
|
||||
else { format!("{}: {}", role, preview) }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Get a reference to the inner message.
|
||||
/// Panics on Log entries.
|
||||
pub fn message(&self) -> &Message {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue