diff --git a/code/frontend/src/components/Answer/AnswerParser.tsx b/code/frontend/src/components/Answer/AnswerParser.tsx index 0717ec3e7..8d248673d 100644 --- a/code/frontend/src/components/Answer/AnswerParser.tsx +++ b/code/frontend/src/components/Answer/AnswerParser.tsx @@ -19,7 +19,7 @@ export function parseAnswer(answer: AskResponse): ParsedAnswer { // Replacing the links/citations with number let citationIndex = link.slice(lengthDocN, link.length - 1); let citation = cloneDeep(answer.citations[Number(citationIndex) - 1]) as Citation; - if (!filteredCitations.find((c) => c.id === citationIndex)) { + if (!filteredCitations.find((c) => c.id === citationIndex) && citation !== undefined) { answerText = answerText.replaceAll(link, ` ^${++citationReindex}^ `); citation.id = citationIndex; // original doc index to de-dupe citation.reindex_id = citationReindex.toString(); // reindex from 1 for display