feat: create a chat assistant and extract SimilaritySlider (#67)
* feat: extract SimilaritySlider * feat: create a chat assistant
This commit is contained in:
@@ -1,13 +1,18 @@
|
||||
import { IDialog } from '@/interfaces/database/chat';
|
||||
import chatService from '@/services/chatService';
|
||||
import { message } from 'antd';
|
||||
import { DvaModel } from 'umi';
|
||||
|
||||
export interface ChatModelState {
|
||||
name: string;
|
||||
dialogList: IDialog[];
|
||||
}
|
||||
|
||||
const model: DvaModel<ChatModelState> = {
|
||||
namespace: 'chatModel',
|
||||
state: {
|
||||
name: 'kate',
|
||||
dialogList: [],
|
||||
},
|
||||
reducers: {
|
||||
save(state, action) {
|
||||
@@ -16,16 +21,41 @@ const model: DvaModel<ChatModelState> = {
|
||||
...action.payload,
|
||||
};
|
||||
},
|
||||
},
|
||||
subscriptions: {
|
||||
setup({ dispatch, history }) {
|
||||
return history.listen((query) => {
|
||||
console.log(query);
|
||||
});
|
||||
setDialogList(state, { payload }) {
|
||||
return {
|
||||
...state,
|
||||
dialogList: payload,
|
||||
};
|
||||
},
|
||||
},
|
||||
|
||||
effects: {
|
||||
*query({ payload }, { call, put }) {},
|
||||
*getDialog({ payload }, { call, put }) {
|
||||
const { data } = yield call(chatService.getDialog, payload);
|
||||
},
|
||||
*setDialog({ payload }, { call, put }) {
|
||||
const { data } = yield call(chatService.setDialog, payload);
|
||||
if (data.retcode === 0) {
|
||||
yield put({ type: 'listDialog' });
|
||||
message.success('Created successfully !');
|
||||
}
|
||||
},
|
||||
*listDialog({ payload }, { call, put }) {
|
||||
const { data } = yield call(chatService.listDialog, payload);
|
||||
yield put({ type: 'setDialogList', payload: data.data });
|
||||
},
|
||||
*listConversation({ payload }, { call, put }) {
|
||||
const { data } = yield call(chatService.listConversation, payload);
|
||||
},
|
||||
*getConversation({ payload }, { call, put }) {
|
||||
const { data } = yield call(chatService.getConversation, payload);
|
||||
},
|
||||
*setConversation({ payload }, { call, put }) {
|
||||
const { data } = yield call(chatService.setConversation, payload);
|
||||
},
|
||||
*completeConversation({ payload }, { call, put }) {
|
||||
const { data } = yield call(chatService.completeConversation, payload);
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user