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 { useTranslation } from 'next-i18next';
|
||||||
|
|
||||||
import { DEFAULT_TEMPERATURE } from '@/utils/app/const';
|
import { DEFAULT_TEMPERATURE } from '@/utils/app/const';
|
||||||
|
|
||||||
|
import HomeContext from '@/pages/api/home/home.context';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
label: string;
|
label: string;
|
||||||
onChangeTemperature: (temperature: number) => void;
|
onChangeTemperature: (temperature: number) => void;
|
||||||
|
@ -13,7 +15,13 @@ export const TemperatureSlider: FC<Props> = ({
|
||||||
label,
|
label,
|
||||||
onChangeTemperature,
|
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 { t } = useTranslation('chat');
|
||||||
const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
const newValue = parseFloat(event.target.value);
|
const newValue = parseFloat(event.target.value);
|
||||||
|
|
|
@ -192,7 +192,7 @@ const Home = ({
|
||||||
tokenLimit: OpenAIModels[defaultModelId].tokenLimit,
|
tokenLimit: OpenAIModels[defaultModelId].tokenLimit,
|
||||||
},
|
},
|
||||||
prompt: DEFAULT_SYSTEM_PROMPT,
|
prompt: DEFAULT_SYSTEM_PROMPT,
|
||||||
temperature: DEFAULT_TEMPERATURE,
|
temperature: lastConversation?.temperature ?? DEFAULT_TEMPERATURE,
|
||||||
folderId: null,
|
folderId: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -326,6 +326,7 @@ const Home = ({
|
||||||
value: cleanedSelectedConversation,
|
value: cleanedSelectedConversation,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
const lastConversation = conversations[conversations.length - 1];
|
||||||
dispatch({
|
dispatch({
|
||||||
field: 'selectedConversation',
|
field: 'selectedConversation',
|
||||||
value: {
|
value: {
|
||||||
|
@ -334,7 +335,7 @@ const Home = ({
|
||||||
messages: [],
|
messages: [],
|
||||||
model: OpenAIModels[defaultModelId],
|
model: OpenAIModels[defaultModelId],
|
||||||
prompt: DEFAULT_SYSTEM_PROMPT,
|
prompt: DEFAULT_SYSTEM_PROMPT,
|
||||||
temperature: DEFAULT_TEMPERATURE,
|
temperature: lastConversation?.temperature ?? DEFAULT_TEMPERATURE,
|
||||||
folderId: null,
|
folderId: null,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue