From 6e4f828cbd5957ac5cd9d8a4d258d3823043d024 Mon Sep 17 00:00:00 2001 From: Fraser Date: Mon, 3 Apr 2023 20:16:17 -0400 Subject: [PATCH] check valid citation Asking questions about the format of citation itself is a quick way to check out-of-range info --- web/src/pages/index.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/web/src/pages/index.tsx b/web/src/pages/index.tsx index dee86c5..ec90794 100644 --- a/web/src/pages/index.tsx +++ b/web/src/pages/index.tsx @@ -225,7 +225,12 @@ const Home: NextPage = () => { const citations = new Map(); 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",