@ragfoundry/adapter-rerank-cohere
v0.1.2
Published
Cohere reranker adapter for RAGFoundry.
Maintainers
Readme
@ragfoundry/adapter-rerank-cohere
🔀 Cohere reranker adapter. Reorder retrieved chunks by relevance with Cohere Rerank before they reach the prompt.
A Reranker adapter for RAGFoundry — typed retrieval-augmented generation for TypeScript.
💡 New to RAGFoundry? This page is for adding one specific provider to an app you're already building. Starting a project from scratch is faster with the scaffolder — it asks a few questions and wires everything (including this adapter, if you pick it) for you:
npm create @ragfoundry my-app
📦 Install
npm install @ragfoundry/core @ragfoundry/adapter-rerank-cohere🚀 Usage
Works with both import and require — this package ships both builds.
ESM:
import { createRAG } from "@ragfoundry/core"
import "@ragfoundry/adapter-rerank-cohere"
const rag = createRAG({
reranker: { provider: "cohere", apiKey: process.env.COHERE_API_KEY! },
// ...the rest of your config
})CommonJS:
const { createRAG } = require("@ragfoundry/core")
require("@ragfoundry/adapter-rerank-cohere")
const rag = createRAG({
reranker: { provider: "cohere", apiKey: process.env.COHERE_API_KEY },
// ...the rest of your config
})⚠️ The import/require is what registers "cohere" at runtime — remove
it and createRAG throws Unknown adapter "cohere", even though the
provider name is still typed correctly. In TypeScript it's also what makes the
reranker block above autocomplete and type-check.
⚙️ Options
| Option | Type | Required | Default |
|---|---|---|---|
| apiKey | string | yes | — |
| model | string | no | rerank-v3.5 |
| baseUrl | string | no | Cohere API |
📝 A reranker only helps if it has more to choose from than ends up in the prompt, so
topKdefaults to 20 (instead of 5) whenever one is configured.
🔗 See also
@ragfoundry/core— the pipelines, types, and every export explained@ragfoundry/create—npm create @ragfoundry, scaffold a whole project
📄 License
MIT
