Member Junction
    Preparing search index...

    Cohere implementation of the BaseReranker class. Uses Cohere's Rerank API for semantic document reranking.

    Supported models:

    • rerank-v3.5: Latest English reranker with best accuracy
    • rerank-multilingual-v3.0: Supports 100+ languages

    API Key: Set via environment variable: AI_VENDOR_API_KEY__COHERELLM

    Usage:

    const reranker = ClassFactory.CreateInstance<BaseReranker>(
    BaseReranker,
    'CohereReranker',
    apiKey,
    'rerank-v3.5'
    );

    const response = await reranker.Rerank({
    query: 'What is the capital of France?',
    documents: [
    { id: '1', text: 'Paris is the capital of France.' },
    { id: '2', text: 'London is in England.' }
    ],
    topK: 5
    });

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    _modelName: string

    Accessors

    • get apiKey(): string

      Only sub-classes can access the API key

      Returns string

    • get ModelName(): string

      Get the model name used for this reranker

      Returns string

    Methods

    • Create a standardized error response. Used internally when validation fails or an exception occurs.

      Parameters

      • message: string
      • startTime: number

      Returns RerankResponse

    • Rerank documents based on their relevance to a query. This is the main entry point for reranking operations.

      The method:

      1. Validates input parameters
      2. Calls the provider-specific doRerank() implementation
      3. Applies topK limit if specified
      4. Returns standardized RerankResponse

      Parameters

      • params: RerankParams

        Reranking parameters including query and documents

      Returns Promise<RerankResponse>

      Promise resolving to RerankResponse with reranked results