LibreChat/client/src/store/modelSlice.js

60 lines
1.2 KiB
JavaScript
Raw Normal View History

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'
2023-03-08 19:47:23 -05:00
},
{
_id: '3',
name: 'Sydney',
value: 'sydney'
},
{
_id: '4',
2023-03-08 19:47:23 -05:00
name: 'ChatGPT',
value: 'chatgptBrowser'
},
2023-03-04 20:48:59 -05:00
],
modelMap: {},
initial: { chatgpt: true, chatgptCustom: true, bingai: true, sydney: true, chatgptBrowser: true }
2023-03-08 19:47:23 -05:00
// initial: { chatgpt: true, chatgptCustom: true, bingai: true, }
};
const currentSlice = createSlice({
name: 'models',
initialState,
reducers: {
setModels: (state, action) => {
2023-03-04 20:48:59 -05:00
const models = [...initialState.models, ...action.payload];
state.models = models;
const modelMap = {};
models.slice(initialState.models.length).forEach((modelItem) => {
2023-03-04 20:48:59 -05:00
modelMap[modelItem.value] = {
chatGptLabel: modelItem.chatGptLabel,
promptPrefix: modelItem.promptPrefix
};
});
state.modelMap = modelMap;
}
}
});
export const { setModels } = currentSlice.actions;
export default currentSlice.reducer;