File size: 4,241 Bytes
f305776 7e26e0d aa396c5 6b8fc2c 04aba1b f305776 362ec6c 6b8fc2c 362ec6c 6b8fc2c f305776 f3d0ebd 7e26e0d aa396c5 6b8fc2c 362ec6c 6b8fc2c f305776 6b8fc2c 7e26e0d aa396c5 6b8fc2c 362ec6c aa396c5 04aba1b 6b8fc2c af3ef26 6b8fc2c cd46bb2 af3ef26 6b8fc2c aa396c5 6b8fc2c aa396c5 6b8fc2c af3ef26 6b8fc2c 04aba1b 6b8fc2c 04aba1b 6b8fc2c af3ef26 6b8fc2c d80b399 6b8fc2c 04aba1b 6b8fc2c af3ef26 6b8fc2c 7e26e0d 6b8fc2c 7e26e0d 04aba1b 6b8fc2c f3d0ebd 6b8fc2c 04aba1b 6b8fc2c 7ccbbf8 7e26e0d 6b8fc2c 7e26e0d 04aba1b 6b8fc2c af3ef26 6b8fc2c 7e26e0d 7ccbbf8 af3ef26 6b8fc2c 7e26e0d 6b8fc2c 362ec6c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
import { ITenantInfo } from '@/interfaces/database/knowledge';
import {
IFactory,
IMyLlmValue,
IThirdOAIModelCollection as IThirdAiModelCollection,
} from '@/interfaces/database/llm';
import { IUserInfo } from '@/interfaces/database/userSetting';
import userService from '@/services/userService';
import { message } from 'antd';
import { Nullable } from 'typings';
import { DvaModel } from 'umi';
export interface SettingModelState {
llm_factory: string;
tenantIfo: Nullable<ITenantInfo>;
llmInfo: IThirdAiModelCollection;
myLlmList: Record<string, IMyLlmValue>;
factoryList: IFactory[];
userInfo: IUserInfo;
}
const model: DvaModel<SettingModelState> = {
namespace: 'settingModel',
state: {
llm_factory: '',
tenantIfo: null,
llmInfo: {},
myLlmList: {},
factoryList: [],
userInfo: {} as IUserInfo,
},
reducers: {
updateState(state, { payload }) {
return {
...state,
...payload,
};
},
setUserInfo(state, { payload }) {
return {
...state,
userInfo: payload,
};
},
},
effects: {
*setting({ payload = {} }, { call, put }) {
const { data } = yield call(userService.setting, payload);
const { retcode } = data;
if (retcode === 0) {
message.success('Modified!');
yield put({
type: 'getUserInfo',
});
}
},
*getUserInfo({ payload = {} }, { call, put }) {
const { data } = yield call(userService.user_info, payload);
const { retcode, data: res } = data;
// const userInfo = {
// avatar: res.avatar,
// name: res.nickname,
// email: res.email,
// };
// authorizationUtil.setUserInfo(userInfo);
if (retcode === 0) {
yield put({ type: 'setUserInfo', payload: res });
// localStorage.setItem('userInfo',res.)
}
},
*getTenantInfo({ payload = {} }, { call, put }) {
const { data } = yield call(userService.get_tenant_info, payload);
const { retcode, data: res } = data;
// llm_id 对应chat_id
// asr_id 对应speech2txt
if (retcode === 0) {
res.chat_id = res.llm_id;
res.speech2text_id = res.asr_id;
yield put({
type: 'updateState',
payload: {
tenantIfo: res,
},
});
}
},
*set_tenant_info({ payload = {} }, { call, put }) {
const { data } = yield call(userService.set_tenant_info, payload);
const { retcode } = data;
if (retcode === 0) {
message.success('Modified!');
yield put({
type: 'getTenantInfo',
});
}
return retcode;
},
*factories_list({ payload = {} }, { call, put }) {
const { data } = yield call(userService.factories_list);
const { retcode, data: res } = data;
if (retcode === 0) {
yield put({
type: 'updateState',
payload: {
factoryList: res,
},
});
}
},
*llm_list({ payload = {} }, { call, put }) {
const { data } = yield call(userService.llm_list, payload);
const { retcode, data: res } = data;
if (retcode === 0) {
yield put({
type: 'updateState',
payload: {
llmInfo: res,
},
});
}
},
*my_llm({ payload = {} }, { call, put }) {
const { data } = yield call(userService.my_llm);
const { retcode, data: res } = data;
if (retcode === 0) {
yield put({
type: 'updateState',
payload: {
myLlmList: res,
},
});
}
},
*set_api_key({ payload = {} }, { call, put }) {
const { data } = yield call(userService.set_api_key, payload);
const { retcode } = data;
if (retcode === 0) {
message.success('Modified!');
yield put({ type: 'my_llm' });
yield put({ type: 'factories_list' });
yield put({
type: 'updateState',
});
}
return retcode;
},
},
};
export default model;
|