diff --git a/models/Conversation.js b/models/Conversation.js
index c0387f54f1..329bd82d80 100644
--- a/models/Conversation.js
+++ b/models/Conversation.js
@@ -56,7 +56,7 @@ module.exports = {
return { message: 'Error updating conversation' };
}
},
- getConvos: async () => await Conversation.find({}).exec(),
+ getConvos: async () => await Conversation.find({}).sort({ created: -1 }).exec(),
deleteConvos: async (filter) => {
let deleteCount = await Conversation.deleteMany(filter).exec();
diff --git a/server/index.js b/server/index.js
index 2469632fb0..4dcc5cfa01 100644
--- a/server/index.js
+++ b/server/index.js
@@ -69,12 +69,17 @@ app.post('/update_convo', async (req, res) => {
});
app.post('/ask', async (req, res) => {
- console.log(req.body);
const { text, parentMessageId, conversationId } = req.body;
+ if (!text.trim().includes(' ') && text.length < 5) {
+ res.status(500).write('Prompt empty or too short');
+ res.end();
+ return;
+ }
+
const userMessageId = crypto.randomUUID();
let userMessage = { id: userMessageId, sender: 'User', text };
- console.log(userMessage, req.body);
+ console.log('initial ask log', userMessage);
res.writeHead(200, {
Connection: 'keep-alive',
diff --git a/src/components/Conversations/Conversation.jsx b/src/components/Conversations/Conversation.jsx
index 4dfa96006b..a1f088e3b4 100644
--- a/src/components/Conversations/Conversation.jsx
+++ b/src/components/Conversations/Conversation.jsx
@@ -1,19 +1,18 @@
import React, { useState, useRef } from 'react';
import RenameButton from './RenameButton';
import DeleteButton from './DeleteButton';
-import { useSelector, useDispatch } from 'react-redux';
+import { useDispatch } from 'react-redux';
import { setConversation } from '~/store/convoSlice';
import { setMessages } from '~/store/messageSlice';
import { setText } from '~/store/textSlice';
import manualSWR from '~/utils/fetchers';
import ConvoIcon from '../svg/ConvoIcon';
-export default function Conversation({ id, parentMessageId, title = 'New conversation' }) {
+export default function Conversation({ id, parentMessageId, conversationId, title = 'New conversation' }) {
const [renaming, setRenaming] = useState(false);
const [titleInput, setTitleInput] = useState(title);
const inputRef = useRef(null);
const dispatch = useDispatch();
- const { conversationId } = useSelector((state) => state.convo);
const { trigger, isMutating } = manualSWR(`http://localhost:3050/messages/${id}`, 'get');
const rename = manualSWR(`http://localhost:3050/update_convo`, 'post');
@@ -72,7 +71,7 @@ export default function Conversation({ id, parentMessageId, title = 'New convers
{...aProps}
>
-
+
{renaming === true ? (
state.convo);
+ // const currentRef = useRef(null);
+
+ // const scrollToTop = () => {
+ // currentRef.current?.scrollIntoView({ behavior: 'smooth' });
+ // };
+
+ // // this useEffect triggers the following warning in the Messages component (but not here):
+ // // Warning: Internal React error: Expected static flag was missing.
+ // useEffect(() => {
+ // scrollToTop();
+ // }, [conversationId]);
+
return (
+ {/*
*/}
{conversations &&
conversations.map((convo, i) => (
))}
{conversations && conversations.length >= 12 && (
diff --git a/src/components/Nav/index.jsx b/src/components/Nav/index.jsx
index a11cbe2cd4..631ec0b3e2 100644
--- a/src/components/Nav/index.jsx
+++ b/src/components/Nav/index.jsx
@@ -3,7 +3,7 @@ import NewChat from './NewChat';
import Conversations from '../Conversations';
import NavLinks from './NavLinks';
-export default function Nav({ conversations }) {
+export default function Nav({ conversations, conversationId }) {
return (
diff --git a/src/components/Prompts/Templates.jsx b/src/components/Prompts/Templates.jsx
index 409fa1c98d..a2e0f93e99 100644
--- a/src/components/Prompts/Templates.jsx
+++ b/src/components/Prompts/Templates.jsx
@@ -1,7 +1,7 @@
import React from 'react';
import ChatIcon from '../svg/ChatIcon';
-export default function Templates() {
+export default function Templates({ showTemplates }) {
return (
- Showing -4{' '}
- to 0 of{' '}
+ Showing 1 of{' '}
- 0 Entries
+ 1 Entries
+
- Use prompt →
+ Use prompt →
);
diff --git a/src/components/main/Message.jsx b/src/components/main/Message.jsx
index 07cc7ac46a..b370a592c5 100644
--- a/src/components/main/Message.jsx
+++ b/src/components/main/Message.jsx
@@ -40,7 +40,7 @@ export default function Message({ sender, text, last = false, error = false }) {
) : (
{text}
- {isSubmitting && last && sender === 'GPT' && █}
+ {isSubmitting && last && sender === 'GPT' && █}
)}
diff --git a/src/components/main/Regenerate.jsx b/src/components/main/Regenerate.jsx
index 6c0eb573cb..b08b90db40 100644
--- a/src/components/main/Regenerate.jsx
+++ b/src/components/main/Regenerate.jsx
@@ -1,7 +1,7 @@
import React from 'react';
import RegenerateIcon from '../svg/RegenerateIcon';
-export default function Regenerate({ submitMessage, tryAgain }) {
+export default function Regenerate({ submitMessage, tryAgain, errorMessage }) {
const clickHandler = (e) => {
e.preventDefault();
submitMessage();
@@ -9,18 +9,23 @@ export default function Regenerate({ submitMessage, tryAgain }) {
return (
<>
-
+
There was an error generating a response
+ {!errorMessage.includes('short') && (
+
+
+ Regenerate response
+
+ )}
-
- Regenerate response
-
-
Try another message
diff --git a/src/components/main/TextChat.jsx b/src/components/main/TextChat.jsx
index 7ab532cc71..44a4fd0103 100644
--- a/src/components/main/TextChat.jsx
+++ b/src/components/main/TextChat.jsx
@@ -10,6 +10,7 @@ import { setSubmitState } from '~/store/submitSlice';
import { setText } from '~/store/textSlice';
export default function TextChat({ messages, reloadConvos }) {
+ const [errorMessage, setErrorMessage] = useState('');
const dispatch = useDispatch();
const convo = useSelector((state) => state.convo);
const { isSubmitting } = useSelector((state) => state.submit);
@@ -35,8 +36,8 @@ export default function TextChat({ messages, reloadConvos }) {
};
const convoHandler = (data) => {
if (convo.conversationId === null && convo.parentMessageId === null) {
- const { conversationId, parentMessageId } = data;
- dispatch(setConversation({ conversationId, parentMessageId: data.id }));
+ const { title, conversationId, parentMessageId } = data;
+ dispatch(setConversation({ title, conversationId, parentMessageId: data.id }));
}
reloadConvos();
@@ -50,6 +51,7 @@ export default function TextChat({ messages, reloadConvos }) {
text: `An error occurred. Please try again in a few moments.\n\nError message: ${event.data}`,
error: true
};
+ setErrorMessage(event.data);
dispatch(setSubmitState(false));
dispatch(setMessages([...messages.slice(0, -2), currentMsg, errorResponse]));
dispatch(setText(payload));
@@ -105,6 +107,7 @@ export default function TextChat({ messages, reloadConvos }) {
) : (
diff --git a/src/style.css b/src/style.css
index 33abac2be7..d4c791cc89 100644
--- a/src/style.css
+++ b/src/style.css
@@ -14,9 +14,30 @@
0% {
opacity: 1;
}
+ 50% {
+ opacity: 0;
+ }
+ 100% {
+ opacity: 1;
+ }
+}
+
+.cursorBlink {
+ animation: blink 1.5s linear infinite;
+}
+@keyframes blink {
+ 0% {
+ opacity: 1;
+ }
+ 79% {
+ opacity: 1;
+ }
80% {
opacity: 0;
}
+ 99% {
+ opacity: 0;
+ }
100% {
opacity: 1;
}