2023-02-07 16:22:35 -05:00
|
|
|
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-16 21:12:33 +08:00
|
|
|
disabled: true,
|
2023-03-03 15:52:06 -05:00
|
|
|
model: 'chatgpt',
|
2023-03-14 20:21:41 -04:00
|
|
|
promptPrefix: null,
|
|
|
|
|
chatGptLabel: null,
|
2023-03-11 21:42:08 -05:00
|
|
|
customModel: null,
|
2023-03-19 11:25:12 -04:00
|
|
|
cursor: true,
|
2023-02-07 16:22:35 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
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;
|
2023-03-11 22:35:39 -05:00
|
|
|
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;
|
|
|
|
|
},
|
2023-02-13 21:15:28 -05:00
|
|
|
setModel: (state, action) => {
|
|
|
|
|
state.model = action.payload;
|
|
|
|
|
},
|
2023-03-19 11:25:12 -04:00
|
|
|
toggleCursor: (state, action) => {
|
|
|
|
|
if (action.payload) {
|
|
|
|
|
state.cursor = action.payload;
|
|
|
|
|
} else {
|
|
|
|
|
state.cursor = !state.cursor;
|
|
|
|
|
}
|
|
|
|
|
},
|
2023-03-03 15:52:06 -05:00
|
|
|
setCustomGpt: (state, action) => {
|
|
|
|
|
state.promptPrefix = action.payload.promptPrefix;
|
|
|
|
|
state.chatGptLabel = action.payload.chatGptLabel;
|
|
|
|
|
},
|
2023-03-04 21:10:45 -05:00
|
|
|
setCustomModel: (state, action) => {
|
|
|
|
|
state.customModel = action.payload;
|
|
|
|
|
}
|
2023-02-07 16:22:35 -05:00
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2023-03-19 11:25:12 -04:00
|
|
|
export const { toggleCursor, setSubmitState, setSubmission, setStopStream, setDisabled, setModel, setCustomGpt, setCustomModel } =
|
2023-03-04 21:10:45 -05:00
|
|
|
currentSlice.actions;
|
2023-02-07 16:22:35 -05:00
|
|
|
|
|
|
|
|
export default currentSlice.reducer;
|