chore: Add index property to HashedMessage

02900520c9e5cc2eb8312827b6a26f1b95a59c8d

Cohee <18619528+Cohee1207@users.noreply.github.com>

1 files changed, +2 -1Ignore whitespace
public/scripts/extensions/vectors/index.js+2 -1
@@ -37,6 +37,7 @@ import { generateWebLlmChatPrompt, isWebLlmSupported } from '../shared.js';
3737 * @typedef {object} HashedMessage
3838 * @property {string} text - The hashed message text
3939 * @property {number} hash - The hash used as the vector key
40+ * @property {number} index - The index of the message in the chat
4041 */
4142
4243const MODULE_NAME = 'vectors';
@@ -725,7 +726,7 @@ const onChatEvent = debounce(async () => await moduleWorker.update(), debounce_t
725726 */
726727async function getQueryText(chat, initiator) {
727728 let hashedMessages = chat
728729 .map(x => ({ text: String(substituteParams(x.mes)), hash: getStringHash(substituteParams(x.mes)), index: chat.indexOf(x) }))
729730 .filter(x => x.text)
730731 .reverse()
731732 .slice(0, settings.query);