Skip to content

Commit c457b9a

Browse files
authored
hotfix for cache & drawer bug (#2538)
1 parent a2a0850 commit c457b9a

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

website/src/components/Chat/ChatSection.tsx

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,21 @@ export const ChatSection = ({ chatId }: { chatId: string | null }) => {
1616

1717
console.assert(modelInfos.length > 0, "No model config was found");
1818

19-
const form = useForm<ChatConfigFormData>({
20-
defaultValues: getConfigCache() ?? {
19+
let defaultValues = getConfigCache();
20+
if (defaultValues) {
21+
const model = modelInfos.find((model) => model.name === defaultValues.model_config_name);
22+
if (!model) {
23+
defaultValues = null;
24+
}
25+
}
26+
if (!defaultValues) {
27+
defaultValues = {
2128
...modelInfos[0].parameter_configs[0].sampling_parameters,
2229
model_config_name: modelInfos[0].name,
23-
},
24-
});
30+
};
31+
}
32+
33+
const form = useForm<ChatConfigFormData>({ defaultValues });
2534
return (
2635
<FormProvider {...form}>
2736
<Card className="mx-auto" maxW={{ base: "min(64rem, 90vw)", lg: "36rem", xl: "3xl", "2xl": "5xl" }}>

0 commit comments

Comments
 (0)