From e434b3afea28b5d39f57eaeefc8180e60f38fb02 Mon Sep 17 00:00:00 2001 From: Danny Avila Date: Tue, 28 Mar 2023 08:10:22 -0400 Subject: [PATCH 1/4] fix: set max height on customgpt prompt prefix --- client/src/components/Models/ModelDialog.jsx | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/client/src/components/Models/ModelDialog.jsx b/client/src/components/Models/ModelDialog.jsx index 122bf6688a..984cb7ba4d 100644 --- a/client/src/components/Models/ModelDialog.jsx +++ b/client/src/components/Models/ModelDialog.jsx @@ -19,7 +19,7 @@ import { export default function ModelDialog({ mutate, setModelSave, handleSaveState }) { const dispatch = useDispatch(); - const { modelMap, initial } = useSelector((state) => state.models); + const { modelMap, initial } = useSelector(state => state.models); const [chatGptLabel, setChatGptLabel] = useState(''); const [promptPrefix, setPromptPrefix] = useState(''); const [saveText, setSaveText] = useState('Save'); @@ -27,7 +27,7 @@ export default function ModelDialog({ mutate, setModelSave, handleSaveState }) { const inputRef = useRef(null); const updateCustomGpt = manualSWR(`/api/customGpts/`, 'post'); - const selectHandler = (e) => { + const selectHandler = e => { if (chatGptLabel.length === 0) { e.preventDefault(); setRequired(true); @@ -42,7 +42,7 @@ export default function ModelDialog({ mutate, setModelSave, handleSaveState }) { dispatch(setSubmission({})); }; - const saveHandler = (e) => { + const saveHandler = e => { e.preventDefault(); setModelSave(true); const value = chatGptLabel.toLowerCase(); @@ -56,7 +56,7 @@ export default function ModelDialog({ mutate, setModelSave, handleSaveState }) { updateCustomGpt.trigger({ value, chatGptLabel, promptPrefix }); mutate(); - setSaveText((prev) => prev + 'd!'); + setSaveText(prev => prev + 'd!'); setTimeout(() => { setSaveText('Save'); }, 2500); @@ -84,8 +84,7 @@ export default function ModelDialog({ mutate, setModelSave, handleSaveState }) { Customize ChatGPT - Note: important instructions are often better placed in your message rather than the - prefix.{' '} + Note: important instructions are often better placed in your message rather than the prefix.{' '} setChatGptLabel(e.target.value)} + onChange={e => setChatGptLabel(e.target.value)} placeholder="Set a custom name for ChatGPT" className=" col-span-3 shadow-[0_0_10px_rgba(0,0,0,0.10)] outline-none placeholder:text-gray-400 invalid:border-red-400 invalid:text-red-600 invalid:placeholder-red-600 invalid:placeholder-opacity-70 invalid:ring-opacity-10 focus:ring-0 focus:invalid:border-red-400 focus:invalid:ring-red-300 dark:border-none dark:bg-gray-700 dark:text-gray-50 dark:shadow-[0_0_15px_rgba(0,0,0,0.10)] dark:invalid:border-red-600 dark:invalid:text-red-300 dark:invalid:placeholder-opacity-80 dark:focus:border-none dark:focus:border-transparent dark:focus:outline-none dark:focus:ring-0 dark:focus:ring-gray-400 dark:focus:ring-offset-0 dark:focus:invalid:ring-red-600 dark:focus:invalid:ring-opacity-50" @@ -124,9 +123,9 @@ export default function ModelDialog({ mutate, setModelSave, handleSaveState }) { setPromptPrefix(e.target.value)} + onChange={e => setPromptPrefix(e.target.value)} placeholder="Set custom instructions. Defaults to: 'You are ChatGPT, a large language model trained by OpenAI.'" - className="col-span-3 flex h-20 w-full resize-none rounded-md border border-gray-300 bg-transparent py-2 px-3 text-sm shadow-[0_0_10px_rgba(0,0,0,0.10)] outline-none placeholder:text-gray-400 focus:outline-none focus:ring-gray-400 focus:ring-opacity-20 focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 dark:border-none dark:bg-gray-700 dark:text-gray-50 dark:shadow-[0_0_15px_rgba(0,0,0,0.10)] dark:focus:border-none dark:focus:border-transparent dark:focus:outline-none dark:focus:ring-0 dark:focus:ring-gray-400 dark:focus:ring-offset-0" + className="col-span-3 flex h-20 max-h-52 w-full resize-none rounded-md border border-gray-300 bg-transparent py-2 px-3 text-sm shadow-[0_0_10px_rgba(0,0,0,0.10)] outline-none placeholder:text-gray-400 focus:outline-none focus:ring-gray-400 focus:ring-opacity-20 focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 dark:border-none dark:bg-gray-700 dark:text-gray-50 dark:shadow-[0_0_15px_rgba(0,0,0,0.10)] dark:focus:border-none dark:focus:border-transparent dark:focus:outline-none dark:focus:ring-0 dark:focus:ring-gray-400 dark:focus:ring-offset-0" /> From 0fbbe744794d50c29d73e368a9c3a3a255cd75af Mon Sep 17 00:00:00 2001 From: Danny Avila Date: Tue, 28 Mar 2023 11:38:56 -0400 Subject: [PATCH 2/4] revert bing to last working state --- api/server/routes/askBing.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/api/server/routes/askBing.js b/api/server/routes/askBing.js index 535b580ed5..ffadc8a493 100644 --- a/api/server/routes/askBing.js +++ b/api/server/routes/askBing.js @@ -2,7 +2,7 @@ const express = require('express'); const crypto = require('crypto'); const router = express.Router(); const { titleConvo, askBing } = require('../../app/'); -const { saveBingMessage, getConvoTitle, saveConvo, updateConvo } = require('../../models'); +const { saveBingMessage, getConvoTitle, saveConvo } = require('../../models'); const { handleError, sendMessage, createOnProgress, handleText } = require('./handlers'); router.post('/', async (req, res) => { @@ -123,7 +123,7 @@ const ask = async ({ // Attition: the api will also create new conversationId while using invalid userMessage.parentMessageId, // but in this situation, don't change the conversationId, but create new convo. if (conversationId != userMessage.conversationId && isNewConversation) - await updateConvo( + await saveConvo( req?.session?.user?.username, { conversationId: conversationId, @@ -148,7 +148,7 @@ const ask = async ({ response.text = await handleText(response, true); await saveBingMessage(response); - await updateConvo(req?.session?.user?.username, { model, chatGptLabel: null, promptPrefix: null, ...convo, ...response }); + await saveConvo(req?.session?.user?.username, { model, chatGptLabel: null, promptPrefix: null, ...convo, ...response }); sendMessage(res, { title: await getConvoTitle(req?.session?.user?.username, conversationId), @@ -161,9 +161,11 @@ const ask = async ({ if (userParentMessageId == '00000000-0000-0000-0000-000000000000') { const title = await titleConvo({ model, text, response }); - await updateConvo( + await saveConvo( req?.session?.user?.username, { + ...convo, + ...response, conversationId, title } @@ -185,4 +187,4 @@ const ask = async ({ } }; -module.exports = router; +module.exports = router; \ No newline at end of file From 4564b648f7cc5a3286c6d7b326d608e43bc17bfb Mon Sep 17 00:00:00 2001 From: Danny Avila Date: Tue, 28 Mar 2023 11:42:36 -0400 Subject: [PATCH 3/4] fix: failsafe to prevent all convos clearing from delete button --- api/server/routes/convos.js | 8 +++++++- client/src/components/Conversations/DeleteButton.jsx | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/api/server/routes/convos.js b/api/server/routes/convos.js index 7b2f9c72f9..656caa0e1b 100644 --- a/api/server/routes/convos.js +++ b/api/server/routes/convos.js @@ -41,11 +41,17 @@ router.post('/gen_title', async (req, res) => { router.post('/clear', async (req, res) => { let filter = {}; - const { conversationId } = req.body.arg; + const { conversationId, source } = req.body.arg; if (conversationId) { filter = { conversationId }; } + console.log('source:', source); + + if (source === 'button' && !conversationId) { + return res.status(200).send('No conversationId provided'); + } + try { const dbResponse = await deleteConvos(req?.session?.user?.username, filter); res.status(201).send(dbResponse); diff --git a/client/src/components/Conversations/DeleteButton.jsx b/client/src/components/Conversations/DeleteButton.jsx index d2be57c4fc..79895169f1 100644 --- a/client/src/components/Conversations/DeleteButton.jsx +++ b/client/src/components/Conversations/DeleteButton.jsx @@ -21,7 +21,7 @@ export default function DeleteButton({ conversationId, renaming, cancelHandler, } ); - const clickHandler = () => trigger({ conversationId }); + const clickHandler = () => trigger({ conversationId, source: 'button' }); const handler = renaming ? cancelHandler : clickHandler; return ( From d9363b93c632791432024641e76423047657cdbe Mon Sep 17 00:00:00 2001 From: Danny Avila <110412045+danny-avila@users.noreply.github.com> Date: Tue, 28 Mar 2023 11:48:47 -0400 Subject: [PATCH 4/4] Create .github/FUNDING.yml --- .github/FUNDING.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 .github/FUNDING.yml diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000000..37ef799acb --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,13 @@ +# These are supported funding model platforms + +github: [danny-avila] +patreon: # Replace with a single Patreon username +open_collective: # Replace with a single Open Collective username +ko_fi: # Replace with a single Ko-fi username +tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel +community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry +liberapay: # Replace with a single Liberapay username +issuehunt: # Replace with a single IssueHunt username +otechie: # Replace with a single Otechie username +lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry +custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']