pub struct RagContextManager<R: Retriever, G: GroundingStrategy = PrependStrategy> { /* private fields */ }Expand description
A ContextManager that retrieves documents and injects them as grounded context.
Implementations§
Source§impl<R: Retriever> RagContextManager<R, PrependStrategy>
impl<R: Retriever> RagContextManager<R, PrependStrategy>
Source§impl<R: Retriever, G: GroundingStrategy> RagContextManager<R, G>
impl<R: Retriever, G: GroundingStrategy> RagContextManager<R, G>
Sourcepub fn with_grounding<G2: GroundingStrategy>(
self,
grounding: G2,
) -> RagContextManager<R, G2>
pub fn with_grounding<G2: GroundingStrategy>( self, grounding: G2, ) -> RagContextManager<R, G2>
Set the grounding strategy used to format retrieved documents.
Sourcepub fn with_max_docs(self, max_docs: usize) -> Self
pub fn with_max_docs(self, max_docs: usize) -> Self
Maximum number of retrieved documents to inject (default: 5).
Trait Implementations§
Source§impl<R: Retriever, G: GroundingStrategy> ContextManager for RagContextManager<R, G>
impl<R: Retriever, G: GroundingStrategy> ContextManager for RagContextManager<R, G>
Source§fn prepare<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
messages: &'life1 mut Vec<Message>,
_context_window: usize,
_state: &'life2 mut AgentState,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn prepare<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
messages: &'life1 mut Vec<Message>,
_context_window: usize,
_state: &'life2 mut AgentState,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Prepare messages: retrieve docs for last user query, prepend as system message.
Auto Trait Implementations§
impl<R, G> Freeze for RagContextManager<R, G>
impl<R, G> RefUnwindSafe for RagContextManager<R, G>where
R: RefUnwindSafe,
G: RefUnwindSafe,
impl<R, G> Send for RagContextManager<R, G>
impl<R, G> Sync for RagContextManager<R, G>
impl<R, G> Unpin for RagContextManager<R, G>
impl<R, G> UnsafeUnpin for RagContextManager<R, G>where
R: UnsafeUnpin,
G: UnsafeUnpin,
impl<R, G> UnwindSafe for RagContextManager<R, G>where
R: UnwindSafe,
G: UnwindSafe,
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