import { useEffect, useState } from 'react'; import TextareaAutosize from 'react-textarea-autosize'; import { Label } from '~/components/ui/Label.tsx'; import { Checkbox } from '~/components/ui/Checkbox.tsx'; import SelectDropDown from '../../ui/SelectDropDown'; import { cn } from '~/utils/'; import useDebounce from '~/hooks/useDebounce'; import { useUpdateTokenCountMutation } from '@librechat/data-provider'; import { useRecoilValue } from 'recoil'; import store from '~/store'; import { localize } from '~/localization/Translation'; const defaultTextProps = 'rounded-md border border-gray-200 focus:border-slate-400 focus:bg-gray-50 bg-transparent text-sm shadow-[0_0_10px_rgba(0,0,0,0.05)] outline-none placeholder:text-gray-400 focus:outline-none focus:ring-gray-400 focus:ring-opacity-20 focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 dark:border-gray-500 dark:bg-gray-700 focus:dark:bg-gray-600 dark:text-gray-50 dark:shadow-[0_0_15px_rgba(0,0,0,0.10)] dark:focus:border-gray-400 dark:focus:outline-none dark:focus:ring-0 dark:focus:ring-gray-400 dark:focus:ring-offset-0'; function Settings(props) { const { readonly, context, systemMessage, jailbreak, toneStyle, setOption } = props; const [tokenCount, setTokenCount] = useState(0); const showSystemMessage = jailbreak; const setContext = setOption('context'); const setSystemMessage = setOption('systemMessage'); const setJailbreak = setOption('jailbreak'); const setToneStyle = (value) => setOption('toneStyle')(value.toLowerCase()); const debouncedContext = useDebounce(context, 250); const updateTokenCountMutation = useUpdateTokenCountMutation(); const lang = useRecoilValue(store.lang); useEffect(() => { if (!debouncedContext || debouncedContext.trim() === '') { setTokenCount(0); return; } const handleTextChange = (context) => { updateTokenCountMutation.mutate( { text: context }, { onSuccess: (data) => { setTokenCount(data.count); }, }, ); }; handleTextChange(debouncedContext); // eslint-disable-next-line react-hooks/exhaustive-deps }, [debouncedContext]); return (