mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-01-05 10:08:52 +01:00
customGpts persist through localStorage
This commit is contained in:
parent
62bb6ea8f8
commit
9c3a78f96b
22 changed files with 405 additions and 220 deletions
|
|
@ -20,6 +20,7 @@ app.get('/', function (req, res) {
|
|||
app.use('/ask', routes.ask);
|
||||
app.use('/messages', routes.messages);
|
||||
app.use('/convos', routes.convos);
|
||||
app.use('/customGpts', routes.customGpts);
|
||||
app.use('/prompts', routes.prompts);
|
||||
|
||||
app.listen(port, () => {
|
||||
|
|
|
|||
|
|
@ -120,6 +120,15 @@ router.post('/', async (req, res) => {
|
|||
gptResponse.sender = model === 'chatgptCustom' ? chatGptLabel : model;
|
||||
gptResponse.final = true;
|
||||
gptResponse.text = await detectCode(gptResponse.text);
|
||||
|
||||
if (chatGptLabel?.length > 0 && model === 'chatgptCustom') {
|
||||
gptResponse.chatGptLabel = chatGptLabel;
|
||||
}
|
||||
|
||||
if (promptPrefix?.length > 0 && model === 'chatgptCustom') {
|
||||
gptResponse.promptPrefix = promptPrefix;
|
||||
}
|
||||
|
||||
await saveMessage(gptResponse);
|
||||
await saveConvo(gptResponse);
|
||||
sendMessage(res, gptResponse);
|
||||
|
|
|
|||
56
server/routes/customGpts.js
Normal file
56
server/routes/customGpts.js
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const { getCustomGpts, updateCustomGpt, deleteCustomGpts } = require('../../models');
|
||||
|
||||
router.get('/', async (req, res) => {
|
||||
const models = (await getCustomGpts()).map(model => {
|
||||
model = model.toObject();
|
||||
model._id = model._id.toString();
|
||||
return model;
|
||||
});
|
||||
// console.log(models);
|
||||
res.status(200).send(models);
|
||||
});
|
||||
|
||||
router.post('/delete/:_id', async (req, res) => {
|
||||
const { _id } = req.params;
|
||||
let filter = {};
|
||||
|
||||
if (_id) {
|
||||
filter = { _id };
|
||||
}
|
||||
|
||||
try {
|
||||
const dbResponse = await deleteCustomGpts(filter);
|
||||
res.status(201).send(dbResponse);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
res.status(500).send(error);
|
||||
}
|
||||
});
|
||||
|
||||
// router.post('/create', async (req, res) => {
|
||||
// const payload = req.body.arg;
|
||||
|
||||
// try {
|
||||
// const dbResponse = await createCustomGpt(payload);
|
||||
// res.status(201).send(dbResponse);
|
||||
// } catch (error) {
|
||||
// console.error(error);
|
||||
// res.status(500).send(error);
|
||||
// }
|
||||
// });
|
||||
|
||||
router.post('/', async (req, res) => {
|
||||
const update = req.body.arg;
|
||||
|
||||
try {
|
||||
const dbResponse = await updateCustomGpt(update);
|
||||
res.status(201).send(dbResponse);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
res.status(500).send(error);
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = router;
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
const ask = require('./ask');
|
||||
const messages = require('./messages');
|
||||
const convos = require('./convos');
|
||||
const customGpts = require('./customGpts');
|
||||
const prompts = require('./prompts');
|
||||
|
||||
module.exports = { ask, messages, convos, prompts };
|
||||
module.exports = { ask, messages, convos, customGpts, prompts };
|
||||
Loading…
Add table
Add a link
Reference in a new issue