Skip to main content

Crate synaptic_cohere

Crate synaptic_cohere 

Source
Expand description

Cohere integration for Synaptic.

This crate provides CohereReranker, a reranker that uses the Cohere Rerank API to reorder documents by relevance to a query.

When the retrieval feature is enabled, CohereReranker also implements the DocumentCompressor trait, making it usable with ContextualCompressionRetriever.

§Example

use synaptic_cohere::{CohereReranker, CohereRerankerConfig};
use synaptic_core::Document;

let config = CohereRerankerConfig::new("your-api-key")
    .with_top_n(3);
let reranker = CohereReranker::new(config);

let docs = vec![
    Document::new("1", "Rust is a systems programming language"),
    Document::new("2", "Python is great for data science"),
];

let reranked = reranker.rerank("systems programming", docs, None).await?;

Structs§

CohereReranker
A reranker that uses the Cohere Rerank API to reorder documents by relevance to a query.
CohereRerankerConfig
Configuration for the Cohere Reranker.
Document
A document with content and metadata, used throughout the retrieval pipeline.