pub struct RAGPipeline<S: VectorStore, E: Embedder> { /* private fields */ }Expand description
RAG (Retrieval-Augmented Generation) Pipeline
Implementations§
Source§impl<S: VectorStore, E: Embedder> RAGPipeline<S, E>
impl<S: VectorStore, E: Embedder> RAGPipeline<S, E>
Sourcepub fn with_chunking(self, strategy: ChunkingStrategy) -> Self
pub fn with_chunking(self, strategy: ChunkingStrategy) -> Self
Set chunking strategy
Sourcepub fn with_top_k(self, top_k: usize) -> Self
pub fn with_top_k(self, top_k: usize) -> Self
Set default top_k for retrieval
Sourcepub async fn index_document(
&self,
doc_id: &str,
content: &str,
metadata: Option<HashMap<String, Value>>,
) -> Result<usize, MemoryError>
pub async fn index_document( &self, doc_id: &str, content: &str, metadata: Option<HashMap<String, Value>>, ) -> Result<usize, MemoryError>
Index a document (with automatic chunking)
Sourcepub async fn retrieve(
&self,
query: &str,
top_k: Option<usize>,
) -> Result<Vec<SearchResult>, MemoryError>
pub async fn retrieve( &self, query: &str, top_k: Option<usize>, ) -> Result<Vec<SearchResult>, MemoryError>
Retrieve relevant context for a query
Sourcepub async fn retrieve_context(
&self,
query: &str,
top_k: Option<usize>,
) -> Result<String, MemoryError>
pub async fn retrieve_context( &self, query: &str, top_k: Option<usize>, ) -> Result<String, MemoryError>
Retrieve and format context as a string for LLM prompt
Sourcepub async fn augment_prompt(
&self,
query: &str,
top_k: Option<usize>,
) -> Result<String, MemoryError>
pub async fn augment_prompt( &self, query: &str, top_k: Option<usize>, ) -> Result<String, MemoryError>
Build an augmented prompt with retrieved context
Sourcepub async fn delete_document(&self, doc_id: &str) -> Result<usize, MemoryError>
pub async fn delete_document(&self, doc_id: &str) -> Result<usize, MemoryError>
Delete a document and all its chunks
Sourcepub async fn document_count(&self) -> Result<usize, MemoryError>
pub async fn document_count(&self) -> Result<usize, MemoryError>
Get document count
Sourcepub async fn clear(&self) -> Result<(), MemoryError>
pub async fn clear(&self) -> Result<(), MemoryError>
Clear all documents
Auto Trait Implementations§
impl<S, E> Freeze for RAGPipeline<S, E>
impl<S, E> RefUnwindSafe for RAGPipeline<S, E>where
S: RefUnwindSafe,
E: RefUnwindSafe,
impl<S, E> Send for RAGPipeline<S, E>
impl<S, E> Sync for RAGPipeline<S, E>
impl<S, E> Unpin for RAGPipeline<S, E>
impl<S, E> UnsafeUnpin for RAGPipeline<S, E>
impl<S, E> UnwindSafe for RAGPipeline<S, E>where
S: RefUnwindSafe,
E: RefUnwindSafe,
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