Skip to content

Commit

Permalink
fix: Frontend crash due to invalid citations (#1002)
Browse files Browse the repository at this point in the history
  • Loading branch information
komalg1 authored May 29, 2024
1 parent cfdbd89 commit c323d78
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion code/frontend/src/components/Answer/AnswerParser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c323d78

Please sign in to comment.