pub struct KnowledgeBase { /* private fields */ }Expand description
Knowledge base for RAG
Implementations§
Source§impl KnowledgeBase
impl KnowledgeBase
Sourcepub fn new(vector_config: VectorStoreConfig) -> Self
pub fn new(vector_config: VectorStoreConfig) -> Self
Create a new knowledge base
Sourcepub fn with_persistence(
vector_config: VectorStoreConfig,
db_path: impl AsRef<Path>,
) -> Result<Self, MemoryError>
pub fn with_persistence( vector_config: VectorStoreConfig, db_path: impl AsRef<Path>, ) -> Result<Self, MemoryError>
Create with persistence
Sourcepub fn add_document(
&mut self,
document: Document,
) -> Result<String, MemoryError>
pub fn add_document( &mut self, document: Document, ) -> Result<String, MemoryError>
Add a document
Sourcepub fn retrieve(
&mut self,
query_embedding: &Embedding,
limit: usize,
) -> Vec<SearchResult>
pub fn retrieve( &mut self, query_embedding: &Embedding, limit: usize, ) -> Vec<SearchResult>
Retrieve relevant context for a query
Sourcepub fn get_document(&self, id: &str) -> Option<&Document>
pub fn get_document(&self, id: &str) -> Option<&Document>
Get document by ID
Sourcepub fn list_documents(&self) -> Vec<&Document>
pub fn list_documents(&self) -> Vec<&Document>
List all documents
Sourcepub fn delete_document(&mut self, id: &str) -> bool
pub fn delete_document(&mut self, id: &str) -> bool
Delete document
Auto Trait Implementations§
impl !Freeze for KnowledgeBase
impl !RefUnwindSafe for KnowledgeBase
impl Send for KnowledgeBase
impl !Sync for KnowledgeBase
impl Unpin for KnowledgeBase
impl !UnwindSafe for KnowledgeBase
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