feat: return home page on any path

fix: clearConvo will remove all messages
This commit is contained in:
Wentao Lyu 2023-03-28 00:15:29 +08:00
parent 5b8483828b
commit 7d43032a98
3 changed files with 10 additions and 32 deletions

View file

@ -16,29 +16,6 @@ router.get('/:conversationId', async (req, res) => {
res.status(200).send(convo.toObject());
});
router.post('/gen_title', async (req, res) => {
const { conversationId } = req.body.arg;
const convo = await getConvo(req?.session?.user?.username, conversationId);
const firstMessage = (await getMessages({ conversationId }))[0];
const secondMessage = (await getMessages({ conversationId }))[1];
const title = convo.jailbreakConversationId
? await getConvoTitle(req?.session?.user?.username, conversationId)
: await titleConvo({
model: convo?.model,
message: firstMessage?.text,
response: JSON.stringify(secondMessage?.text || '')
});
await saveConvo(req?.session?.user?.username, {
conversationId,
title
});
res.status(200).send(title);
});
router.post('/clear', async (req, res) => {
let filter = {};
const { conversationId } = req.body.arg;