@corbits/reranking scores documents against a query with a cross-encoder
over TEI, Cohere/Jina or Voyage rerank endpoints, with @intx/inference
retries and error classification. It owns the wire adapters, id mapping and
the one-shot JSON transport. It does not retrieve or store documents.
src/rerank.ts:RerankConfigSchemaandrerankDocuments, which maps scores back to caller ids and sorts best first.src/adapters.ts: thetei,cohereandvoyageadapters andcreateRerankAdapterRegistry.src/request.ts:runJSONRequest(private transport),RerankRequestError,Retry-Afterextraction.src/index.ts: the only module consumers import from.e2e/: a live TEI suite that skips unlessTEI_RERANK_URLanswers.
- Providers score by array position; always map back to the caller's
id. - Throw
RerankRequestErrorcarrying the classifiedInferenceErrorasreason; never throw theInferenceErroritself. - Adapters parse replies with arktype and throw
ProtocolMismatchErroron a bad shape. - An empty
docslist returns[]without a request. exactOptionalPropertyTypesis on: omit optional keys, never assignundefinedto them.
bun install
bun run check- Read
README.mdbefore changing public behavior. - Keep changes focused; update docs and tests alongside code changes.
- Run
bun run checkbefore declaring work complete.