import React, { useEffect, useState } from 'react'; import { useRecoilState } from 'recoil'; import ModelSelect from './ModelSelect'; import { Button } from '../../ui/Button.tsx'; import store from '~/store'; function OpenAIOptions() { const [advancedMode, setAdvancedMode] = useState(false); const [conversation, setConversation] = useRecoilState(store.conversation) || {}; const { endpoint } = conversation; const triggerAdvancedMode = () => setAdvancedMode(prev => !prev); const switchToSimpleMode = () => { setConversation(prevState => ({ ...prevState, chatGptLabel: null, promptPrefix: null, temperature: 0.8, top_p: 1, presence_penalty: 1 })); setAdvancedMode(false); }; const setModel = newModel => { setConversation(prevState => ({ ...prevState, model: newModel })); }; useEffect(() => { const { endpoint, chatGptLabel, promptPrefix, temperature, top_p, presence_penalty } = conversation; if (endpoint !== 'openAI') return; const mustInAdvancedMode = chatGptLabel !== null || promptPrefix !== null || temperature !== 0.8 || top_p !== 1 || presence_penalty !== 1; if (mustInAdvancedMode && !advancedMode) setAdvancedMode(true); }, [conversation, advancedMode]); if (endpoint !== 'openAI') return null; const { model } = conversation; const cardStyle = 'shadow-md rounded-md min-w-[75px] font-normal bg-white border-black/10 border dark:bg-gray-700 text-black dark:text-white'; return ( <>