AbstractCreate a new reranker instance.
API key for the reranking service (e.g., Cohere API key)
OptionalmodelName: stringOptional model name to use (provider-specific)
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.
Protected AbstractdoProvider-specific reranking implementation. Subclasses must implement this method to perform the actual reranking.
Implementation requirements:
params.CancellationToken when one is setReranking parameters
Promise resolving to array of RerankResult sorted by relevance
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.
Abstract base class for all reranker implementations. Extends BaseModel to follow MJ conventions for AI model classes.
Provides common functionality including:
Example usage: