pub struct RetrievalSystem { /* private fields */ }Expand description
Document retrieval system for RAG
Implementations§
Source§impl RetrievalSystem
impl RetrievalSystem
Sourcepub fn new(config: RetrievalConfig) -> Result<Self>
pub fn new(config: RetrievalConfig) -> Result<Self>
Create a new retrieval system
Attempts to use ONNX embeddings (semantic) with fallback to simple embeddings (hash-based)
Sourcepub fn with_embedder(
config: RetrievalConfig,
embedder: Arc<dyn EmbeddingGenerator>,
) -> Result<Self>
pub fn with_embedder( config: RetrievalConfig, embedder: Arc<dyn EmbeddingGenerator>, ) -> Result<Self>
Create a new retrieval system with a custom embedding generator
Sourcepub fn index_document(
&self,
document_id: &str,
content: &str,
source: &str,
metadata: Option<String>,
) -> Result<usize>
pub fn index_document( &self, document_id: &str, content: &str, source: &str, metadata: Option<String>, ) -> Result<usize>
Index a document by splitting it into chunks
Sourcepub fn retrieve(&self, query: &str, top_k: usize) -> Result<Vec<SearchResult>>
pub fn retrieve(&self, query: &str, top_k: usize) -> Result<Vec<SearchResult>>
Retrieve relevant documents for a query
Sourcepub fn chunk_count(&self) -> usize
pub fn chunk_count(&self) -> usize
Get the number of indexed chunks
Sourcepub fn stats(&self) -> RetrievalStats
pub fn stats(&self) -> RetrievalStats
Get retrieval statistics
Auto Trait Implementations§
impl Freeze for RetrievalSystem
impl !RefUnwindSafe for RetrievalSystem
impl Send for RetrievalSystem
impl Sync for RetrievalSystem
impl Unpin for RetrievalSystem
impl !UnwindSafe for RetrievalSystem
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