balibabu commited on
Commit
28c23a3
·
1 Parent(s): aa96c78

fix: Delete the model.ts file of chat #1306 (#2129)

Browse files

### What problem does this PR solve?
fix: Delete the model.ts file of chat #1306

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)

Files changed (2) hide show
  1. web/src/pages/chat/model.ts +0 -194
  2. web/typings.d.ts +0 -2
web/src/pages/chat/model.ts DELETED
@@ -1,194 +0,0 @@
1
- import { IConversation, IDialog, Message } from '@/interfaces/database/chat';
2
- import i18n from '@/locales/config';
3
- import chatService from '@/services/chat-service';
4
- import { message } from 'antd';
5
- import { DvaModel } from 'umi';
6
- import { v4 as uuid } from 'uuid';
7
- import { IClientConversation, IMessage } from './interface';
8
- import { getDocumentIdsFromConversionReference } from './utils';
9
-
10
- export interface ChatModelState {
11
- name: string;
12
- dialogList: IDialog[];
13
- currentDialog: IDialog;
14
- conversationList: IConversation[];
15
- currentConversation: IClientConversation;
16
- }
17
-
18
- const model: DvaModel<ChatModelState> = {
19
- namespace: 'chatModel',
20
- state: {
21
- name: 'kate',
22
- dialogList: [],
23
- currentDialog: <IDialog>{},
24
- conversationList: [],
25
- currentConversation: {} as IClientConversation,
26
- },
27
- reducers: {
28
- save(state, action) {
29
- return {
30
- ...state,
31
- ...action.payload,
32
- };
33
- },
34
- setDialogList(state, { payload }) {
35
- return {
36
- ...state,
37
- dialogList: payload,
38
- };
39
- },
40
- setCurrentDialog(state, { payload }) {
41
- return {
42
- ...state,
43
- currentDialog: payload,
44
- };
45
- },
46
- setConversationList(state, { payload }) {
47
- return {
48
- ...state,
49
- conversationList: payload,
50
- };
51
- },
52
- setCurrentConversation(state, { payload }) {
53
- const messageList =
54
- payload?.message?.map((x: Message | IMessage) => ({
55
- ...x,
56
- id: 'id' in x ? x.id : uuid(),
57
- })) ?? [];
58
- return {
59
- ...state,
60
- currentConversation: { ...payload, message: messageList },
61
- };
62
- },
63
- },
64
-
65
- effects: {
66
- *getDialog({ payload }, { call, put }) {
67
- const needToBeSaved =
68
- payload.needToBeSaved === undefined ? true : payload.needToBeSaved;
69
- const { data } = yield call(chatService.getDialog, {
70
- dialog_id: payload.dialog_id,
71
- });
72
- if (data.retcode === 0 && needToBeSaved) {
73
- yield put({ type: 'setCurrentDialog', payload: data.data });
74
- }
75
- return data;
76
- },
77
- *setDialog({ payload }, { call, put }) {
78
- const { data } = yield call(chatService.setDialog, payload);
79
- if (data.retcode === 0) {
80
- yield put({ type: 'listDialog' });
81
- message.success(
82
- i18n.t(`message.${payload.dialog_id ? 'modified' : 'created'}`),
83
- );
84
- }
85
- return data.retcode;
86
- },
87
- *removeDialog({ payload }, { call, put }) {
88
- const { data } = yield call(chatService.removeDialog, payload);
89
- if (data.retcode === 0) {
90
- yield put({ type: 'listDialog' });
91
- message.success(i18n.t('message.deleted'));
92
- }
93
- return data.retcode;
94
- },
95
- *listDialog({ payload }, { call, put }) {
96
- const { data } = yield call(chatService.listDialog, payload);
97
- if (data.retcode === 0) {
98
- yield put({ type: 'setDialogList', payload: data.data });
99
- }
100
- return data;
101
- },
102
- *listConversation({ payload }, { call, put }) {
103
- const { data } = yield call(chatService.listConversation, payload);
104
- if (data.retcode === 0) {
105
- yield put({ type: 'setConversationList', payload: data.data });
106
- }
107
- return data.retcode;
108
- },
109
- *getConversation({ payload }, { call, put }) {
110
- const needToBeSaved =
111
- payload.needToBeSaved === undefined ? true : payload.needToBeSaved;
112
- const { data } = yield call(chatService.getConversation, {
113
- conversation_id: payload.conversation_id,
114
- });
115
- if (data.retcode === 0 && needToBeSaved) {
116
- yield put({
117
- type: 'kFModel/fetch_document_thumbnails',
118
- payload: {
119
- doc_ids: getDocumentIdsFromConversionReference(data.data),
120
- },
121
- });
122
- yield put({ type: 'setCurrentConversation', payload: data.data });
123
- }
124
- return data;
125
- },
126
- *setConversation({ payload }, { call, put }) {
127
- const { data } = yield call(chatService.setConversation, payload);
128
- if (data.retcode === 0) {
129
- yield put({
130
- type: 'listConversation',
131
- payload: {
132
- dialog_id: data.data.dialog_id,
133
- },
134
- });
135
- }
136
- return data;
137
- },
138
- *completeConversation({ payload }, { call }) {
139
- const { data } = yield call(chatService.completeConversation, payload);
140
- // if (data.retcode === 0) {
141
- // yield put({
142
- // type: 'getConversation',
143
- // payload: {
144
- // conversation_id: payload.conversation_id,
145
- // },
146
- // });
147
- // }
148
- return data.retcode;
149
- },
150
- *removeConversation({ payload }, { call, put }) {
151
- const { data } = yield call(chatService.removeConversation, {
152
- conversation_ids: payload.conversation_ids,
153
- });
154
- if (data.retcode === 0) {
155
- yield put({
156
- type: 'listConversation',
157
- payload: { dialog_id: payload.dialog_id },
158
- });
159
- message.success(i18n.t('message.deleted'));
160
- }
161
- return data.retcode;
162
- },
163
- *createExternalConversation({ payload }, { call, put }) {
164
- const { data } = yield call(
165
- chatService.createExternalConversation,
166
- payload,
167
- );
168
- // if (data.retcode === 0) {
169
- // yield put({
170
- // type: 'getExternalConversation',
171
- // payload: data.data.id,
172
- // });
173
- // }
174
- return data;
175
- },
176
- *getExternalConversation({ payload }, { call }) {
177
- const { data } = yield call(
178
- chatService.getExternalConversation,
179
- null,
180
- payload,
181
- );
182
- return data;
183
- },
184
- *completeExternalConversation({ payload }, { call }) {
185
- const { data } = yield call(
186
- chatService.completeExternalConversation,
187
- payload,
188
- );
189
- return data.retcode;
190
- },
191
- },
192
- };
193
-
194
- export default model;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
web/typings.d.ts CHANGED
@@ -1,5 +1,4 @@
1
  import { KFModelState } from '@/pages/add-knowledge/components/knowledge-file/model';
2
- import { ChatModelState } from '@/pages/chat/model';
3
 
4
  declare module 'lodash';
5
 
@@ -9,7 +8,6 @@ function useSelector<TState = RootState, TSelected = unknown>(
9
  ): TSelected;
10
 
11
  export interface RootState {
12
- chatModel: ChatModelState;
13
  kFModel: KFModelState;
14
  }
15
 
 
1
  import { KFModelState } from '@/pages/add-knowledge/components/knowledge-file/model';
 
2
 
3
  declare module 'lodash';
4
 
 
8
  ): TSelected;
9
 
10
  export interface RootState {
 
11
  kFModel: KFModelState;
12
  }
13