Spaces:
Sleeping
Sleeping
Download web/src/components/chat/AnswerBody.tsx from TBM99/CoverageCheck: direct link, hf CLI and curl.
- Browser
- Download file 2.74 kB
-
https://huggingface.co/spaces/TBM99/CoverageCheck/resolve/main/web/src/components/chat/AnswerBody.tsx
- Command line
-
hf download hf://spaces/TBM99/CoverageCheck/web/src/components/chat/AnswerBody.tsx
-
curl -L -o AnswerBody.tsx https://huggingface.co/spaces/TBM99/CoverageCheck/resolve/main/web/src/components/chat/AnswerBody.tsx
2.74 kB
| import { CircleAlert } from 'lucide-react' | |
| import { seconds, usd } from '@/lib/format' | |
| import type { RunState } from '@/lib/run' | |
| import { Sources } from './Sources' | |
| import { Trace } from './Trace' | |
| /** An answer: how it was made (Trace), the text, what a broker would still need to find | |
| * out, a version note, the numbered sources, and what it took. `recorded`: a held-out | |
| * run shown on the Evals page (its cost line says what it cost then). */ | |
| export function AnswerBody({ run, lastEventAt, recorded = false }: { run: RunState; lastEventAt: number; recorded?: boolean }) { | |
| const a = run.answer | |
| return ( | |
| <div className="space-y-3"> | |
| <Trace run={run} lastEventAt={lastEventAt} /> | |
| {run.error && ( | |
| <p role="alert" className="flex items-start gap-2 rounded-lg bg-red-50 p-3 text-sm text-red-700"> | |
| <CircleAlert className="mt-0.5 size-4 shrink-0" /> {run.error} | |
| </p> | |
| )} | |
| {a && ( | |
| <> | |
| {a.abstain && ( | |
| <p className="inline-flex items-center gap-1.5 rounded-full bg-amber-50 px-3 py-1 text-xs font-medium text-amber-800"> | |
| <CircleAlert className="size-3.5" /> Can't determine this from the documents | |
| </p> | |
| )} | |
| <div className="text-[15px] leading-relaxed whitespace-pre-wrap">{a.answer}</div> | |
| {a.missing_info.length > 0 && ( | |
| <div className="rounded-xl border p-3"> | |
| <p className="text-sm font-medium">What a broker would need to find out</p> | |
| <ul className="mt-1 list-disc space-y-1 pl-5 text-sm"> | |
| {a.missing_info.map((m, i) => ( | |
| <li key={i}>{m}</li> | |
| ))} | |
| </ul> | |
| </div> | |
| )} | |
| {a.flagged.length > 0 && ( | |
| <p className="text-xs text-amber-700"> | |
| Version note: {a.flagged.join(', ')} {a.flagged.length > 1 ? 'are' : 'is'} not in force on the policy date | |
| by {a.flagged.length > 1 ? 'their' : 'its'} stated dates, and no version of the form is: the answer may | |
| rest on an edition that is not the one on the policy. | |
| </p> | |
| )} | |
| {a.citations.length > 0 && <Sources citations={a.citations} />} | |
| <p className="text-[11px] tabular-nums text-muted-foreground"> | |
| Confidence {Math.round(a.confidence * 100)}% 路 {seconds(a.latency_ms)} 路{' '} | |
| {(a.usage.tokens_in + a.usage.tokens_out).toLocaleString()} tokens 路{' '} | |
| {recorded | |
| ? `${usd(a.usage.cost_usd)} when recorded` | |
| : a.usage.cached | |
| ? 'repeated question, answered from memory' | |
| : usd(a.usage.cost_usd)} | |
| </p> | |
| </> | |
| )} | |
| </div> | |
| ) | |
| } | |