Expand description
Recent messages: which newest messages of a conversation a request
sends. A Recent rule says where the messages it keeps start; view moves that
start past results whose calls it cut off, so every result it keeps
still follows its call.
use std::sync::Arc;
use rig_core::completion::Message;
use rig_memory::recent::{LastMessages, view};
let messages = [Message::user("1"), Message::assistant("2"), Message::user("3")].map(Arc::new);
assert_eq!(view(&messages, &LastMessages(2)), &messages[1..]);Structs§
- Last
Messages - The newest so many messages.
- Token
Budget - The newest messages within
max_tokens, ascountercounts them: walking back from the newest, it stops before the first message that does not fit.
Traits§
- Recent
- Where the newest messages a request sends start.
Functions§
- view
- The messages of
messagesthatrecentkeeps, from its start moved forward bysafe_startso no result loses its call.