Retrieved Sources
The passages a reply was built from: each document with where the passage sits and how relevant it scored, opening to the passage, with those under a threshold muted.
Full-time employees accrue 1.5 days of paid leave per month, up to a maximum of 30 days carried into the next year.
Installation
npx shadcn@latest add "@aiellie/retrieved-sources"shadcn needs the @aiellie registry in components.json first. npx aiellie add retrieved-sources adds it on its first run, then installs the same way.
Retrieved Sources lists the passages a reply was built from when it searched your own documents. Each row names the document, where in it the passage sits, and how relevant it scored, and opens to show the passage itself.
With a threshold, passages that scored under it are muted, so it's clear which ones the model was given. For pages from the web, use Sources.
Getting started
List what was retrieved
Scores run from 0 to 1, as most vector stores return them.
components/reply-sources.tsximport { RetrievedSource, RetrievedSources, } from "@/components/aiellie/retrieved-sources" export function ReplySources({ chunks }: { chunks: Chunk[] }) { return ( <RetrievedSources threshold={0.5}> {chunks.map((chunk) => ( <RetrievedSource key={chunk.id} title={chunk.document} location={`p. ${chunk.page}`} score={chunk.score} > {chunk.text} </RetrievedSource> ))} </RetrievedSources> ) }
Anatomy
<ol data-slot="retrieved-sources">
<li data-slot="retrieved-source" data-below-threshold>
<button /> {/* icon, title, location, score, chevron */}
<blockquote /> {/* the passage, when opened */}
</li>
</ol>Each row is a Base UI Collapsible. A row with no passage doesn't open and shows no chevron. The score is drawn as a short bar and printed to two places, and read out as its relevance.
Examples
Without scores
Leave score out for search that doesn't rank, and pass your own icon.
API reference
RetrievedSources
| Prop | Type | Default | Description |
|---|---|---|---|
threshold | number | Passages scoring under it are muted as not used. |
All other ol props are forwarded.
RetrievedSource
| Prop | Type | Default | Description |
|---|---|---|---|
title | ReactNode | required | The document. |
location | ReactNode | Where in it, like "p. 4". | |
score | number | Relevance, from 0 to 1. | |
icon | IconSvgElement | a file | |
children | ReactNode | The passage, shown when opened. | |
open, defaultOpen, onOpenChange | As on Collapsible.Root. |