pub struct ContextAssembler { /* private fields */ }Expand description
Context assembler — builds prompts respecting token budgets.
Implementations§
Source§impl ContextAssembler
impl ContextAssembler
Sourcepub fn new(budget: TokenBudget) -> Self
pub fn new(budget: TokenBudget) -> Self
Create a new context assembler.
Sourcepub fn with_defaults() -> Self
pub fn with_defaults() -> Self
Create with default budget.
Sourcepub fn with_system_prompt(self, prompt: impl Into<String>) -> Self
pub fn with_system_prompt(self, prompt: impl Into<String>) -> Self
Set custom system prompt.
Sourcepub fn with_user_profile(self, profile: UserProfile) -> Self
pub fn with_user_profile(self, profile: UserProfile) -> Self
Set user profile.
Sourcepub fn assemble(
&self,
user_message: &str,
memories: &[Memory],
conversation_history: &[Message],
) -> Vec<Message>
pub fn assemble( &self, user_message: &str, memories: &[Memory], conversation_history: &[Message], ) -> Vec<Message>
Assemble context into messages.
Takes retrieved memories and conversation history, returns messages ready for the LLM.
Sourcepub fn estimate_tokens(messages: &[Message]) -> usize
pub fn estimate_tokens(messages: &[Message]) -> usize
Quick estimate of total tokens in messages.
Auto Trait Implementations§
impl Freeze for ContextAssembler
impl RefUnwindSafe for ContextAssembler
impl Send for ContextAssembler
impl Sync for ContextAssembler
impl Unpin for ContextAssembler
impl UnsafeUnpin for ContextAssembler
impl UnwindSafe for ContextAssembler
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more