pub struct ChunkedVectorStore { /* private fields */ }Expand description
Chunked Vector Store
Implementations§
Source§impl ChunkedVectorStore
impl ChunkedVectorStore
Sourcepub fn new(
document_store: Arc<InMemoryChunkedDocumentStore>,
vector_size: usize,
) -> ChunkedVectorStore
pub fn new( document_store: Arc<InMemoryChunkedDocumentStore>, vector_size: usize, ) -> ChunkedVectorStore
创建新的 ChunkedVectorStore
Sourcepub async fn add_chunk_vector(
&self,
chunk_id: impl Into<String>,
embedding: Vec<f32>,
) -> Result<(), VectorStoreError>
pub async fn add_chunk_vector( &self, chunk_id: impl Into<String>, embedding: Vec<f32>, ) -> Result<(), VectorStoreError>
添加 chunk 向量(chunk_id + embedding)
Sourcepub async fn add_chunk_vectors(
&self,
chunk_ids: Vec<String>,
embeddings: Vec<Vec<f32>>,
) -> Result<(), VectorStoreError>
pub async fn add_chunk_vectors( &self, chunk_ids: Vec<String>, embeddings: Vec<Vec<f32>>, ) -> Result<(), VectorStoreError>
批量添加 chunk 向量
Sourcepub async fn add_parent_document(
&self,
document: Document,
chunk_size: usize,
embeddings_fn: impl Fn(&str) -> Vec<f32>,
) -> Result<(String, Vec<String>), VectorStoreError>
pub async fn add_parent_document( &self, document: Document, chunk_size: usize, embeddings_fn: impl Fn(&str) -> Vec<f32>, ) -> Result<(String, Vec<String>), VectorStoreError>
从 Parent 文档添加(自动分割 + 向量化)
Sourcepub async fn get_embedding(
&self,
chunk_id: &str,
) -> Result<Option<Vec<f32>>, VectorStoreError>
pub async fn get_embedding( &self, chunk_id: &str, ) -> Result<Option<Vec<f32>>, VectorStoreError>
获取 chunk_id 对应的向量 (M4: O(1) HashMap lookup)
Sourcepub async fn vector_count(&self) -> usize
pub async fn vector_count(&self) -> usize
获取向量数量
Trait Implementations§
Source§impl VectorStore for ChunkedVectorStore
impl VectorStore for ChunkedVectorStore
Source§fn add_documents<'life0, 'async_trait>(
&'life0 self,
documents: Vec<Document>,
embeddings: Vec<Vec<f32>>,
) -> Pin<Box<dyn Future<Output = Result<Vec<String>, VectorStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
ChunkedVectorStore: 'async_trait,
fn add_documents<'life0, 'async_trait>(
&'life0 self,
documents: Vec<Document>,
embeddings: Vec<Vec<f32>>,
) -> Pin<Box<dyn Future<Output = Result<Vec<String>, VectorStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
ChunkedVectorStore: 'async_trait,
Adds documents. Read more
Source§fn similarity_search<'life0, 'life1, 'async_trait>(
&'life0 self,
query_embedding: &'life1 [f32],
k: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<SearchResult>, VectorStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
ChunkedVectorStore: 'async_trait,
fn similarity_search<'life0, 'life1, 'async_trait>(
&'life0 self,
query_embedding: &'life1 [f32],
k: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<SearchResult>, VectorStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
ChunkedVectorStore: 'async_trait,
Searches similar documents. Read more
Source§fn similarity_search_with_min_score<'life0, 'life1, 'async_trait>(
&'life0 self,
query_embedding: &'life1 [f32],
k: usize,
min_score: Option<f32>,
) -> Pin<Box<dyn Future<Output = Result<Vec<SearchResult>, VectorStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
ChunkedVectorStore: 'async_trait,
fn similarity_search_with_min_score<'life0, 'life1, 'async_trait>(
&'life0 self,
query_embedding: &'life1 [f32],
k: usize,
min_score: Option<f32>,
) -> Pin<Box<dyn Future<Output = Result<Vec<SearchResult>, VectorStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
ChunkedVectorStore: 'async_trait,
带最低分数阈值的相似度检索。 Read more
Source§fn get_document<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Document>, VectorStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
ChunkedVectorStore: 'async_trait,
fn get_document<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Document>, VectorStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
ChunkedVectorStore: 'async_trait,
Gets document by ID.
Source§fn get_embedding<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Vec<f32>>, VectorStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
ChunkedVectorStore: 'async_trait,
fn get_embedding<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Vec<f32>>, VectorStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
ChunkedVectorStore: 'async_trait,
Gets document embedding by ID.
Source§fn delete_document<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), VectorStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
ChunkedVectorStore: 'async_trait,
fn delete_document<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), VectorStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
ChunkedVectorStore: 'async_trait,
Deletes document.
Source§fn count<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = usize> + Send + 'async_trait>>where
'life0: 'async_trait,
ChunkedVectorStore: 'async_trait,
fn count<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = usize> + Send + 'async_trait>>where
'life0: 'async_trait,
ChunkedVectorStore: 'async_trait,
Returns document count.
Source§fn clear<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), VectorStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
ChunkedVectorStore: 'async_trait,
fn clear<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), VectorStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
ChunkedVectorStore: 'async_trait,
Clears store.
Source§fn embed_query(&self) -> Option<&dyn Embeddings>
fn embed_query(&self) -> Option<&dyn Embeddings>
返回该向量存储自带的文本嵌入器(若有)。 Read more
Source§fn similarity_search_text<'life0, 'life1, 'async_trait>(
&'life0 self,
query: &'life1 str,
k: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<SearchResult>, VectorStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn similarity_search_text<'life0, 'life1, 'async_trait>(
&'life0 self,
query: &'life1 str,
k: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<SearchResult>, VectorStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Auto Trait Implementations§
impl !RefUnwindSafe for ChunkedVectorStore
impl !UnwindSafe for ChunkedVectorStore
impl Freeze for ChunkedVectorStore
impl Send for ChunkedVectorStore
impl Sync for ChunkedVectorStore
impl Unpin for ChunkedVectorStore
impl UnsafeUnpin for ChunkedVectorStore
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