UNPKG

@adonis-agora/agent

Version:

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

25 lines • 1.08 kB
/** * Two-stage retrieval: over-fetch cheap candidates from a base {@link Retriever}, then reorder them with * a stronger {@link Reranker} and keep the top few. The standard precision boost — a fast first stage * casts a wide net, a slow accurate second stage sharpens it. Composes over ANY retriever (vector, * hybrid, keyword), and is itself a `Retriever` so it drops straight into the config's `retriever` slot. * Mirrors the reference `RerankingRetriever` exactly. */ export class RerankingRetriever { base; reranker; options; constructor(base, reranker, options = {}) { this.base = base; this.reranker = reranker; this.options = options; } async retrieve(query, options = {}) { const candidates = await this.base.retrieve(query, { topK: this.options.fetchTopK ?? 20, ...(options.filter !== undefined ? { filter: options.filter } : {}), }); return this.reranker.rerank(query, candidates, { topK: options.topK ?? 5 }); } } //# sourceMappingURL=reranking-retriever.js.map