import React, { useRef, useState } from 'react'; import TextareaAutosize from 'react-textarea-autosize'; import { Input } from '~/components/ui/Input.tsx'; import { Label } from '~/components/ui/Label.tsx'; import { Slider } from '~/components/ui/Slider.tsx'; import { cn } from '~/utils/'; const defaultTextProps = 'rounded-md border border-gray-300 bg-transparent text-sm shadow-[0_0_10px_rgba(0,0,0,0.10)] 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-none dark:bg-gray-700 dark:text-gray-50 dark:shadow-[0_0_15px_rgba(0,0,0,0.10)] dark:focus:border-none dark:focus:border-transparent dark:focus:outline-none dark:focus:ring-0 dark:focus:ring-gray-400 dark:focus:ring-offset-0'; const optionText = 'p-0 shadow-none text-right pr-1 h-8'; function Settings() { const [chatGptLabel, setChatGptLabel] = useState(''); const [promptPrefix, setPromptPrefix] = useState(''); const [temperature, setTemperature] = useState(1); const [maxLength, setMaxLength] = useState(2048); const [topP, setTopP] = useState(1); const [freqP, setFreqP] = useState(0); const [presP, setPresP] = useState(0); const textareaRef = useRef(null); const inputRef = useRef(null); // return (
{/* Note: important instructions are often better placed in your message rather than the prefix.{' '} More info here */}
setChatGptLabel(e.target.value)} placeholder="Set a custom name for ChatGPT" className=" col-span-3 shadow-[0_0_10px_rgba(0,0,0,0.10)] outline-none placeholder:text-gray-400 dark:bg-gray-700 dark:text-gray-50 dark:shadow-[0_0_15px_rgba(0,0,0,0.10)]" />
setPromptPrefix(e.target.value)} placeholder="Set custom instructions. Defaults to: 'You are ChatGPT, a large language model trained by OpenAI.'" className={cn(defaultTextProps, 'col-span-3 flex h-10 max-h-10 w-full resize-none px-3 py-2 ')} onFocus={() => { textareaRef.current.classList.remove('max-h-10'); textareaRef.current.classList.add('max-h-52'); }} onBlur={() => { textareaRef.current.classList.remove('max-h-52'); textareaRef.current.classList.add('max-h-10'); }} ref={textareaRef} />
setTemperature(e.target.value)} placeholder="1.0" className={cn(defaultTextProps, `w-9 ${optionText}`)} />
setMaxLength(e.target.value)} placeholder="1.0" className={cn(defaultTextProps, `w-11 ${optionText}`)} />
setTemperature(value)} max={2} min={0} step={0.01} className="w-full" /> setMaxLength(value)} max={2048} min={1} step={1} className="w-full" />
setTopP(e.target.value)} placeholder="1.0" className={cn(defaultTextProps, `w-9 ${optionText}`)} />
setFreqP(e.target.value)} placeholder="1.0" className={cn(defaultTextProps, `w-9 ${optionText}`)} />
setTopP(value)} max={2} min={0} step={0.01} className="w-full" /> setFreqP(value)} max={2} min={0} step={0.01} className="w-full" />
); } export default Settings;