diff --git a/client/src/components/Endpoints/OpenAI/Settings.jsx b/client/src/components/Endpoints/OpenAI/Settings.jsx index b4bd2b269c..054e9df6ad 100644 --- a/client/src/components/Endpoints/OpenAI/Settings.jsx +++ b/client/src/components/Endpoints/OpenAI/Settings.jsx @@ -1,6 +1,7 @@ import React from 'react'; +import { useRecoilValue } from 'recoil'; import TextareaAutosize from 'react-textarea-autosize'; -import ModelDropDown from '../../ui/ModelDropDown'; +import SelectDropDown from '../../ui/SelectDropDown'; import { Input } from '~/components/ui/Input.tsx'; import { Label } from '~/components/ui/Label.tsx'; import { Slider } from '~/components/ui/Slider.tsx'; @@ -14,9 +15,13 @@ const defaultTextProps = const optionText = 'p-0 shadow-none text-right pr-1 h-8 border-transparent focus:ring-[#10a37f] focus:ring-offset-0 focus:ring-opacity-100 hover:bg-gray-800/10 dark:hover:bg-white/10 focus:bg-gray-800/10 dark:focus:bg-white/10 transition-colors'; +import store from '~/store'; + function Settings(props) { const { readonly, model, chatGptLabel, promptPrefix, temperature, topP, freqP, presP, setOption } = props; + const endpointsConfig = useRecoilValue(store.endpointsConfig); + const setModel = setOption('model'); const setChatGptLabel = setOption('chatGptLabel'); const setPromptPrefix = setOption('promptPrefix'); @@ -25,16 +30,18 @@ function Settings(props) { const setFreqP = setOption('presence_penalty'); const setPresP = setOption('frequency_penalty'); + const models = endpointsConfig?.['openAI']?.['availableModels'] || []; + return ( <>
- ({ ...prevState, context: null, - systemMessage: null, - jailbreak: null + systemMessage: null })); setAdvancedMode(false); }; @@ -68,6 +68,19 @@ function BingAIOptions() { (!advancedMode ? ' show' : '') } > + setOption('jailbreak')(value === 'Sydney')} + availableValues={['BingAI', 'Sydney']} + showAbove={true} + showLabel={false} + className={cn( + cardStyle, + 'min-w-36 z-50 flex h-[40px] w-36 items-center justify-center px-4 ring-0 hover:cursor-pointer hover:bg-slate-50 focus:ring-0 focus:ring-offset-0 data-[state=open]:bg-slate-50 dark:bg-gray-700 dark:hover:bg-gray-600 dark:data-[state=open]:bg-gray-600' + )} + /> + { if (endpoint !== 'chatGPTBrowser') return; }, [conversation]); @@ -18,6 +19,8 @@ function ChatGPTOptions() { if (endpoint !== 'chatGPTBrowser') return null; if (conversationId !== 'new') return null; + const models = endpointsConfig?.['chatGPTBrowser']?.['availableModels'] || []; + const setOption = param => newValue => { let update = {}; update[param] = newValue; @@ -31,11 +34,11 @@ function ChatGPTOptions() { 'transition-colors shadow-md rounded-md min-w-[75px] font-normal bg-white border-black/10 hover:border-black/10 focus:border-black/10 dark:border-black/10 dark:hover:border-black/10 dark:focus:border-black/10 border dark:bg-gray-700 text-black dark:text-white'; return ( -
- + { if (endpoint !== 'openAI') return; @@ -37,6 +38,8 @@ function OpenAIOptions() { if (endpoint !== 'openAI') return null; if (conversationId !== 'new') return null; + const models = endpointsConfig?.['openAI']?.['availableModels'] || []; + const triggerAdvancedMode = () => setAdvancedMode(prev => !prev); const switchToSimpleMode = () => { @@ -86,10 +89,10 @@ function OpenAIOptions() { ' z-50 flex h-[40px] items-center justify-center px-4 hover:bg-slate-50 data-[state=open]:bg-slate-50 dark:hover:bg-gray-600 dark:data-[state=open]:bg-gray-600' )} /> */} -
{({ open }) => ( @@ -41,7 +37,7 @@ function ModelDropDown({ id="headlessui-listbox-label-:r1:" data-headlessui-state="" > - Model + {title} )} @@ -51,8 +47,8 @@ function ModelDropDown({ !showLabel ? 'text-xs' : '' )} > - {!showLabel && Model:} - {model} + {!showLabel && {title}:} + {value} @@ -82,22 +78,22 @@ function ModelDropDown({ className={showAbove ? 'bottom-full mb-3' : 'top-full mt-3'} > - {models.map((modelOption, i) => ( + {availableValues.map((option, i) => ( - {modelOption} + {option} - {modelOption === model && ( + {option === value && ( @@ -109,72 +105,10 @@ function ModelDropDown({ )} - - {/* - - - Model - - - - {model} - - - - - - - - - - {models.map((modelOption, i) => ( - - - - {modelOption} - - {modelOption === model && ( - - - - )} - - - ))} - */}
); } -export default ModelDropDown; +export default SelectDropDown; diff --git a/client/src/utils/cleanupPreset.js b/client/src/utils/cleanupPreset.js index 6040e47b53..bb63c6180c 100644 --- a/client/src/utils/cleanupPreset.js +++ b/client/src/utils/cleanupPreset.js @@ -22,10 +22,6 @@ const cleanupPreset = _preset => { jailbreak: _preset?.jailbreak || false, context: _preset?.context || null, systemMessage: _preset?.systemMessage || null, - jailbreakpresetId: _preset?._jailbreakpresetId || null, - presetSignature: null, - clientId: null, - invocationId: 1, toneStyle: _preset?.toneStyle || 'fast', title: _preset?.title || 'New Preset' }; diff --git a/client/src/utils/getDefaultConversation.js b/client/src/utils/getDefaultConversation.js index bb6fdea767..9434853a2a 100644 --- a/client/src/utils/getDefaultConversation.js +++ b/client/src/utils/getDefaultConversation.js @@ -16,13 +16,13 @@ const buildDefaultConversation = ({ conversation, endpoint, lastConversationSetu ...conversation, endpoint, jailbreak: lastConversationSetup?.jailbreak || false, - systemMessage: lastConversationSetup?.systemMessage || null, context: lastConversationSetup?.context || null, + systemMessage: lastConversationSetup?.systemMessage || null, + toneStyle: lastConversationSetup?.toneStyle || 'fast', jailbreakConversationId: lastConversationSetup?.jailbreakConversationId || null, conversationSignature: null, clientId: null, - invocationId: 1, - toneStyle: lastConversationSetup?.toneStyle || 'fast' + invocationId: 1 }; } else if (endpoint === 'chatGPTBrowser') { conversation = {