From 1103aba184df720cf7f5243688397cc5703e7692 Mon Sep 17 00:00:00 2001 From: Zihao Zhou Date: Wed, 24 Apr 2024 09:13:59 +0000 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Tune=20for=20Poe?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Chat/ChatContent/ChatTitle.tsx | 76 +++++++++++------- src/components/ConfigMenu/ConfigMenu.tsx | 6 +- src/components/Menu/Menu.tsx | 2 +- src/components/TokenCount/TokenCount.tsx | 2 +- src/constants/chat.ts | 79 ++++++++++++++++--- src/hooks/useSubmit.ts | 9 ++- src/types/chat.ts | 17 +++- tailwind.config.cjs | 1 + 8 files changed, 143 insertions(+), 49 deletions(-) diff --git a/src/components/Chat/ChatContent/ChatTitle.tsx b/src/components/Chat/ChatContent/ChatTitle.tsx index 4130b0ee1..836228140 100644 --- a/src/components/Chat/ChatContent/ChatTitle.tsx +++ b/src/components/Chat/ChatContent/ChatTitle.tsx @@ -3,7 +3,8 @@ import { useTranslation } from 'react-i18next'; import { shallow } from 'zustand/shallow'; import useStore from '@store/store'; import ConfigMenu from '@components/ConfigMenu'; -import { ChatInterface, ConfigInterface } from '@type/chat'; +import { ModelSelector } from '@components/ConfigMenu/ConfigMenu'; +import { ChatInterface, ConfigInterface, ModelOptions } from '@type/chat'; import { _defaultChatConfig } from '@constants/chat'; const ChatTitle = React.memo(() => { @@ -40,31 +41,52 @@ const ChatTitle = React.memo(() => { } }, [currentChatIndex]); + const [_model, _setModel] = useState(config?.model ?? _defaultChatConfig.model); + useEffect(() => { + // Assuming 'config' contains the current configuration + // and '_model' is the updated model state from the local component state: + if (config) { + setConfig({ + ...config, // This spreads the current config. + model: _model // This overwrites 'model' with the updated state. + }); + } + }, [_model, config, setConfig]); + return config ? ( <>
{ - setIsModalOpen(true); - }} + className='flex gap-x-4 gap-y-1 w-full items-center justify-center border-b border-black/10 bg-gray-50 p-3 dark:border-gray-900/50 dark:bg-gray-700 text-gray-600 dark:text-gray-300 sticky top-0 z-10' + // Added sticky, top-0, and z-10 to make the chat title stick to the top + // Removed flex-wrap to avoid wrapping > -
- {t('model')}: {config.model} -
-
- {t('token.label')}: {config.max_tokens} -
-
- {t('temperature.label')}: {config.temperature} -
-
- {t('topP.label')}: {config.top_p} -
-
- {t('presencePenalty.label')}: {config.presence_penalty} -
-
- {t('frequencyPenalty.label')}: {config.frequency_penalty} + {/* ModelSelector is used here instead of displaying the model as text */} + + {/* Wrapping the rest of the divs so they can open the modal */} +
{ + setIsModalOpen(true); + }} + className='cursor-pointer flex gap-x-4' // Add flex and gap-x-4 to align the buttons in a row + > +
+ {t('token.label')}: {config.max_tokens} +
+
+ {t('temperature.label')}: {config.temperature} +
+
+ {t('topP.label')}: {config.top_p} +
+
+ {t('presencePenalty.label')}: {config.presence_penalty} +
+
+ {t('frequencyPenalty.label')}: {config.frequency_penalty} +
{isModalOpen && ( @@ -75,9 +97,7 @@ const ChatTitle = React.memo(() => { /> )} - ) : ( - <> - ); -}); - -export default ChatTitle; + ) : null; // Use null for no-render instead of <> + }); + + export default ChatTitle; \ No newline at end of file diff --git a/src/components/ConfigMenu/ConfigMenu.tsx b/src/components/ConfigMenu/ConfigMenu.tsx index 52f5c396a..1b6302a27 100644 --- a/src/components/ConfigMenu/ConfigMenu.tsx +++ b/src/components/ConfigMenu/ConfigMenu.tsx @@ -47,7 +47,9 @@ const ConfigMenu = ({ handleClickBackdrop={handleConfirm} >
- +
+ +
(false); return ( -
+