forked from XiaoMo/ChatGPT-Next-Web
feat: close #2013 add switch model button to chat actions
This commit is contained in:
parent
50b1f7db12
commit
5d06fa217c
@ -27,6 +27,7 @@ import DarkIcon from "../icons/dark.svg";
|
|||||||
import AutoIcon from "../icons/auto.svg";
|
import AutoIcon from "../icons/auto.svg";
|
||||||
import BottomIcon from "../icons/bottom.svg";
|
import BottomIcon from "../icons/bottom.svg";
|
||||||
import StopIcon from "../icons/pause.svg";
|
import StopIcon from "../icons/pause.svg";
|
||||||
|
import RobotIcon from "../icons/robot.svg";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
ChatMessage,
|
ChatMessage,
|
||||||
@ -38,6 +39,7 @@ import {
|
|||||||
Theme,
|
Theme,
|
||||||
useAppConfig,
|
useAppConfig,
|
||||||
DEFAULT_TOPIC,
|
DEFAULT_TOPIC,
|
||||||
|
ALL_MODELS,
|
||||||
} from "../store";
|
} from "../store";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@ -385,6 +387,19 @@ export function ChatActions(props: {
|
|||||||
const couldStop = ChatControllerPool.hasPending();
|
const couldStop = ChatControllerPool.hasPending();
|
||||||
const stopAll = () => ChatControllerPool.stopAll();
|
const stopAll = () => ChatControllerPool.stopAll();
|
||||||
|
|
||||||
|
// switch model
|
||||||
|
const currentModel = chatStore.currentSession().mask.modelConfig.model;
|
||||||
|
function nextModel() {
|
||||||
|
const models = ALL_MODELS.filter((m) => m.available).map((m) => m.name);
|
||||||
|
const modelIndex = models.indexOf(currentModel);
|
||||||
|
const nextIndex = (modelIndex + 1) % models.length;
|
||||||
|
const nextModel = models[nextIndex];
|
||||||
|
chatStore.updateCurrentSession((session) => {
|
||||||
|
session.mask.modelConfig.model = nextModel;
|
||||||
|
session.mask.syncGlobalConfig = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={chatStyle["chat-input-actions"]}>
|
<div className={chatStyle["chat-input-actions"]}>
|
||||||
{couldStop && (
|
{couldStop && (
|
||||||
@ -453,6 +468,12 @@ export function ChatActions(props: {
|
|||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<ChatAction
|
||||||
|
onClick={nextModel}
|
||||||
|
text={currentModel}
|
||||||
|
icon={<RobotIcon />}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
1
app/icons/robot.svg
Normal file
1
app/icons/robot.svg
Normal file
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 12 KiB |
Loading…
Reference in New Issue
Block a user