mirror of https://github.com/arc53/DocsGPT
adds conversation slice
parent
a86744d9d6
commit
d20b5f3e09
@ -0,0 +1,29 @@
|
|||||||
|
import { createSlice } from '@reduxjs/toolkit';
|
||||||
|
|
||||||
|
type MESSAGE_TYPE = 'QUESTION' | 'ANSWER';
|
||||||
|
|
||||||
|
interface SingleConversation {
|
||||||
|
message: string;
|
||||||
|
messageType: MESSAGE_TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ConversationState {
|
||||||
|
conversation: SingleConversation[];
|
||||||
|
}
|
||||||
|
|
||||||
|
const initialState: ConversationState = {
|
||||||
|
conversation: [],
|
||||||
|
};
|
||||||
|
|
||||||
|
export const conversationSlice = createSlice({
|
||||||
|
name: 'conversation',
|
||||||
|
initialState,
|
||||||
|
reducers: {
|
||||||
|
addMessage(state, action) {
|
||||||
|
state.conversation.push(action.payload);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export const { addMessage } = conversationSlice.actions;
|
||||||
|
export default conversationSlice.reducer;
|
Loading…
Reference in New Issue