Spaces:
Sleeping
Sleeping
Aissugur Kurganbekov
Claude Opus 4.8
Add hybrid retrieval (TF-IDF + embeddings), OCR, A/B eval, and answer trust/UX
f65a6b3 Download frontend/src/lib/highlight.jsx from financeflow/ai: direct link, hf CLI and curl.
- Browser
- Download file 1.07 kB
-
https://huggingface.co/spaces/financeflow/ai/resolve/main/frontend/src/lib/highlight.jsx
- Command line
-
hf download hf://spaces/financeflow/ai/frontend/src/lib/highlight.jsx
-
curl -L -o highlight.jsx https://huggingface.co/spaces/financeflow/ai/resolve/main/frontend/src/lib/highlight.jsx
1.07 kB
| // highlightMatch — wrap the verbatim `match` substring inside `text` in a | |
| // <mark>, so the UI can show *which* span of an evidence excerpt the question | |
| // matched (Citation.match_text from the backend). Degrades gracefully: | |
| // - no match / not found -> returns the plain text unchanged | |
| // - case-insensitive, but preserves the excerpt's original casing in output | |
| // Returns a React-renderable node (string or array of strings + <mark>). | |
| export function highlightMatch(text, match) { | |
| if (!text) return text ?? ""; | |
| if (!match || typeof match !== "string") return text; | |
| const needle = match.trim(); | |
| if (!needle) return text; | |
| const idx = text.toLowerCase().indexOf(needle.toLowerCase()); | |
| if (idx === -1) return text; // span not present verbatim — show plain excerpt | |
| const before = text.slice(0, idx); | |
| const hit = text.slice(idx, idx + needle.length); // keep original casing | |
| const after = text.slice(idx + needle.length); | |
| return ( | |
| <> | |
| {before} | |
| <mark className="evidence-mark">{hit}</mark> | |
| {after} | |
| </> | |
| ); | |
| } | |