import type { Reranker } from './retrievers.js'; /** Raised when a rerank API answers with an error. */ export declare class RerankerError extends Error { /** The HTTP status the API answered with. */ readonly status: number; /** The API's response body, as text. */ readonly body?: string | undefined; constructor(message: string, /** The HTTP status the API answered with. */ status: number, /** The API's response body, as text. */ body?: string | undefined); } /** What every HTTP reranker takes. */ export interface RerankerHttpOptions { /** Replaces the global `fetch`, for a proxy, retries, or tests. */ fetch?: typeof globalThis.fetch; /** Headers added to every request. */ headers?: Record; /** Aborts a request that takes longer, in milliseconds. Defaults to 30 seconds. */ timeoutMs?: number; /** Characters of each chunk sent. Defaults to 4,000. */ maxChunkCharacters?: number; } /** Options for a hosted rerank API. */ export interface HostedRerankerOptions extends RerankerHttpOptions { /** The API key. */ apiKey: string; /** The rerank model, such as `rerank-v3.5`. */ model: string; /** Replaces the API's endpoint, for a regional or proxied one. */ url?: string; } /** Options for `httpReranker()`: any rerank API, described by its request and its response. */ export interface HttpRerankerOptions extends RerankerHttpOptions { /** The endpoint. */ url: string; /** The request body for a query and its passages. */ body: (query: string, passages: string[]) => unknown; /** Reads the response: each passage's index and score. Passages it leaves out score 0. */ scores: (response: unknown) => ReadonlyArray<{ index: number; score: number; }>; } /** * A reranker over any HTTP rerank API: you describe the request body and how to read the scores, * and it handles the rest — truncation, the timeout, cancellation, errors, and scores put back in * the order of the chunks. */ export declare function httpReranker(options: HttpRerankerOptions): Reranker; /** Cohere's rerank API (`/v2/rerank`), such as `rerank-v3.5`. */ export declare function cohereReranker(options: HostedRerankerOptions): Reranker; /** Voyage AI's rerank API (`/v1/rerank`), such as `rerank-2`. */ export declare function voyageReranker(options: HostedRerankerOptions): Reranker; /** Jina AI's rerank API (`/v1/rerank`), such as `jina-reranker-v2-base-multilingual`. */ export declare function jinaReranker(options: HostedRerankerOptions): Reranker; /** Options for `teiReranker()`. */ export interface TeiRerankerOptions extends RerankerHttpOptions { /** The server, such as `http://localhost:8080`. */ url: string; } /** * A cross-encoder served by Hugging Face's text-embeddings-inference, on your own machine or * cluster: `docker run ... --model-id BAAI/bge-reranker-base`, then `teiReranker({ url })`. The * scores are the model's own, from 0 to 1. */ export declare function teiReranker(options: TeiRerankerOptions): Reranker; /** * A cross-encoder run in process: one score per (query, passage) pair, higher meaning more relevant. * A model from an ONNX runtime or a transformers library fits it in a few lines, so the package * depends on neither. */ export interface CrossEncoder { /** Scores each pair, in order. */ score(pairs: ReadonlyArray): Promise | readonly number[]; } /** Options for `crossEncoderReranker()`. */ export interface CrossEncoderRerankerOptions { /** Pairs scored in one call. Defaults to 32. */ batchSize?: number; /** Characters of each chunk scored. Defaults to 2,000. */ maxChunkCharacters?: number; /** Maps raw logits to 0–1 with a sigmoid, for a model that returns logits. Defaults to false. */ sigmoid?: boolean; } /** * A reranker over a cross-encoder you run in process: no network call, no per-query price, and the * passages never leave the machine. Pairs are scored in batches, and the run's signal is checked * between batches. */ export declare function crossEncoderReranker(model: CrossEncoder, options?: CrossEncoderRerankerOptions): Reranker;