pub struct ContextPack {
pub config: ContextPackConfig,
pub selected: Vec<ContextItem>,
pub omitted: Vec<OmittedContextItem>,
pub total_estimated_chars: usize,
}Expand description
Selected and omitted context for one bounded model window.
use rig_compose::{ContextItem, ContextPack, ContextPackConfig, ContextSourceKind};
let item = ContextItem::new(ContextSourceKind::Memory, "m1", "fact alice lives in Berlin");
let pack = ContextPack::pack(vec![item], ContextPackConfig::new(1_000));
assert_eq!(pack.render_text(), "fact alice lives in Berlin");Fields§
§config: ContextPackConfigConfiguration used to build this pack.
selected: Vec<ContextItem>Items selected for prompt context, in render order.
omitted: Vec<OmittedContextItem>Items considered but omitted, with explicit reasons.
total_estimated_chars: usizeEstimated characters consumed by selected text and separators.
Implementations§
Source§impl ContextPack
impl ContextPack
Sourcepub fn pack(items: Vec<ContextItem>, config: ContextPackConfig) -> Self
pub fn pack(items: Vec<ContextItem>, config: ContextPackConfig) -> Self
Pack ranked context items into the configured character window.
Items are sorted by rank before packing so recorded fixtures can be
replayed even if a source returns equivalent items in a different order.
Sourcepub fn render_text(&self) -> String
pub fn render_text(&self) -> String
Render selected item text as prompt-ready context.
Trait Implementations§
Source§impl Clone for ContextPack
impl Clone for ContextPack
Source§fn clone(&self) -> ContextPack
fn clone(&self) -> ContextPack
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ContextPack
impl Debug for ContextPack
Source§impl<'de> Deserialize<'de> for ContextPack
impl<'de> Deserialize<'de> for ContextPack
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for ContextPack
impl PartialEq for ContextPack
Source§fn eq(&self, other: &ContextPack) -> bool
fn eq(&self, other: &ContextPack) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl Serialize for ContextPack
impl Serialize for ContextPack
impl StructuralPartialEq for ContextPack
Auto Trait Implementations§
impl Freeze for ContextPack
impl RefUnwindSafe for ContextPack
impl Send for ContextPack
impl Sync for ContextPack
impl Unpin for ContextPack
impl UnsafeUnpin for ContextPack
impl UnwindSafe for ContextPack
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more