LibreChat/client/src/store/submitSlice.js

50 lines
1.3 KiB
JavaScript
Raw Normal View History

import { createSlice } from '@reduxjs/toolkit';
const initialState = {
isSubmitting: false,
2023-03-11 21:42:08 -05:00
submission: {},
2023-03-11 18:39:46 -05:00
stopStream: false,
2023-03-03 15:52:06 -05:00
disabled: false,
model: 'chatgpt',
promptPrefix: '',
chatGptLabel: '',
2023-03-11 21:42:08 -05:00
customModel: null,
};
const currentSlice = createSlice({
name: 'submit',
initialState,
reducers: {
setSubmitState: (state, action) => {
state.isSubmitting = action.payload;
},
2023-03-11 21:42:08 -05:00
setSubmission: (state, action) => {
state.submission = action.payload;
if (Object.keys(action.payload).length === 0) {
state.isSubmitting = false;
}
2023-03-11 21:42:08 -05:00
},
2023-03-11 18:39:46 -05:00
setStopStream: (state, action) => {
state.stopStream = action.payload;
},
2023-03-03 15:52:06 -05:00
setDisabled: (state, action) => {
state.disabled = action.payload;
},
setModel: (state, action) => {
state.model = action.payload;
},
2023-03-03 15:52:06 -05:00
setCustomGpt: (state, action) => {
state.promptPrefix = action.payload.promptPrefix;
state.chatGptLabel = action.payload.chatGptLabel;
},
setCustomModel: (state, action) => {
state.customModel = action.payload;
}
}
});
2023-03-11 21:42:08 -05:00
export const { setSubmitState, setSubmission, setStopStream, setDisabled, setModel, setCustomGpt, setCustomModel } =
currentSlice.actions;
export default currentSlice.reducer;