Prepend title to chat messages array before concatenating the string.

bbdd98a15527270f26b7afe2bdd03ff9546b6c23

Gness Erquint <gness.na@gmail.com>

1 files changed, +3 -3Showing whitespace changes
src/endpoints/chats.js+3 -3
@@ -785,9 +785,9 @@ router.post('/search', validateAvatarUrlMiddleware, function (request, response)
785785
786786 // Search through chats
787787 const fragments = query.trim().toLowerCase().split(/\s+/).filter(x => x);
788- const text = messages.map(message => message?.mes).join("\n").toLowerCase();
788+ const text = [chatFile.path.split(/[\\\/]/).pop().replace(/.jsonl$/, ''),
789- const stem = chatFile.path.toLowerCase().split(/[\\\/]/).pop().replace(/.jsonl$/, '');
789+ ...messages.map(message => message?.mes)].join("\n").toLowerCase();
790790 const hasMatch = fragments.every(fragment => (stem + text).includes(fragment));
791791
792792 if (hasMatch) {
793793 results.push({