mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 00:40:14 +01:00
fix: use universal setToneStyle
This commit is contained in:
parent
0c4b754fba
commit
010d900c90
2 changed files with 7 additions and 13 deletions
|
|
@ -18,15 +18,16 @@ 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';
|
'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';
|
||||||
|
|
||||||
function Settings(props) {
|
function Settings(props) {
|
||||||
const { readonly, context, systemMessage, jailbreak, toneStyle, setOption, setToneStyle } = props;
|
const { readonly, context, systemMessage, jailbreak, toneStyle, setOption } = props;
|
||||||
const [tokenCount, setTokenCount] = useState(0);
|
const [tokenCount, setTokenCount] = useState(0);
|
||||||
const showSystemMessage = jailbreak;
|
const showSystemMessage = jailbreak;
|
||||||
const setContext = setOption('context');
|
const setContext = setOption('context');
|
||||||
const setSystemMessage = setOption('systemMessage');
|
const setSystemMessage = setOption('systemMessage');
|
||||||
const setJailbreak = setOption('jailbreak');
|
const setJailbreak = setOption('jailbreak');
|
||||||
|
const setToneStyle = value => setOption('toneStyle')(value.toLowerCase());
|
||||||
|
|
||||||
// useEffect to update token count
|
// useEffect to update token count
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!context || context.trim() === '') {
|
if (!context || context.trim() === '') {
|
||||||
setTokenCount(0);
|
setTokenCount(0);
|
||||||
|
|
@ -37,7 +38,7 @@ function Settings(props) {
|
||||||
const handleTextChange = context => {
|
const handleTextChange = context => {
|
||||||
debouncedPost({
|
debouncedPost({
|
||||||
url: '/api/tokenizer',
|
url: '/api/tokenizer',
|
||||||
arg: { text: context},
|
arg: { text: context },
|
||||||
callback: data => {
|
callback: data => {
|
||||||
setTokenCount(data.count);
|
setTokenCount(data.count);
|
||||||
}
|
}
|
||||||
|
|
@ -45,7 +46,7 @@ function Settings(props) {
|
||||||
};
|
};
|
||||||
|
|
||||||
handleTextChange(context);
|
handleTextChange(context);
|
||||||
return () => debouncedPost.cancel();
|
return () => debouncedPost.cancel();
|
||||||
}, [context]);
|
}, [context]);
|
||||||
|
|
||||||
// console.log('data', data);
|
// console.log('data', data);
|
||||||
|
|
@ -83,9 +84,7 @@ function Settings(props) {
|
||||||
'flex max-h-[300px] min-h-[100px] w-full resize-none px-3 py-2'
|
'flex max-h-[300px] min-h-[100px] w-full resize-none px-3 py-2'
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
<small className="mb-5 text-black dark:text-white">
|
<small className="mb-5 text-black dark:text-white">{`Token count: ${tokenCount}`}</small>
|
||||||
{`Token count: ${tokenCount}`}
|
|
||||||
</small>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="col-span-1 flex flex-col items-center justify-start gap-6">
|
<div className="col-span-1 flex flex-col items-center justify-start gap-6">
|
||||||
|
|
|
||||||
|
|
@ -28,10 +28,6 @@ function BingAIOptions() {
|
||||||
if (endpoint !== 'bingAI') return null;
|
if (endpoint !== 'bingAI') return null;
|
||||||
if (conversationId !== 'new') return null;
|
if (conversationId !== 'new') return null;
|
||||||
|
|
||||||
const changeHandler = value => {
|
|
||||||
setConversation(prevState => ({ ...prevState, toneStyle: value.toLowerCase() }));
|
|
||||||
};
|
|
||||||
|
|
||||||
const triggerAdvancedMode = () => setAdvancedMode(prev => !prev);
|
const triggerAdvancedMode = () => setAdvancedMode(prev => !prev);
|
||||||
|
|
||||||
const switchToSimpleMode = () => {
|
const switchToSimpleMode = () => {
|
||||||
|
|
@ -78,7 +74,7 @@ function BingAIOptions() {
|
||||||
cardStyle +
|
cardStyle +
|
||||||
' z-50 flex h-[40px] items-center justify-center px-0 hover:bg-slate-50 dark:hover:bg-gray-600'
|
' z-50 flex h-[40px] items-center justify-center px-0 hover:bg-slate-50 dark:hover:bg-gray-600'
|
||||||
}
|
}
|
||||||
onValueChange={changeHandler}
|
onValueChange={value => setOption('toneStyle')(value.toLowerCase())}
|
||||||
>
|
>
|
||||||
<TabsList className="bg-white/[.60] dark:bg-gray-700">
|
<TabsList className="bg-white/[.60] dark:bg-gray-700">
|
||||||
<TabsTrigger
|
<TabsTrigger
|
||||||
|
|
@ -126,7 +122,6 @@ function BingAIOptions() {
|
||||||
systemMessage={systemMessage}
|
systemMessage={systemMessage}
|
||||||
jailbreak={jailbreak}
|
jailbreak={jailbreak}
|
||||||
toneStyle={toneStyle}
|
toneStyle={toneStyle}
|
||||||
setToneStyle={changeHandler}
|
|
||||||
setOption={setOption}
|
setOption={setOption}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue