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 ( -
+