chore: Add index property to HashedMessage
| @@ -37,6 +37,7 @@ import { generateWebLlmChatPrompt, isWebLlmSupported } from '../shared.js'; | ||
| 37 | 37 | * @typedef {object} HashedMessage |
| 38 | 38 | * @property {string} text - The hashed message text |
| 39 | 39 | * @property {number} hash - The hash used as the vector key |
| 40 | + * @property {number} index - The index of the message in the chat | |
| 40 | 41 | */ |
| 41 | 42 | |
| 42 | 43 | const MODULE_NAME = 'vectors'; |
| @@ -725,7 +726,7 @@ const onChatEvent = debounce(async () => await moduleWorker.update(), debounce_t | ||
| 725 | 726 | */ |
| 726 | 727 | async function getQueryText(chat, initiator) { |
| 727 | 728 | let hashedMessages = chat |
| 728 | 729 | .map(x => ({ text: String(substituteParams(x.mes)), hash: getStringHash(substituteParams(x.mes)), index: chat.indexOf(x) })) |
| 729 | 730 | .filter(x => x.text) |
| 730 | 731 | .reverse() |
| 731 | 732 | .slice(0, settings.query); |