Skip to content

Cite userguide answers by url, so they stop having no sources at all - #246

Merged
adamjohnwright merged 1 commit into
mainfrom
feat/userguide-citations
Sep 18, 2026
Merged

adamjohnwright merged 1 commit into
mainfrom
feat/userguide-citations

Conversation

@adamjohnwright

Copy link
Copy Markdown
Contributor

Adam's decision. A userguide-routed question returned zero citations — "How do I use the pathway browser?" gave 0 citations and 452 tokens — because a citation carries st_id, and the userguide collection indexes documentation pages whose identity is a URL. It is also the fastest class of answer, so the gap was common rather than exotic.

The shape

Exactly one identifier per citation, the other key absent rather than empty:

{"st_id": "R-HSA-8862803", "display_name": "Deregulated CDK5 triggers..."}
{"url": "https://reactome.org/userguide/pathway-browser", "display_name": "The Pathway Browser"}

A consumer that understands only st_id keeps working by skipping what it does not recognise.

No fabricated stable ids. A made-up R- would resolve to nothing or — worse — to a real but wrong entity, and a reader cannot tell from the link text.

Deduplicated by page, not chunk: the bundle is 98 chunks across 10 pages, so chunk-level citations would repeat one page up to 27 times.

The bug the unit tests could not have caught

The first version leaked a server filesystem path as a citation url:

url   /home/awright/git/reactome_chatbot/embeddings/openai/...

source is a generic LangChain metadata field, and the CSV loaders set it to the file they read — so a Reactome document lacking an st_id cited a local path, to a public website. Only https:// and http:// sources are cited now.

It showed up the first time a real question ran. My fixtures were too clean to contain a filesystem path, which is precisely why they passed.

Measured after

question before after
How do I use the pathway browser? 0 4
How do I run a GSEA in Reactome? 0 2
What does CDK5 do in neurons? 12 12, no paths

CI-equivalent locally: ruff, format, mypy (129 files), full suite with no API keys set.

🤖 Generated with Claude Code

Adam's call, 2026-09-18. A userguide-routed question returned zero citations --
"How do I use the pathway browser?" gave 0 citations and 452 tokens -- because a
citation carries `st_id` and the userguide collection indexes documentation
pages whose identity is a URL. It is also the fastest class of answer, so the
gap was common rather than exotic.

A citation now carries exactly one identifier: `st_id` for Reactome and
disease-variant sources, `url` for userguide pages, with the other key absent
rather than empty so a consumer that understands only `st_id` keeps working by
skipping what it does not recognise.

No fabricated stable ids. A made-up `R-` would resolve to nothing or to a real
but wrong entity, and a reader cannot tell from the link text.

Deduplicated by page rather than chunk: the bundle is 98 chunks across 10 pages,
so chunk-level citations would repeat one page up to 27 times. The page title is
the label.

**Only http(s) sources are cited, and that guard was not in the first version.**
`source` is a generic LangChain field the CSV loaders set to the file they read,
so a Reactome document lacking an `st_id` cited
"/home/awright/git/reactome_chatbot/embeddings/openai/..." -- a server path, to a
public website. The unit tests used fixtures too clean to contain one; it showed
up the first time a real question ran.

Measured after: pathway-browser 0 -> 4 citations, GSEA 0 -> 2, and Reactome
questions unchanged at 12 with no paths among them.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@adamjohnwright
adamjohnwright merged commit 127ae3d into main Sep 18, 2026
10 checks passed
@adamjohnwright
adamjohnwright deleted the feat/userguide-citations branch September 18, 2026 06:16
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.

1 participant