Optional cost reporter. When set, the reranker invokes it after each successful
Rerank call with the actual cents charged. The SearchEngine wires this from the
RerankerBudgetGuard to the scope-level spend tracker — see Phase 2D.6.
The DriverClass key used by @RegisterClass(BaseReRanker, 'DriverClassName') so
the SearchEngine can resolve this subclass via ClassFactory from the scope's
ScopeConfig.reRanker.driverClass value.
Human-friendly display name. Defaults to DriverClass so subclasses don't have to
override unless they want a different label in UI dropdowns / cost reports.
Reranker semantic version (independent of the package version). Bump this on a
subclass when the prompt, scoring formula, or upstream model identifier changes
in a way that invalidates cached scores. Defaults to '1'.
ProtectedbuildBuild the text representation of a SearchResultItem for the rerank model.
Default concatenates Title and Snippet separated by newline. Override to
customize (e.g. include tags or entity context).
Cohere bills per "search". 1 search reranks up to 100 documents; above 100,
count as ceil(N/100) searches, each estimated at 0.2¢ (see the file header).
ProtectedgetReturn the underlying @memberjunction/ai BaseReranker instance to use.
Provider-specific subclasses (Cohere, BGE, Voyage) override this to return a
configured AI reranker. Returning null (the default) tells ReRank() to
skip the AI layer and fall back to a simple top-N slice — useful for Noop
and test implementations.
Provider-specific config from ScopeConfig.reRanker.config.
The calling user (for auth / tenant propagation).
Cohere caps a single rerank call at 1000 documents. Above this, the SearchEngine should chunk (not implemented yet — most realistic candidate lists are <100).
ProtectedreportHelper for subclasses: report a cost AND record it on the optional callback. Always safe to call even when no callback is set.
Override ReRank to record actual cost via reportCost only after a successful
Cohere call (matching VoyageReRanker's super.ReRank pattern).
Optionalconfig: Record<string, unknown>StaticGetEnumerate every reranker currently registered with ClassFactory under
BaseReRanker. Designed for the SearchScope form's reranker dropdown (P2D.7) —
the form populates the dropdown from this single call rather than hardcoding
a list, so any ClassFactory-registered reranker (including third-party ones
published as separate packages) shows up automatically.
Each entry includes the driver-class registration key, the friendly Name,
Version, and a HasCost flag (true when EstimateCostCents(1) > 0). Sorted
by Name for stable UI ordering.
Cohere re-ranker for SearchEngine (defaults to
rerank-v5.0-fast). Configured per scope viaSearchScope.ScopeConfig.reRanker.driverClass = 'CohereReRanker'.Configuration keys in
ScopeConfig.reRanker.config:model: Cohere model ID ('rerank-v5.0-fast','rerank-v5.0-pro','rerank-v4.0-pro','rerank-v3.5', etc.)relevantSpans:trueor{ threshold?: number, maxSpans?: number }to extract passage-level spans with Cohere Rerank 5 Context Focus.focusSnippet: When Context Focus returns spans, whether to narrowSnippetto them (default:true).minRelevanceThreshold: Calibrated relevance cutoff (0.0-1.0). Results below it are dropped, unless none reaches it, in which case all are kept.