Prefix handoff messages with role

This commit is contained in:
Ahmed Ibrahim
2026-03-04 13:45:50 -08:00
parent 2322e49549
commit 38a744bd07

View File

@@ -376,7 +376,7 @@ fn realtime_text_from_handoff_request(handoff: &RealtimeHandoffRequested) -> Opt
let messages = handoff
.messages
.iter()
.map(|message| message.text.as_str())
.map(|message| format!("{}: {}", message.role, message.text))
.collect::<Vec<_>>()
.join("\n");
(!messages.is_empty()).then_some(messages).or_else(|| {
@@ -605,7 +605,7 @@ mod tests {
};
assert_eq!(
realtime_text_from_handoff_request(&handoff),
Some("hello\nhi there".to_string())
Some("user: hello\nassistant: hi there".to_string())
);
}