diff --git a/client/src/store2/convoSlice.js b/client/src/store2/convoSlice.js deleted file mode 100644 index d800535296..0000000000 --- a/client/src/store2/convoSlice.js +++ /dev/null @@ -1,113 +0,0 @@ -import { createSlice } from '@reduxjs/toolkit'; - -const initialState = { - error: false, - title: 'ChatGPT Clone', - conversationId: null, - parentMessageId: null, - jailbreakConversationId: null, - conversationSignature: null, - clientId: null, - invocationId: null, - toneStyle: null, - chatGptLabel: null, - promptPrefix: null, - convosLoading: false, - pageNumber: 1, - pages: 1, - refreshConvoHint: 0, - search: false, - latestMessage: null, - convos: [], - convoMap: {}, -}; - -const currentSlice = createSlice({ - name: 'convo', - initialState, - reducers: { - refreshConversation: (state) => { - state.refreshConvoHint = state.refreshConvoHint + 1; - }, - setConversation: (state, action) => { - // return { ...state, ...action.payload }; - - for (const key in action.payload) { - if (Object.hasOwnProperty.call(action.payload, key)) { - state[key] = action.payload[key]; - } - } - }, - setError: (state, action) => { - state.error = action.payload; - }, - increasePage: (state) => { - state.pageNumber = state.pageNumber + 1; - }, - decreasePage: (state) => { - state.pageNumber = state.pageNumber - 1; - }, - setPage: (state, action) => { - state.pageNumber = action.payload; - }, - setNewConvo: (state) => { - state.error = false; - state.title = 'ChatGPT Clone'; - state.conversationId = null; - state.parentMessageId = null; - state.jailbreakConversationId = null; - state.conversationSignature = null; - state.clientId = null; - state.invocationId = null; - state.toneStyle = null; - state.chatGptLabel = null; - state.promptPrefix = null; - state.convosLoading = false; - state.latestMessage = null; - }, - setConvos: (state, action) => { - const { convos, searchFetch } = action.payload; - if (searchFetch) { - state.convos = convos; - } else { - state.convos = convos.sort((a, b) => new Date(b.createdAt) - new Date(a.createdAt)); - } - - // state.convoMap = convos.reduce((acc, curr) => { - // acc[curr.conversationId] = { ...curr }; - // delete acc[curr.conversationId].conversationId; - // return acc; - // }, {}); - - }, - setPages: (state, action) => { - state.pages = action.payload; - }, - removeConvo: (state, action) => { - state.convos = state.convos.filter((convo) => convo.conversationId !== action.payload); - }, - removeAll: (state) => { - state.convos = []; - }, - setLatestMessage: (state, action) => { - state.latestMessage = action.payload; - } - } -}); - -export const { - refreshConversation, - setConversation, - setPages, - setConvos, - setNewConvo, - setError, - increasePage, - decreasePage, - setPage, - removeConvo, - removeAll, - setLatestMessage -} = currentSlice.actions; - -export default currentSlice.reducer; diff --git a/client/src/store2/index.js b/client/src/store2/index.js deleted file mode 100644 index aa45a5c9d3..0000000000 --- a/client/src/store2/index.js +++ /dev/null @@ -1,22 +0,0 @@ -import { configureStore } from '@reduxjs/toolkit'; - -import convoReducer from './convoSlice.js'; -import messageReducer from './messageSlice.js'; -import modelReducer from './modelSlice.js'; -import submitReducer from './submitSlice.js'; -import textReducer from './textSlice.js'; -import userReducer from './userReducer.js'; -import searchReducer from './searchSlice.js'; - -export const store = configureStore({ - reducer: { - convo: convoReducer, - messages: messageReducer, - models: modelReducer, - text: textReducer, - submit: submitReducer, - user: userReducer, - search: searchReducer - }, - devTools: true -}); diff --git a/client/src/store2/messageSlice.js b/client/src/store2/messageSlice.js deleted file mode 100644 index de1fef38e0..0000000000 --- a/client/src/store2/messageSlice.js +++ /dev/null @@ -1,35 +0,0 @@ -import { createSlice } from '@reduxjs/toolkit'; -import buildTree from '~/utils/buildTree'; - -const initialState = { - messages: [], - messageTree: [] -}; - -const currentSlice = createSlice({ - name: 'messages', - initialState, - reducers: { - setMessages: (state, action) => { - state.messages = action.payload; - const groupAll = action.payload[0]?.searchResult; - if (groupAll) console.log('grouping all messages'); - state.messageTree = buildTree(action.payload, groupAll); - }, - setEmptyMessage: (state) => { - state.messages = [ - { - messageId: '1', - conversationId: '1', - parentMessageId: '1', - sender: '', - text: '' - } - ] - }, - } -}); - -export const { setMessages, setEmptyMessage } = currentSlice.actions; - -export default currentSlice.reducer; diff --git a/client/src/store2/modelSlice.js b/client/src/store2/modelSlice.js deleted file mode 100644 index 1db760de5d..0000000000 --- a/client/src/store2/modelSlice.js +++ /dev/null @@ -1,68 +0,0 @@ -import { createSlice } from '@reduxjs/toolkit'; - -const initialState = { - models: [ - { - _id: '0', - name: 'ChatGPT', - value: 'chatgpt', - model: 'chatgpt' - }, - { - _id: '1', - name: 'CustomGPT', - value: 'chatgptCustom', - model: 'chatgptCustom' - }, - { - _id: '2', - name: 'BingAI', - value: 'bingai', - model: 'bingai' - }, - { - _id: '3', - name: 'Sydney', - value: 'sydney', - model: 'sydney' - }, - { - _id: '4', - name: 'ChatGPT', - value: 'chatgptBrowser', - model: 'chatgptBrowser' - }, - ], - modelMap: {}, - initial: { chatgpt: false, chatgptCustom: false, bingai: false, sydney: false, chatgptBrowser: false } - // initial: { chatgpt: true, chatgptCustom: true, bingai: true, } -}; - -const currentSlice = createSlice({ - name: 'models', - initialState, - reducers: { - setModels: (state, action) => { - const models = [...initialState.models, ...action.payload]; - state.models = models; - const modelMap = {}; - - models.slice(initialState.models.length).forEach((modelItem) => { - modelMap[modelItem.value] = { - chatGptLabel: modelItem.chatGptLabel, - promptPrefix: modelItem.promptPrefix, - model: 'chatgptCustom' - }; - }); - - state.modelMap = modelMap; - }, - setInitial: (state, action) => { - state.initial = action.payload; - } - } -}); - -export const { setModels, setInitial } = currentSlice.actions; - -export default currentSlice.reducer; diff --git a/client/src/store2/searchSlice.js b/client/src/store2/searchSlice.js deleted file mode 100644 index d53c0eea62..0000000000 --- a/client/src/store2/searchSlice.js +++ /dev/null @@ -1,35 +0,0 @@ -import { createSlice } from '@reduxjs/toolkit'; - -const initialState = { - searchEnabled: false, - search: false, - query: '', - inputValue: '', -}; - -const currentSlice = createSlice({ - name: 'search', - initialState, - reducers: { - setInputValue: (state, action) => { - state.inputValue = action.payload; - }, - setSearchState: (state, action) => { - state.searchEnabled = action.payload; - }, - setQuery: (state, action) => { - const q = action.payload; - state.query = q; - - if (q === '') { - state.search = false; - } else if (q?.length > 0 && !state.search) { - state.search = true; - } - }, - } -}); - -export const { setInputValue, setSearchState, setQuery } = currentSlice.actions; - -export default currentSlice.reducer; diff --git a/client/src/store2/submitSlice.js b/client/src/store2/submitSlice.js deleted file mode 100644 index 6efdb85148..0000000000 --- a/client/src/store2/submitSlice.js +++ /dev/null @@ -1,57 +0,0 @@ -import { createSlice } from '@reduxjs/toolkit'; - -const initialState = { - isSubmitting: false, - submission: {}, - stopStream: false, - disabled: true, - model: 'chatgpt', - promptPrefix: null, - chatGptLabel: null, - customModel: null, - cursor: true, -}; - -const currentSlice = createSlice({ - name: 'submit', - initialState, - reducers: { - setSubmitState: (state, action) => { - state.isSubmitting = action.payload; - }, - setSubmission: (state, action) => { - state.submission = action.payload; - if (Object.keys(action.payload).length === 0) { - state.isSubmitting = false; - } - }, - setStopStream: (state, action) => { - state.stopStream = action.payload; - }, - setDisabled: (state, action) => { - state.disabled = action.payload; - }, - setModel: (state, action) => { - state.model = action.payload; - }, - toggleCursor: (state, action) => { - if (action.payload) { - state.cursor = action.payload; - } else { - state.cursor = !state.cursor; - } - }, - setCustomGpt: (state, action) => { - state.promptPrefix = action.payload.promptPrefix; - state.chatGptLabel = action.payload.chatGptLabel; - }, - setCustomModel: (state, action) => { - state.customModel = action.payload; - } - } -}); - -export const { toggleCursor, setSubmitState, setSubmission, setStopStream, setDisabled, setModel, setCustomGpt, setCustomModel } = - currentSlice.actions; - -export default currentSlice.reducer; diff --git a/client/src/store2/textSlice.js b/client/src/store2/textSlice.js deleted file mode 100644 index 7d25b16d26..0000000000 --- a/client/src/store2/textSlice.js +++ /dev/null @@ -1,19 +0,0 @@ -import { createSlice } from '@reduxjs/toolkit'; - -const initialState = { - text: '', -}; - -const currentSlice = createSlice({ - name: 'text', - initialState, - reducers: { - setText: (state, action) => { - state.text = action.payload; - }, - } -}); - -export const { setText } = currentSlice.actions; - -export default currentSlice.reducer; diff --git a/client/src/store2/userReducer.js b/client/src/store2/userReducer.js deleted file mode 100644 index bf0591333b..0000000000 --- a/client/src/store2/userReducer.js +++ /dev/null @@ -1,19 +0,0 @@ -import { createSlice } from '@reduxjs/toolkit'; - -const initialState = { - user: null, -}; - -const currentSlice = createSlice({ - name: 'user', - initialState, - reducers: { - setUser: (state, action) => { - state.user = action.payload; - }, - } -}); - -export const { setUser } = currentSlice.actions; - -export default currentSlice.reducer;