forked from XiaoMo/ChatGPT-Next-Web
Merge pull request #3229 from Yidadaa/bugfix-1112
This commit is contained in:
commit
8bd39f33e0
@ -431,11 +431,27 @@ export function ChatActions(props: {
|
|||||||
|
|
||||||
// switch model
|
// switch model
|
||||||
const currentModel = chatStore.currentSession().mask.modelConfig.model;
|
const currentModel = chatStore.currentSession().mask.modelConfig.model;
|
||||||
const models = useAllModels()
|
const allModels = useAllModels();
|
||||||
.filter((m) => m.available)
|
const models = useMemo(
|
||||||
.map((m) => m.name);
|
() => allModels.filter((m) => m.available).map((m) => m.name),
|
||||||
|
[allModels],
|
||||||
|
);
|
||||||
const [showModelSelector, setShowModelSelector] = useState(false);
|
const [showModelSelector, setShowModelSelector] = useState(false);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
// if current model is not available
|
||||||
|
// switch to first available model
|
||||||
|
const isUnavaliableModel = !models.includes(currentModel);
|
||||||
|
if (isUnavaliableModel && models.length > 0) {
|
||||||
|
const nextModel = models[0] as ModelType;
|
||||||
|
chatStore.updateCurrentSession(
|
||||||
|
(session) => (session.mask.modelConfig.model = nextModel),
|
||||||
|
);
|
||||||
|
showToast(nextModel);
|
||||||
|
}
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, [currentModel, models]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles["chat-input-actions"]}>
|
<div className={styles["chat-input-actions"]}>
|
||||||
{couldStop && (
|
{couldStop && (
|
||||||
|
@ -8,7 +8,7 @@ export function useAllModels() {
|
|||||||
const models = useMemo(() => {
|
const models = useMemo(() => {
|
||||||
return collectModels(
|
return collectModels(
|
||||||
configStore.models,
|
configStore.models,
|
||||||
[accessStore.customModels, configStore.customModels].join(","),
|
[configStore.customModels, accessStore.customModels].join(","),
|
||||||
);
|
);
|
||||||
}, [accessStore.customModels, configStore.customModels, configStore.models]);
|
}, [accessStore.customModels, configStore.customModels, configStore.models]);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user