check valid citation

Asking questions about the format of citation itself is a quick way to check out-of-range info
This commit is contained in:
Fraser
2023-04-03 20:16:51 -04:00
parent ebbf5e81ac
commit 6e4f828cbd
+6 -1
View File
@@ -225,7 +225,12 @@ const Home: NextPage = () => {
const citations = new Map<number, Citation>();
cite_map.forEach((value, key) => {
citations.set(value, data.citations[key.charCodeAt(0) - 'a'.charCodeAt(0)]);
const index = key.charCodeAt(0) - 'a'.charCodeAt(0);
if (index >= data.citations.length) {
console.log("invalid citation index: " + index);
} else {
citations.set(value, data.citations[index]);
}
});
setEntries([...new_entries, {role: "assistant",