Files
owlen/examples/session_management.rs
vikingowl 4d7ad2c330 Refactor codebase for consistency and readability
- Standardize array and vector formatting for clarity.
- Adjust spacing and indentation in examples and TUI code.
- Ensure proper newline usage across files (e.g., LICENSE, TOML files, etc.).
- Simplify `.to_string()` and `.ok()` calls for brevity.
2025-10-05 02:31:53 +02:00

31 lines
884 B
Rust

// This example demonstrates how to use the session controller.
use owlen_core::session::Session;
fn main() {
// Create a new session.
let mut session = Session::new("my-session");
println!("Created new session: {}", session.name);
// Add messages to the session.
session.add_message("user", "Hello, Owlen!");
session.add_message("bot", "Hello, user! How can I help you today?");
// Get the messages from the session.
let messages = session.get_messages();
println!("\nMessages in session:");
for message in messages {
println!(" {}: {}", message.role, message.content);
}
// Clear the session.
session.clear_messages();
println!("\nSession cleared.");
let messages_after_clear = session.get_messages();
println!(
"Messages in session after clear: {}",
messages_after_clear.len()
);
}