chore: reorganize client files for docker

This commit is contained in:
Danny Avila 2023-03-06 10:47:06 -05:00
parent affbaaf1a5
commit f5e079742a
93 changed files with 178726 additions and 1 deletions

View file

@ -0,0 +1,42 @@
import { createSlice } from '@reduxjs/toolkit';
const initialState = {
error: false,
title: 'ChatGPT Clone',
conversationId: null,
parentMessageId: null,
conversationSignature: null,
clientId: null,
invocationId: null,
chatGptLabel: null,
promptPrefix: null,
convosLoading: false,
pageNumber: 1,
convos: [],
};
const currentSlice = createSlice({
name: 'convo',
initialState,
reducers: {
setConversation: (state, action) => {
return { ...state, ...action.payload };
},
setError: (state, action) => {
state.error = action.payload;
},
incrementPage: (state) => {
state.pageNumber = state.pageNumber + 1;
},
setConvos: (state, action) => {
const newConvos = action.payload.filter((convo) => {
return !state.convos.some((c) => c.conversationId === convo.conversationId);
});
state.convos = [...state.convos, ...newConvos];
},
}
});
export const { setConversation, setConvos, setError, incrementPage } = currentSlice.actions;
export default currentSlice.reducer;

18
client/src/store/index.js Normal file
View file

@ -0,0 +1,18 @@
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'
export const store = configureStore({
reducer: {
convo: convoReducer,
messages: messageReducer,
models: modelReducer,
text: textReducer,
submit: submitReducer,
},
devTools: true,
});

View file

@ -0,0 +1,19 @@
import { createSlice } from '@reduxjs/toolkit';
const initialState = {
messages: [],
};
const currentSlice = createSlice({
name: 'messages',
initialState,
reducers: {
setMessages: (state, action) => {
state.messages = action.payload;
},
}
});
export const { setMessages, setSubmitState } = currentSlice.actions;
export default currentSlice.reducer;

View file

@ -0,0 +1,53 @@
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'
},
{
_id: '3',
name: 'ChatGPT',
value: 'chatgptBrowser'
}
],
modelMap: {},
initial: { chatgpt: true, chatgptCustom: true, bingai: true, chatgptBrowser: true }
};
const currentSlice = createSlice({
name: 'models',
initialState,
reducers: {
setModels: (state, action) => {
const models = [...initialState.models, ...action.payload];
state.models = models;
const modelMap = {};
models.slice(4).forEach((modelItem) => {
modelMap[modelItem.value] = {
chatGptLabel: modelItem.chatGptLabel,
promptPrefix: modelItem.promptPrefix
};
});
state.modelMap = modelMap;
}
}
});
export const { setModels } = currentSlice.actions;
export default currentSlice.reducer;

View file

@ -0,0 +1,38 @@
import { createSlice } from '@reduxjs/toolkit';
const initialState = {
isSubmitting: false,
disabled: false,
model: 'chatgpt',
promptPrefix: '',
chatGptLabel: '',
customModel: null
};
const currentSlice = createSlice({
name: 'submit',
initialState,
reducers: {
setSubmitState: (state, action) => {
state.isSubmitting = action.payload;
},
setDisabled: (state, action) => {
state.disabled = action.payload;
},
setModel: (state, action) => {
state.model = action.payload;
},
setCustomGpt: (state, action) => {
state.promptPrefix = action.payload.promptPrefix;
state.chatGptLabel = action.payload.chatGptLabel;
},
setCustomModel: (state, action) => {
state.customModel = action.payload;
}
}
});
export const { setSubmitState, setDisabled, setModel, setCustomGpt, setCustomModel } =
currentSlice.actions;
export default currentSlice.reducer;

View file

@ -0,0 +1,19 @@
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;