Member Junction
    Preparing search index...

    LLM-based implementation of the BaseReranker class. Uses AI Prompts to perform semantic reranking via large language models.

    This reranker is useful when:

    • You want to use your existing LLM infrastructure
    • You need more control over the reranking logic via custom prompts
    • Cohere or other dedicated rerankers are not available

    Configuration:

    • Requires a rerank prompt ID to be provided
    • The prompt should accept 'query', 'documents', and 'topK' template variables
    • The prompt should return JSON array: [{ index: number, score: number }, ...]

    Usage:

    const reranker = ClassFactory.CreateInstance<BaseReranker>(
    BaseReranker,
    'LLMReranker',
    '', // No API key needed, uses AI Prompts system
    '', // No model name, uses prompt configuration
    promptID,
    contextUser
    );

    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

    • Create a new LLMReranker instance.

      Parameters

      • apiKey: string

        Not used for LLM reranker, pass empty string

      • modelName: string

        Not used for LLM reranker, pass empty string

      • promptID: string

        ID of the AI Prompt to use for reranking

      • contextUser: UserInfo

        User context for executing the prompt

      Returns LLMReranker

    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