Skip to main content

Module recent

Module recent 

Source
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§

LastMessages
The newest so many messages.
TokenBudget
The newest messages within max_tokens, as counter counts 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 messages that recent keeps, from its start moved forward by safe_start so no result loses its call.