chore: use last conversation temperature (#568)
This commit is contained in:
parent
ba1dacb899
commit
03afa00732
|
@ -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);
|
||||
|
|
|
@ -192,7 +192,7 @@ const Home = ({
|
|||
tokenLimit: OpenAIModels[defaultModelId].tokenLimit,
|
||||
},
|
||||
prompt: DEFAULT_SYSTEM_PROMPT,
|
||||
temperature: DEFAULT_TEMPERATURE,
|
||||
temperature: lastConversation?.temperature ?? DEFAULT_TEMPERATURE,
|
||||
folderId: null,
|
||||
};
|
||||
|
||||
|
@ -326,6 +326,7 @@ const Home = ({
|
|||
value: cleanedSelectedConversation,
|
||||
});
|
||||
} else {
|
||||
const lastConversation = conversations[conversations.length - 1];
|
||||
dispatch({
|
||||
field: 'selectedConversation',
|
||||
value: {
|
||||
|
@ -334,7 +335,7 @@ const Home = ({
|
|||
messages: [],
|
||||
model: OpenAIModels[defaultModelId],
|
||||
prompt: DEFAULT_SYSTEM_PROMPT,
|
||||
temperature: DEFAULT_TEMPERATURE,
|
||||
temperature: lastConversation?.temperature ?? DEFAULT_TEMPERATURE,
|
||||
folderId: null,
|
||||
},
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue