affectUI › Components › Agents
Rerank List
What a search found for a question and what a reranker kept – each chunk with its similarity and relevance, and a line that cuts off what goes into the prompt.
Part of affectUI Pro. Install: npx shadcn@latest add https://www.affectui.com/r/rerank-list.json · Import from @/components/ui/rerank-list
When to use
- Showing what a RAG pipeline found for a question and which chunks a reranker kept for the prompt
- Making a reranker's effect visible: the vector search's best hit can drop out, a lower one can climb into the top few
- Debugging retrieval – why an answer quoted one source and not another
When not to use
- Showing where each extracted value stands in a document – use Source Map
- Citing sources under an answer in a chat – use Cited Answer
- Picking the best of several answers, two at a time – use Judge Bracket
Usage
import { RerankList, type RerankQuery } from "@/components/ui/rerank-list";
const queries: RerankQuery[] = [
{
id: "rotate",
query: "How do I rotate an API key without downtime?",
chunks: [
{ id: "create", title: "API keys › Creating a key", snippet: "Create a key under Settings → API keys.", source: { name: "Docs" }, similarity: 0.86, relevance: 0.31 },
{ id: "rotate", title: "API keys › Rotating keys", snippet: "Create the new key first, then revoke the old one.", source: { name: "Docs" }, similarity: 0.84, relevance: 0.96 },
{ id: "thread", title: "Key rotation at peak", snippet: "Revoke only once the deploy is done.", source: { name: "Support" }, similarity: 0.77, relevance: 0.74 },
],
},
];
export function Retrieval() {
return <RerankList queries={queries} model={{ id: "rerank", name: "Reranker", subtitle: "Cross-encoder" }} topK={2} />;
}Props
| Name | Type | Default | Description |
|---|---|---|---|
queries | RerankQuery[] | { id, query, chunks, topK? } – one question each, with the chunks its search found; several play one after the other | |
chunks | RerankChunk[] | { id, title, snippet?, source?, similarity, relevance } – similarity (0–1) is the vector search's score and sets the order they come in, relevance (0–1) the reranker's and sets the order they end in; ties keep the order given | |
model | { id: string; name: string; subtitle?: string } | The reranker in the head – its pixel mark is drawn from id; subtitle defaults to Reranker | |
topK | number | How many chunks go into the prompt – default 3. They sit above the line on a light gray of their own, the rest fade. 0 keeps none, as many as there are draws no line | |
autoPlay | boolean | Scores the chunks one by one, moves them to their places and goes on to the next question – default true. Off, it shows the result and the arrows step through the questions | |
className | string | Extra class on the root – set the color variables on it, e.g. --ui-rkl-rel-bg for the relevance bars |
Keyboard
- Tab: Pause or Play, then the list as one stop – it starts at rank 1 – then the arrows when paused
- ↑ / ↓ / Home / End: In the list: the chunk one rank up or down, the first or the last – in the order they stand, not the order they came in
Accessibility
- Each chunk reads its title, source, score and rank, and whether it goes into the prompt; its place in the list follows its rank
- A polite live region (not shown) says which chunks went into the prompt once the reranker is done
- The run holds while a chunk is pointed at or focused; Pause stops it, also with one question
- Focus rings show for the keyboard only (:focus-visible)
- Titles and the question keep their own direction in any script; ranks, bars and scores read left to right, also in RTL
Responsive
- Fills its container; in a narrow one the bars and the arrows step aside – the scores stay
- More than ten chunks scroll inside the list, with a soft fade where more wait below
- Rows keep one height – long titles and snippets end in an ellipsis, the full text shows on hover
- The classic style is a gray tray with the question and the list as white cards on it, pill-shaped tags and firmer type – the same behavior as the clean one
- Dark mode built in: switches when an ancestor (usually <html>) has the class dark or data-theme="dark"
Requirements
- React 19
Related
- Source Map – What a model pulled out of a document, with a line from every typed field to the words it came from – and "Not in input" where it would otherwise have to guess
- Cited Answer – An AI answer wired to its sources – point at a citation to light up its sentence and source, click to unfold the quoted passage with the matching words marked
- Context Window – What fills the model's context, as a field of cells – hover a part to light it up, remove files, and compact the conversation while its cells shimmer and clear
- Token Budget – How many tokens an agent's runs take against a limit – the average per run large, every run as a bar in its model's color, the part above the limit in pink