mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-09-22 06:00:56 +02:00
fix: correctly searches bing messages
This commit is contained in:
parent
a46ec62532
commit
34bef48e84
4 changed files with 14 additions and 10 deletions
|
@ -1,6 +1,6 @@
|
|||
const cleanUpPrimaryKeyValue = (value) => {
|
||||
// For Bing convoId handling
|
||||
return value.replace(/--/g, '-');
|
||||
return value.replace(/--/g, '|');
|
||||
};
|
||||
|
||||
function replaceSup(text) {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
const mergeSort = require('./mergeSort');
|
||||
const { cleanUpPrimaryKeyValue } = require('./misc');
|
||||
|
||||
function reduceMessages(hits) {
|
||||
const counts = {};
|
||||
|
@ -29,15 +30,16 @@ function reduceHits(hits, titles = []) {
|
|||
const convos = [...hits, ...titles];
|
||||
|
||||
for (const convo of convos) {
|
||||
if (!counts[convo.conversationId]) {
|
||||
counts[convo.conversationId] = 1;
|
||||
const currentId = cleanUpPrimaryKeyValue(convo.conversationId);
|
||||
if (!counts[currentId]) {
|
||||
counts[currentId] = 1;
|
||||
} else {
|
||||
counts[convo.conversationId]++;
|
||||
counts[currentId]++;
|
||||
}
|
||||
|
||||
if (convo.title) {
|
||||
// titleMap[convo.conversationId] = convo._formatted.title;
|
||||
titleMap[convo.conversationId] = convo.title;
|
||||
// titleMap[currentId] = convo._formatted.title;
|
||||
titleMap[currentId] = convo.title;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
// const { Conversation } = require('./plugins');
|
||||
const Conversation = require('./schema/convoSchema');
|
||||
const { cleanUpPrimaryKeyValue } = require('../lib/utils/misc');
|
||||
const { getMessages, deleteMessages } = require('./Message');
|
||||
|
||||
const getConvo = async (user, conversationId) => {
|
||||
|
@ -90,7 +89,7 @@ module.exports = {
|
|||
promises.push(
|
||||
Conversation.findOne({
|
||||
user,
|
||||
conversationId: cleanUpPrimaryKeyValue(convo.conversationId)
|
||||
conversationId: convo.conversationId,
|
||||
}).exec()
|
||||
)
|
||||
);
|
||||
|
|
|
@ -15,7 +15,8 @@ router.get('/sync', async function (req, res) {
|
|||
|
||||
router.get('/', async function (req, res) {
|
||||
try {
|
||||
const user = req?.session?.user?.username;
|
||||
let user = req?.session?.user?.username;
|
||||
user = user ?? null;
|
||||
const { q } = req.query;
|
||||
const pageNumber = req.query.pageNumber || 1;
|
||||
const key = `${user || ''}${q}`;
|
||||
|
@ -50,8 +51,10 @@ router.get('/', async function (req, res) {
|
|||
};
|
||||
});
|
||||
const titles = (await Conversation.meiliSearch(q)).hits;
|
||||
console.log('message hits:', messages.length, 'convo hits:', titles.length);
|
||||
const sortedHits = reduceHits(messages, titles);
|
||||
// debugging:
|
||||
// console.log('user:', user, 'message hits:', messages.length, 'convo hits:', titles.length);
|
||||
// console.log('sorted hits:', sortedHits.length);
|
||||
const result = await getConvosQueried(user, sortedHits, pageNumber);
|
||||
|
||||
const activeMessages = [];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue