Repository navigation
Recognize grouped citations like [1, 2] - #3
Merged
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What was wrong: the citation regex in
rag/service.py(cited_indices) and inAnswerText(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_indicesreturned[]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.pycovers separate, repeated and grouped markers plus out-of-range dropping; new cases inAnswerText.test.tsxcover 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