mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 08:50:15 +01:00
feat: return home page on any path
fix: clearConvo will remove all messages
This commit is contained in:
parent
5b8483828b
commit
7d43032a98
3 changed files with 10 additions and 32 deletions
|
|
@ -67,20 +67,21 @@ const projectPath = path.join(__dirname, '..', '..', 'client');
|
||||||
res.send(JSON.stringify({ hasOpenAI, hasChatGpt, hasBing }));
|
res.send(JSON.stringify({ hasOpenAI, hasChatGpt, hasBing }));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
app.get('/*', routes.authenticatedOrRedirect, function (req, res) {
|
||||||
|
res.sendFile(path.join(projectPath, 'public', 'index.html'));
|
||||||
|
});
|
||||||
|
|
||||||
app.listen(port, host, () => {
|
app.listen(port, host, () => {
|
||||||
if (host == '0.0.0.0')
|
if (host == '0.0.0.0')
|
||||||
console.log(
|
console.log(
|
||||||
`Server listening on all interface at port ${port}. Use http://localhost:${port} to access it`
|
`Server listening on all interface at port ${port}. Use http://localhost:${port} to access it`
|
||||||
);
|
);
|
||||||
else
|
else console.log(`Server listening at http://${host == '0.0.0.0' ? 'localhost' : host}:${port}`);
|
||||||
console.log(
|
|
||||||
`Server listening at http://${host == '0.0.0.0' ? 'localhost' : host}:${port}`
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
|
|
||||||
let messageCount = 0;
|
let messageCount = 0;
|
||||||
process.on('uncaughtException', (err) => {
|
process.on('uncaughtException', err => {
|
||||||
if (!err.message.includes('fetch failed')) {
|
if (!err.message.includes('fetch failed')) {
|
||||||
console.error('There was an uncaught error:', err.message);
|
console.error('There was an uncaught error:', err.message);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,29 +16,6 @@ router.get('/:conversationId', async (req, res) => {
|
||||||
res.status(200).send(convo.toObject());
|
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) => {
|
router.post('/clear', async (req, res) => {
|
||||||
let filter = {};
|
let filter = {};
|
||||||
const { conversationId } = req.body.arg;
|
const { conversationId } = req.body.arg;
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@
|
||||||
/>
|
/>
|
||||||
<script
|
<script
|
||||||
defer
|
defer
|
||||||
src="main.js"
|
src="/main.js"
|
||||||
></script>
|
></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
@ -34,7 +34,7 @@
|
||||||
|
|
||||||
<script
|
<script
|
||||||
type="text/javascript"
|
type="text/javascript"
|
||||||
src="main.js"
|
src="/main.js"
|
||||||
></script>
|
></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue