pub struct CohereReranker { /* private fields */ }Expand description
A reranker that uses the Cohere Rerank API to reorder documents by relevance to a query.
Each returned document has a relevance_score entry added to its metadata.
Implementations§
Source§impl CohereReranker
impl CohereReranker
Sourcepub fn new(config: CohereRerankerConfig) -> Self
pub fn new(config: CohereRerankerConfig) -> Self
Create a new CohereReranker with the given configuration.
Sourcepub fn with_client(config: CohereRerankerConfig, client: Client) -> Self
pub fn with_client(config: CohereRerankerConfig, client: Client) -> Self
Create a new CohereReranker with a custom HTTP client.
Sourcepub async fn rerank(
&self,
query: &str,
documents: Vec<Document>,
top_n: Option<usize>,
) -> Result<Vec<Document>, SynapticError>
pub async fn rerank( &self, query: &str, documents: Vec<Document>, top_n: Option<usize>, ) -> Result<Vec<Document>, SynapticError>
Rerank documents by relevance to a query.
Returns documents sorted by descending relevance score. Each document’s
metadata will contain a "relevance_score" entry.
§Arguments
query- The query to rank against.documents- The documents to rerank.top_n- Override the configuredtop_n. IfNone, uses the configured value, or returns all documents.
Auto Trait Implementations§
impl Freeze for CohereReranker
impl !RefUnwindSafe for CohereReranker
impl Send for CohereReranker
impl Sync for CohereReranker
impl Unpin for CohereReranker
impl UnsafeUnpin for CohereReranker
impl !UnwindSafe for CohereReranker
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