pub struct ContextBuilder { /* private fields */ }Expand description
Context builder for constructing prompts with relevant memory
Implementations§
Source§impl ContextBuilder
impl ContextBuilder
Sourcepub fn with_config(config: ContextConfig) -> Self
pub fn with_config(config: ContextConfig) -> Self
Create a new context builder with configuration
Sourcepub fn max_tokens(&self) -> usize
pub fn max_tokens(&self) -> usize
Get max tokens
Sourcepub fn estimate_tokens(&self, text: &str) -> usize
pub fn estimate_tokens(&self, text: &str) -> usize
Estimate token count for text
Sourcepub fn build_from_memories(
&self,
memories: Vec<Memory>,
query: &str,
) -> MemoryResult<String>
pub fn build_from_memories( &self, memories: Vec<Memory>, query: &str, ) -> MemoryResult<String>
Build context from retrieved memories
Sourcepub fn build_from_search_results(
&self,
results: &[(Memory, f32)],
query: &str,
) -> MemoryResult<String>
pub fn build_from_search_results( &self, results: &[(Memory, f32)], query: &str, ) -> MemoryResult<String>
Build context with relevance scores
Sourcepub fn build_conversation_context(
&self,
conversation_history: &[(String, String)],
relevant_memories: Vec<Memory>,
system_instruction: Option<&str>,
) -> MemoryResult<String>
pub fn build_conversation_context( &self, conversation_history: &[(String, String)], relevant_memories: Vec<Memory>, system_instruction: Option<&str>, ) -> MemoryResult<String>
Build context for conversation continuation
Sourcepub fn build_system_prompt(instruction: &str) -> String
pub fn build_system_prompt(instruction: &str) -> String
Build system prompt with instruction
Sourcepub fn build_summary_prompt(memories: &[Memory]) -> String
pub fn build_summary_prompt(memories: &[Memory]) -> String
Build a summary prompt for memory consolidation
Sourcepub fn build_fact_extraction_prompt(text: &str) -> String
pub fn build_fact_extraction_prompt(text: &str) -> String
Build a fact extraction prompt
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ContextBuilder
impl RefUnwindSafe for ContextBuilder
impl Send for ContextBuilder
impl Sync for ContextBuilder
impl Unpin for ContextBuilder
impl UnwindSafe for ContextBuilder
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