mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 17:00:15 +01:00
feat: set default model once model list read.
This commit is contained in:
parent
131af50034
commit
b6f7f95709
3 changed files with 27 additions and 7 deletions
|
|
@ -72,6 +72,24 @@ export default function ModelMenu() {
|
|||
const initial = {chatgpt: data?.hasOpenAI, chatgptCustom: data?.hasOpenAI, bingai: data?.hasBing, sydney: data?.hasBing, chatgptBrowser: data?.hasChatGpt}
|
||||
dispatch(setInitial(initial))
|
||||
// TODO, auto reset default model
|
||||
if (data?.hasOpenAI) {
|
||||
dispatch(setModel('chatgpt'));
|
||||
dispatch(setDisabled(false));
|
||||
dispatch(setCustomModel(null));
|
||||
dispatch(setCustomGpt({ chatGptLabel: null, promptPrefix: null }));
|
||||
} else if (data?.hasBing) {
|
||||
dispatch(setModel('bingai'));
|
||||
dispatch(setDisabled(false));
|
||||
dispatch(setCustomModel(null));
|
||||
dispatch(setCustomGpt({ chatGptLabel: null, promptPrefix: null }));
|
||||
} else if (data?.hasChatGpt) {
|
||||
dispatch(setModel('chatgptBrowser'));
|
||||
dispatch(setDisabled(false));
|
||||
dispatch(setCustomModel(null));
|
||||
dispatch(setCustomGpt({ chatGptLabel: null, promptPrefix: null }));
|
||||
} else {
|
||||
dispatch(setDisabled(true));
|
||||
}
|
||||
}).catch((error) => {
|
||||
console.error(error)
|
||||
console.log('Not login!')
|
||||
|
|
@ -83,6 +101,8 @@ export default function ModelMenu() {
|
|||
localStorage.setItem('model', JSON.stringify(model));
|
||||
}, [model]);
|
||||
|
||||
const filteredModels = models.filter(({model}) => initial[model])
|
||||
|
||||
const onChange = (value) => {
|
||||
if (!value) {
|
||||
return;
|
||||
|
|
@ -183,10 +203,12 @@ export default function ModelMenu() {
|
|||
onValueChange={onChange}
|
||||
className="overflow-y-auto"
|
||||
>
|
||||
<MenuItems
|
||||
models={models}
|
||||
onSelect={onChange}
|
||||
/>
|
||||
{filteredModels.length?
|
||||
<MenuItems
|
||||
models={filteredModels}
|
||||
onSelect={onChange}
|
||||
/>:<DropdownMenuLabel className="dark:text-gray-300">No model available.</DropdownMenuLabel>
|
||||
}
|
||||
</DropdownMenuRadioGroup>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue