Skip to main content

condense

Function condense 

Source
pub fn condense(
    req: &ModelRequest,
    keep_head: usize,
    keep_tail: usize,
) -> Option<Condensed>
Expand description

Drop the middle of req’s conversation, keeping keep_head opening turns and keep_tail closing ones.

Returns None when there is nothing useful to drop, so a caller cannot loop forever retrying a request that is not getting any smaller — a prompt that overflows on a single enormous turn cannot be fixed by removing turns, and pretending otherwise would just spend another call.