From 5d9bc10cf48322bd40f27f3e05e709c3e5d19246 Mon Sep 17 00:00:00 2001 From: Jiayao Yu Date: Sun, 26 Mar 2023 08:09:10 -0700 Subject: [PATCH] Allow switching GPT model in the middle of a conversation (#181) * Allow switching model in the middle of a conversation * Hide model selection menu behind a settings button * rename * Touch up the settings icon --- components/Chat/Chat.tsx | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/components/Chat/Chat.tsx b/components/Chat/Chat.tsx index 1cf1695..d4548c7 100644 --- a/components/Chat/Chat.tsx +++ b/components/Chat/Chat.tsx @@ -20,6 +20,7 @@ import { ChatMessage } from './ChatMessage'; import { ErrorMessageDiv } from './ErrorMessageDiv'; import { ModelSelect } from './ModelSelect'; import { SystemPrompt } from './SystemPrompt'; +import { IconSettings } from "@tabler/icons-react"; interface Props { conversation: Conversation; @@ -56,6 +57,7 @@ export const Chat: FC = ({ const { t } = useTranslation('chat'); const [currentMessage, setCurrentMessage] = useState(); const [autoScrollEnabled, setAutoScrollEnabled] = useState(true); + const [showSettings, setShowSettings] = useState(false); const messagesEndRef = useRef(null); const chatContainerRef = useRef(null); @@ -82,6 +84,10 @@ export const Chat: FC = ({ } }; + const handleSettings = () => { + setShowSettings(!showSettings); + }; + useEffect(() => { scrollToBottom(); setCurrentMessage(conversation.messages[conversation.messages.length - 2]); @@ -152,9 +158,21 @@ export const Chat: FC = ({ ) : ( <> -
- {t('Model')}: {conversation.model.name} +
+ {t('Model')}: {conversation.model.name} + +
+ {showSettings && ( +
+
+ onUpdateConversation(conversation, { key: "model", value: model })} + /> +
+ )} {conversation.messages.map((message, index) => (