You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The ability to exclude certain citations from being referenced. Code below (/frontend/src/components/Answer/AnswerParser.tsx) filters out any citation that has "EXCLUDE_ME" in the filename.
export function parseAnswer(answer: AskResponse): ParsedAnswer {
let answerText = answer.answer;
const citationLinks = answerText.match(/[(doc\d\d?\d?)]/g);
const lengthDocN = "[doc".length;
let filteredCitations = [] as Citation[];
let citationReindex = 0;
citationLinks?.forEach(link => {
// Extracting the citation index and the corresponding citation
let citationIndex = link.slice(lengthDocN, link.length - 1);
let citation = cloneDeep(answer.citations[Number(citationIndex) - 1]) as Citation;
// If the citation's filename contains the unwanted code, skip this iteration.
if (citation.filepath?.includes("EXCLUDE_ME")) {
// Replace its reference in the answerText with an empty string
answerText = answerText.replace(link, "");
return; // Skip further processing for this citation
}
// Check if citation is already included, if not, process it
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
filteredCitations.push(citation);
}
});
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
The ability to exclude certain citations from being referenced. Code below (/frontend/src/components/Answer/AnswerParser.tsx) filters out any citation that has "EXCLUDE_ME" in the filename.
export function parseAnswer(answer: AskResponse): ParsedAnswer {
let answerText = answer.answer;
const citationLinks = answerText.match(/[(doc\d\d?\d?)]/g);
Beta Was this translation helpful? Give feedback.
All reactions