mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-01-06 02:28:51 +01:00
54 lines
1.1 KiB
JavaScript
54 lines
1.1 KiB
JavaScript
import { createSlice } from '@reduxjs/toolkit';
|
|
|
|
const initialState = {
|
|
models: [
|
|
{
|
|
_id: '0',
|
|
name: 'ChatGPT',
|
|
value: 'chatgpt'
|
|
},
|
|
{
|
|
_id: '1',
|
|
name: 'CustomGPT',
|
|
value: 'chatgptCustom'
|
|
},
|
|
{
|
|
_id: '2',
|
|
name: 'BingAI',
|
|
value: 'bingai'
|
|
},
|
|
{
|
|
_id: '3',
|
|
name: 'ChatGPT',
|
|
value: 'chatgptBrowser'
|
|
}
|
|
],
|
|
modelMap: {},
|
|
initial: { chatgpt: true, chatgptCustom: true, bingai: true, chatgptBrowser: true }
|
|
};
|
|
|
|
const currentSlice = createSlice({
|
|
name: 'models',
|
|
initialState,
|
|
reducers: {
|
|
setModels: (state, action) => {
|
|
console.log('setModels', action.payload);
|
|
const models = [...initialState.models, ...action.payload];
|
|
state.models = models;
|
|
const modelMap = {};
|
|
|
|
models.slice(4).forEach((modelItem) => {
|
|
modelMap[modelItem.value] = {
|
|
chatGptLabel: modelItem.chatGptLabel,
|
|
promptPrefix: modelItem.promptPrefix
|
|
};
|
|
});
|
|
|
|
state.modelMap = modelMap;
|
|
}
|
|
}
|
|
});
|
|
|
|
export const { setModels } = currentSlice.actions;
|
|
|
|
export default currentSlice.reducer;
|