Skip to content

Recognize grouped citations like [1, 2] - #3

Merged
sinnercode228 merged 1 commit into
mainfrom
fix/grouped-citations
Oct 18, 2026
Merged

sinnercode228 merged 1 commit into
mainfrom
fix/grouped-citations

Conversation

@sinnercode228

Copy link
Copy Markdown
Owner

What was wrong: the citation regex in rag/service.py (cited_indices) and in AnswerText (renderInline) only matched one number per pair of brackets. When the model answered with a grouped marker such as [1, 2] or [1, 2, 3] instead of the [1][2] form, cited_indices returned [] and the UI rendered no citation buttons, so every source card stayed grey even though the answer referenced them.

The fix: both the server and the renderer now accept a comma-separated list of numbers inside one pair of brackets and treat each number as its own citation, keeping the same 1..available range check. A grouped marker whose numbers are all out of range still stays as literal text, and [1][2] keeps working.

How it was tested: new backend/tests/test_citations.py covers separate, repeated and grouped markers plus out-of-range dropping; new cases in AnswerText.test.tsx cover a grouped marker becoming one button per source, a mixed in/out-of-range group, and a fully out-of-range group staying literal. Full CI run locally: backend ruff + ruff format + mypy + pytest (114 passed), frontend eslint + tsc + vitest (34 passed) + build.

Fixes #2

The citation regex in rag/service.py and in AnswerText only matched a
single number between brackets, so when the model answered with a
grouped marker such as [1, 2] or [1, 2, 3] instead of the [1][2] form,
cited_indices returned [] and the UI drew no citation buttons, leaving
every source card grey.

Both the server and the renderer now accept a comma-separated list of
numbers inside one pair of brackets and treat each number as its own
citation, the same range check (1..available) as before. A grouped
marker with no in-range number still stays as literal text.

Fixes #2
@sinnercode228
sinnercode228 merged commit 4822345 into main Oct 18, 2026
3 checks passed
@sinnercode228
sinnercode228 deleted the fix/grouped-citations branch October 18, 2026 07:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Grouped citations like [1, 2] are not recognized

1 participant