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
ProtectedcreateThe response for a call its signal ended, before or during the driver's work. A caller
cancellation is classified Cancelled, so it is never failed over; an abort caused by a
timeout reads as a retriable network error.
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:
CancellationToken is already abortedReranking 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. A request's
CancellationTokenis handed to the SDK as itsabortSignal, so cancelling it tears the HTTP request down.Supported models:
Driver class: Registered as both
CohereReranker(the name the Cohere reranker models' model-vendor rows carry, and so the oneAIRerankerRunnerandRerankerServiceresolve) andCohereLLM.API Key: The legacy environment-variable fallback is named after the model-vendor row's driver class: AI_VENDOR_API_KEY__COHERERERANKER for the shipped Cohere reranker models. A Cohere credential binding takes precedence over it.
Usage: