Skip to content

Commit

Permalink
[bug] Fix app crash when doc references a citation that does not exist (
Browse files Browse the repository at this point in the history
#414)

Co-authored-by: Ian Seabock (Centific Technologies Inc) <[email protected]>
  • Loading branch information
iseabock and Ian Seabock (Centific Technologies Inc) committed Dec 4, 2023
1 parent 99bee96 commit 9f92236
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion 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) {
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

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<link rel="icon" type="image/x-icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Azure AI</title>
<script type="module" crossorigin src="/assets/index-f479a168.js"></script>
<script type="module" crossorigin src="/assets/index-4e24bac2.js"></script>
<link rel="stylesheet" href="/assets/index-5ba581b7.css">
</head>
<body>
Expand Down

0 comments on commit 9f92236

Please sign in to comment.