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
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:
Reranking 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:
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.
Abstract base class for all reranker implementations. Extends BaseModel to follow MJ conventions for AI model classes.
Provides common functionality including:
Example usage: