chore: use last conversation temperature (#568)
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
import { FC, useState } from 'react';
|
||||
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;
|
||||
@@ -13,7 +15,13 @@ export const TemperatureSlider: FC<Props> = ({
|
||||
label,
|
||||
onChangeTemperature,
|
||||
}) => {
|
||||
const [temperature, setTemperature] = useState(DEFAULT_TEMPERATURE);
|
||||
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<HTMLInputElement>) => {
|
||||
const newValue = parseFloat(event.target.value);
|
||||
|
||||
Reference in New Issue
Block a user