fix(examples-chat): use Pandoc citation refs so inline markers link#221
Merged
Conversation
…s link The chat-streaming-md component renders citation references via @cacheplane/partial-markdown, which recognises Pandoc-style [^refId] syntax. The previous system prompt instructed the model to emit plain [1], [2] markers, which render as plain text and don't link to the sources panel. Live smoke (post Phase 2B merge) confirmed the issue: chat-message showed plain [1] in the body with the Sources panel rendered below, but inlineRefs (chat-md-citation-reference elements) was 0. System prompt + welcome suggestion now instruct the model to use [^doc-id] with the document id field returned by the search tool. Server-side probe confirms the model emits 17 markers across 3 unique document ids per response, and 0 plain [N] markers. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
Summary
Live smoke (post Phase 2B merge in #220) surfaced Finding G: chat-streaming-md rendered the assistant's response with plain
[1],[2]text markers and a fully-populated Sources panel below — but the inline markers were not clickable links to the sources. They rendered as raw text.Root cause
@cacheplane/partial-markdownrecognises Pandoc-style[^refId]citation syntax, not plain[N]numerical markers. The Phase 2B system prompt instructed the model to emit[1],[2], etc., which the parser ignored — so<chat-md-citation-reference>elements were never generated despite the citations registry being correctly wired.Fix
Update the python graph's system prompt and the Angular welcome suggestion to instruct Pandoc-style
[^doc-id]syntax, using the documentidfield returned by thesearch_documentstool (e.g.[^ng-signals-overview],[^ng-control-flow]). Each first-use of a document gets an auto-numbered marker; subsequent references to the same document share the number.The
Message.citationsshape produced byattach_citationsalready carries each document'sidas the citation's id field, whichCitationsResolverService.lookup(refId)matches against — so the resolver finds the citation by document id and renders the marker as a clickable<a>link to the source URL.Test plan
Verified locally
nx run examples-chat-python:smoke— 4 passednx run examples-chat-angular:build— succeeds (development)[^doc-id]markers (3 unique:ng-signals-overview,ng-signals-rxjs,ng-control-flow); 0 plain[N]markers.Pending visual verification
examples/chatdemo. Inline[N]superscript markers in the assistant's response link to the Sources panel; hovering shows the citation snippet; clicking opens the source URL.