mirror of
https://github.com/wassname/stampy-chat.git
synced 2026-09-10 12:40:44 +08:00
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:
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user