feat: submit api key and add language to Configuration and fetch llm factory list on UserSettingModel mount (#121)

* feat: fetch llm factory list on UserSettingModel mount

* feat: add language to Configuration

* feat: submit api key
This commit is contained in:
balibabu
2024-03-12 18:58:09 +08:00
committed by GitHub
parent 0feb085c88
commit 2ca0dc0fc5
8 changed files with 422 additions and 35 deletions

View File

@@ -1,5 +1,9 @@
import { ITenantInfo } from '@/interfaces/database/knowledge';
import { IThirdOAIModelCollection as IThirdAiModelCollection } from '@/interfaces/database/llm';
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';
@@ -9,13 +13,12 @@ import { DvaModel } from 'umi';
export interface SettingModelState {
isShowPSwModal: boolean;
isShowTntModal: boolean;
isShowSAKModal: boolean;
isShowSSModal: boolean;
llm_factory: string;
tenantIfo: Nullable<ITenantInfo>;
llmInfo: IThirdAiModelCollection;
myLlm: any[];
factoriesList: any[];
myLlmList: Record<string, IMyLlmValue>;
factoryList: IFactory[];
userInfo: IUserInfo;
}
@@ -24,13 +27,12 @@ const model: DvaModel<SettingModelState> = {
state: {
isShowPSwModal: false,
isShowTntModal: false,
isShowSAKModal: false,
isShowSSModal: false,
llm_factory: '',
tenantIfo: null,
llmInfo: {},
myLlm: [],
factoriesList: [],
myLlmList: {},
factoryList: [],
userInfo: {} as IUserInfo,
},
reducers: {
@@ -116,16 +118,13 @@ const model: DvaModel<SettingModelState> = {
},
*factories_list({ payload = {} }, { call, put }) {
const { data, response } = yield call(
userService.factories_list,
payload,
);
const { retcode, data: res, retmsg } = data;
const { data } = yield call(userService.factories_list);
const { retcode, data: res } = data;
if (retcode === 0) {
yield put({
type: 'updateState',
payload: {
factoriesList: res,
factoryList: res,
},
});
}
@@ -143,13 +142,13 @@ const model: DvaModel<SettingModelState> = {
}
},
*my_llm({ payload = {} }, { call, put }) {
const { data, response } = yield call(userService.my_llm, payload);
const { retcode, data: res, retmsg } = data;
const { data } = yield call(userService.my_llm, payload);
const { retcode, data: res } = data;
if (retcode === 0) {
yield put({
type: 'updateState',
payload: {
myLlm: res,
myLlmList: res,
},
});
}
@@ -158,14 +157,12 @@ const model: DvaModel<SettingModelState> = {
const { data } = yield call(userService.set_api_key, payload);
const { retcode } = data;
if (retcode === 0) {
message.success('设置API KEY成功');
message.success('Modified!');
yield put({
type: 'updateState',
payload: {
isShowSAKModal: false,
},
});
}
return retcode;
},
},
};