mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2024-12-11 17:07:07 +01:00
Fix incorrect message counter
This commit is contained in:
parent
6e36b77f1a
commit
e0e60a1d00
@ -73,7 +73,7 @@ function formatBytes(bytes) {
|
|||||||
function getPreviewMessage(messages) {
|
function getPreviewMessage(messages) {
|
||||||
const strlen = 300;
|
const strlen = 300;
|
||||||
const lastMessage = messages[messages.length - 1]?.mes;
|
const lastMessage = messages[messages.length - 1]?.mes;
|
||||||
|
|
||||||
if (!lastMessage) {
|
if (!lastMessage) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
@ -609,13 +609,13 @@ router.post('/search', jsonParser, function (request, response) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const results = [];
|
const results = [];
|
||||||
|
|
||||||
// Search logic
|
// Search logic
|
||||||
for (const chatFile of chatFiles) {
|
for (const chatFile of chatFiles) {
|
||||||
const data = fs.readFileSync(chatFile.path, 'utf8');
|
const data = fs.readFileSync(chatFile.path, 'utf8');
|
||||||
const messages = data.split('\n')
|
const messages = data.split('\n')
|
||||||
.map(line => { try { return JSON.parse(line); } catch (_) { return null; } })
|
.map(line => { try { return JSON.parse(line); } catch (_) { return null; } })
|
||||||
.filter(x => x);
|
.filter(x => x && typeof x.mes === 'string');
|
||||||
|
|
||||||
if (messages.length === 0) {
|
if (messages.length === 0) {
|
||||||
continue;
|
continue;
|
||||||
@ -662,4 +662,4 @@ router.post('/search', jsonParser, function (request, response) {
|
|||||||
console.error('Chat search error:', error);
|
console.error('Chat search error:', error);
|
||||||
return response.status(500).json({ error: 'Search failed' });
|
return response.status(500).json({ error: 'Search failed' });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user