Merge pull request #3727 from Erquint/staging

Chat titles are now included in the search. Query terms don't have to occur in the same message anymore.
This commit is contained in:
Cohee
2025-03-19 19:32:21 +02:00
committed by GitHub
+4 -5
View File
@@ -783,12 +783,11 @@ router.post('/search', validateAvatarUrlMiddleware, function (request, response)
continue;
}
// Search through messages
// Search through title and messages of the chat
const fragments = query.trim().toLowerCase().split(/\s+/).filter(x => x);
const hasMatch = messages.some(message => {
const text = message?.mes?.toLowerCase();
return text && fragments.every(fragment => text.includes(fragment));
});
const text = [chatFile.path.split(/[\\/]/).pop().replace(/.jsonl$/, ''),
...messages.map(message => message?.mes)].join('\n').toLowerCase();
const hasMatch = fragments.every(fragment => text.includes(fragment));
if (hasMatch) {
results.push({