File size: 1,228 Bytes
23d418f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from '@/components/ui/accordion'
import type { Passage } from '@/lib/types'

/** The passages the answer model read, exactly as it read them (label = title + in-force
 * dates), in prompt order. For C they arrive before the answer call. */
export function EvidenceList({ passages }: { passages: Passage[] }) {
  return (
    <Accordion type="multiple" className="w-full">
      {passages.map((p, i) => (
        <AccordionItem key={p.chunk_id} value={p.chunk_id}>
          <AccordionTrigger className="py-2 text-left text-sm break-words">
            <span>
              <span className="mr-2 text-muted-foreground tabular-nums">{i + 1}.</span>
              <span className="font-medium">{p.source_id}</span>
              <span className="ml-2 text-xs text-muted-foreground">
                {p.label}
                {p.pages ? ` · ${p.pages}` : ''}
              </span>
            </span>
          </AccordionTrigger>
          <AccordionContent>
            <p className="rounded-md bg-muted/50 p-3 text-xs leading-relaxed whitespace-pre-wrap">{p.text}</p>
          </AccordionContent>
        </AccordionItem>
      ))}
    </Accordion>
  )
}