mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
chore: Add index property to HashedMessage
This commit is contained in:
@@ -37,6 +37,7 @@ import { generateWebLlmChatPrompt, isWebLlmSupported } from '../shared.js';
|
|||||||
* @typedef {object} HashedMessage
|
* @typedef {object} HashedMessage
|
||||||
* @property {string} text - The hashed message text
|
* @property {string} text - The hashed message text
|
||||||
* @property {number} hash - The hash used as the vector key
|
* @property {number} hash - The hash used as the vector key
|
||||||
|
* @property {number} index - The index of the message in the chat
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const MODULE_NAME = 'vectors';
|
const MODULE_NAME = 'vectors';
|
||||||
@@ -725,7 +726,7 @@ const onChatEvent = debounce(async () => await moduleWorker.update(), debounce_t
|
|||||||
*/
|
*/
|
||||||
async function getQueryText(chat, initiator) {
|
async function getQueryText(chat, initiator) {
|
||||||
let hashedMessages = chat
|
let hashedMessages = chat
|
||||||
.map(x => ({ text: String(substituteParams(x.mes)), hash: getStringHash(substituteParams(x.mes)) }))
|
.map(x => ({ text: String(substituteParams(x.mes)), hash: getStringHash(substituteParams(x.mes)), index: chat.indexOf(x) }))
|
||||||
.filter(x => x.text)
|
.filter(x => x.text)
|
||||||
.reverse()
|
.reverse()
|
||||||
.slice(0, settings.query);
|
.slice(0, settings.query);
|
||||||
|
Reference in New Issue
Block a user