mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-29 14:48:51 +01:00
cleanup remove redux store
This commit is contained in:
parent
aa26eea8c5
commit
b7af3595cf
8 changed files with 0 additions and 368 deletions
|
|
@ -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;
|
||||
|
|
@ -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
|
||||
});
|
||||
|
|
@ -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;
|
||||
|
|
@ -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;
|
||||
|
|
@ -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;
|
||||
|
|
@ -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;
|
||||
|
|
@ -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;
|
||||
|
|
@ -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;
|
||||
Loading…
Add table
Add a link
Reference in a new issue