Create a new CohereReranker instance.
Cohere API key
OptionalmodelName: stringModel to use (default: 'rerank-v3.5')
ProtectedapiOnly sub-classes can access the API key
Get the model name used for this reranker
ProtectedcreateCreate a standardized error response. Used internally when validation fails or an exception occurs.
ProtecteddoRerank documents using Cohere's Rerank API.
The Cohere API returns results sorted by relevance with scores from 0-1. We map the response to our RerankResult format, preserving document metadata.
ProtectedfilterFilter results by minimum relevance threshold. Utility method for implementations that need to filter low-scoring results.
Rerank documents based on their relevance to a query. This is the main entry point for reranking operations.
The method:
Reranking parameters including query and documents
Promise resolving to RerankResponse with reranked results
ProtectedsortSort results by relevance score in descending order. Utility method for implementations.
Cohere implementation of the BaseReranker class. Uses Cohere's Rerank API for semantic document reranking.
Supported models:
API Key: Set via environment variable: AI_VENDOR_API_KEY__COHERELLM
Usage: