Observability
Retrieval Inspector
RAG chunk inspector with a draggable similarity cutoff strip — switch Hybrid, Vector or Keyword scoring, expand matched passages, and pin or exclude chunks against a token budget.
2 variantsMIT
Preview
Retrieval inspector
“prorated refund policy for annual plans”
4 of 6 kept
1,300 / 1,500 tok·cutoff 0.72
Similarity cutoffDrag to filter chunks
0.000.501.00
- 0.92
Annual plans canceled within 14 days of renewal qualify for a prorated refund minus any metered overage charges billed in the current cycle.
Vector0.94Keyword0.89340 tok - 0.82
- 0.80
- 0.73
- 0.66
- 0.40
Threshold applies on next turn
Installation
Copies the component into components/ui and installs its dependencies and theme tokens.
pnpm dlx shadcn@latest add https://tuffui.com/r/retrieval-inspector.jsonUsage
Pass your own data and wire the callbacks to your agent runtime.
import { RetrievalInspector } from "@/components/ui/retrieval-inspector";
export function RagDebugCard({ search, onUpdateContext }: Props) {
return (
<RetrievalInspector
query={search.query}
chunks={search.candidates}
tokenBudget={1500}
onApply={(ids, threshold, mode) =>
onUpdateContext({ chunkIds: ids, threshold, mode })
}
/>
);
}Props
| Prop | Type | Default | Description |
|---|---|---|---|
| query* | string | — | The search query that retrieved these candidate chunks. |
| chunks* | RetrievalChunk[] | — | Candidate passages with vector and keyword scores and token counts. |
| mode | "hybrid" | "vector" | "keyword" | — | Controlled scoring mode. |
| defaultMode | "hybrid" | "vector" | "keyword" | "hybrid" | Initial scoring mode when uncontrolled. |
| onModeChange | (mode: RetrievalMode) => void | — | Called when the user switches between Hybrid, Vector and Keyword. |
| threshold | number | — | Controlled minimum score (0..1) required to include a chunk. |
| defaultThreshold | number | 0.72 | Initial similarity cutoff when uncontrolled. |
| onThresholdChange | (threshold: number) => void | — | Called as the user drags or nudges the similarity cutoff handle. |
| tokenBudget | number | — | Optional context budget; warns when kept chunks exceed it. |
| onApply | (includedIds: string[], threshold: number, mode: RetrievalMode) => void | — | Shows the primary action button and fires with the active chunk IDs. |
| title | ReactNode | "Retrieval inspector" | Header title. |
| subtitle | ReactNode | — | Secondary line under the title. Defaults to the quoted query. |
| className | string | — | Extra classes for the outer Shell. |
type RetrievalMode = "hybrid" | "vector" | "keyword";
type RetrievalChunk = {
id: string;
source: string;
section?: string;
excerpt: string;
vectorScore: number; // 0..1
keywordScore: number; // 0..1
tokens: number;
highlights?: string[];
};