pub struct SemanticSimilarityExampleSelector {
pub vectorstore: Box<dyn VectorStore>,
pub k: usize,
pub example_keys: Option<Vec<String>>,
pub input_keys: Option<Vec<String>>,
pub vectorstore_kwargs: Option<HashMap<String, Value>>,
}
Expand description
Select examples based on semantic similarity using vector stores.
This selector uses embeddings and vector similarity search to find the most relevant examples for a given input.
Fields§
§vectorstore: Box<dyn VectorStore>
Vector store containing the examples
k: usize
Number of examples to select
example_keys: Option<Vec<String>>
Optional keys to filter examples to
input_keys: Option<Vec<String>>
Optional keys to filter input to
vectorstore_kwargs: Option<HashMap<String, Value>>
Extra arguments passed to similarity search
Implementations§
Source§impl SemanticSimilarityExampleSelector
impl SemanticSimilarityExampleSelector
Sourcepub fn new(
vectorstore: Box<dyn VectorStore>,
k: usize,
example_keys: Option<Vec<String>>,
input_keys: Option<Vec<String>>,
vectorstore_kwargs: Option<HashMap<String, Value>>,
) -> Self
pub fn new( vectorstore: Box<dyn VectorStore>, k: usize, example_keys: Option<Vec<String>>, input_keys: Option<Vec<String>>, vectorstore_kwargs: Option<HashMap<String, Value>>, ) -> Self
Create a new semantic similarity example selector.
§Arguments
vectorstore
- Vector store containing the examplesk
- Number of examples to selectexample_keys
- Optional keys to filter examples toinput_keys
- Optional keys to filter input tovectorstore_kwargs
- Extra arguments for similarity search
Trait Implementations§
Source§impl BaseExampleSelector for SemanticSimilarityExampleSelector
impl BaseExampleSelector for SemanticSimilarityExampleSelector
Source§fn add_example(&mut self, _example: Example) -> Result<()>
fn add_example(&mut self, _example: Example) -> Result<()>
Add a new example to the store. Read more
Source§fn aadd_example<'life0, 'async_trait>(
&'life0 mut self,
example: Example,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn aadd_example<'life0, 'async_trait>(
&'life0 mut self,
example: Example,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Async add a new example to the store. Read more
Source§fn select_examples(&self, _input_variables: &Example) -> Result<Vec<Example>>
fn select_examples(&self, _input_variables: &Example) -> Result<Vec<Example>>
Select which examples to use based on the inputs. Read more
Source§fn aselect_examples<'life0, 'life1, 'async_trait>(
&'life0 self,
input_variables: &'life1 Example,
) -> Pin<Box<dyn Future<Output = Result<Vec<Example>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn aselect_examples<'life0, 'life1, 'async_trait>(
&'life0 self,
input_variables: &'life1 Example,
) -> Pin<Box<dyn Future<Output = Result<Vec<Example>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Async select which examples to use based on the inputs. Read more
Auto Trait Implementations§
impl Freeze for SemanticSimilarityExampleSelector
impl !RefUnwindSafe for SemanticSimilarityExampleSelector
impl Send for SemanticSimilarityExampleSelector
impl Sync for SemanticSimilarityExampleSelector
impl Unpin for SemanticSimilarityExampleSelector
impl !UnwindSafe for SemanticSimilarityExampleSelector
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