import { FC, useContext, useState } from 'react'; import { useTranslation } from 'next-i18next'; import { DEFAULT_TEMPERATURE } from '@/utils/app/const'; import HomeContext from '@/pages/api/home/home.context'; interface Props { label: string; onChangeTemperature: (temperature: number) => void; } export const TemperatureSlider: FC = ({ label, onChangeTemperature, }) => { const { state: { conversations }, } = useContext(HomeContext); const lastConversation = conversations[conversations.length - 1]; const [temperature, setTemperature] = useState( lastConversation?.temperature ?? DEFAULT_TEMPERATURE, ); const { t } = useTranslation('chat'); const handleChange = (event: React.ChangeEvent) => { const newValue = parseFloat(event.target.value); setTemperature(newValue); onChangeTemperature(newValue); }; return (
{t( 'Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.', )} {temperature.toFixed(1)}
  • {t('Precise')}
  • {t('Neutral')}
  • {t('Creative')}
); };