Add command interface and status indicator.
This commit is contained in:
parent
5cb6647513
commit
7b9525ef95
7 changed files with 358 additions and 22 deletions
|
|
@ -34,6 +34,11 @@ impl ConversationHistory {
|
|||
pub fn messages(&self) -> &[ConversationMessage] {
|
||||
&self.messages
|
||||
}
|
||||
|
||||
/// Remove all messages from the history.
|
||||
pub fn clear(&mut self) {
|
||||
self.messages.clear();
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for ConversationHistory {
|
||||
|
|
@ -73,6 +78,17 @@ mod tests {
|
|||
assert_eq!(msgs[1].content, "hi there");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn clear_empties_history() {
|
||||
let mut history = ConversationHistory::new();
|
||||
history.push(ConversationMessage {
|
||||
role: Role::User,
|
||||
content: "hello".to_string(),
|
||||
});
|
||||
history.clear();
|
||||
assert!(history.messages().is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn messages_preserves_insertion_order() {
|
||||
let mut history = ConversationHistory::new();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue