UNPKG

@adonis-agora/agent

Version:

Governed, durable-backed AI agent (chat + tool-calling + governance) for AdonisJS — part of the Agora ecosystem.

46 lines • 2.21 kB
import type { Reranker, RerankOptions } from '../spi/reranker.js'; import type { Passage } from '../spi/retriever.js'; export interface HttpRerankerOptions { /** * The full rerank endpoint: `https://api.cohere.com/v2/rerank`, `https://api.jina.ai/v1/rerank`, * `https://api.voyageai.com/v1/rerank`, or a Hugging Face TEI / Infinity / vLLM server's `/rerank`. */ url: string; /** Model id, sent as `model` (hosted APIs require it; TEI serves one model and ignores it). */ model?: string; /** Sent as `Authorization: Bearer <apiKey>` when set. */ apiKey?: string; /** * Request body dialect. `cohere` (Cohere, Jina, Voyage, Infinity, vLLM): `{ query, documents, * top_n }`. `tei`: `{ query, texts }`. Default `auto`, which sends `documents` **and** `texts` so * one config works against both families. Responses are read in every dialect regardless. */ format?: 'auto' | 'cohere' | 'tei'; /** Extra request headers. */ headers?: Record<string, string>; /** Per-request timeout. Default 30 000 ms. */ timeoutMs?: number; /** `fetch` to use. Default the global one. */ fetch?: typeof fetch; } /** * A cross-encoder {@link Reranker} behind an HTTP `/rerank` endpoint — the Cohere-style contract * most providers and self-hosted servers share. Compose it with `RerankingRetriever`: * * ```ts * const reranker = new HttpReranker({ url: 'https://api.cohere.com/v2/rerank', model: 'rerank-v3.5', apiKey }); * const retriever = new RerankingRetriever(hybrid, reranker, { fetchTopK: 30 }); * ``` * * Reads `results: [{ index, relevance_score }]` (Cohere, Jina), `data: [{ index, relevance_score }]` * (Voyage) and a bare `[{ index, score }]` (TEI). Each passage keeps its fields and takes the new * score; the list is re-sorted and cut to `topK`. Indices the server invents are ignored. */ export declare class HttpReranker implements Reranker { private readonly options; private readonly format; private readonly doFetch; constructor(options: HttpRerankerOptions); rerank(query: string, passages: Passage[], options?: RerankOptions): Promise<Passage[]>; } //# sourceMappingURL=http-reranker.d.ts.map