balibabu
commited on
Commit
·
853826a
1
Parent(s):
f2de30c
feat: Delete Model Provider #2376 (#2565)
Browse files### What problem does this PR solve?
feat: Delete Model Provider #2376
### Type of change
- [ ] Bug Fix (non-breaking change which fixes an issue)
- [x] New Feature (non-breaking change which adds functionality)
web/src/hooks/llm-hooks.ts
CHANGED
@@ -278,3 +278,26 @@ export const useDeleteLlm = () => {
|
|
278 |
|
279 |
return { data, loading, deleteLlm: mutateAsync };
|
280 |
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
278 |
|
279 |
return { data, loading, deleteLlm: mutateAsync };
|
280 |
};
|
281 |
+
|
282 |
+
export const useDeleteFactory = () => {
|
283 |
+
const queryClient = useQueryClient();
|
284 |
+
const { t } = useTranslation();
|
285 |
+
const {
|
286 |
+
data,
|
287 |
+
isPending: loading,
|
288 |
+
mutateAsync,
|
289 |
+
} = useMutation({
|
290 |
+
mutationKey: ['deleteFactory'],
|
291 |
+
mutationFn: async (params: IDeleteLlmRequestBody) => {
|
292 |
+
const { data } = await userService.deleteFactory(params);
|
293 |
+
if (data.retcode === 0) {
|
294 |
+
queryClient.invalidateQueries({ queryKey: ['myLlmList'] });
|
295 |
+
queryClient.invalidateQueries({ queryKey: ['factoryList'] });
|
296 |
+
message.success(t('message.deleted'));
|
297 |
+
}
|
298 |
+
return data.retcode;
|
299 |
+
},
|
300 |
+
});
|
301 |
+
|
302 |
+
return { data, loading, deleteFactory: mutateAsync };
|
303 |
+
};
|
web/src/interfaces/request/llm.ts
CHANGED
@@ -8,5 +8,5 @@ export interface IAddLlmRequestBody {
|
|
8 |
|
9 |
export interface IDeleteLlmRequestBody {
|
10 |
llm_factory: string; // Ollama
|
11 |
-
llm_name
|
12 |
}
|
|
|
8 |
|
9 |
export interface IDeleteLlmRequestBody {
|
10 |
llm_factory: string; // Ollama
|
11 |
+
llm_name?: string;
|
12 |
}
|
web/src/pages/user-setting/setting-model/hooks.ts
CHANGED
@@ -3,6 +3,7 @@ import {
|
|
3 |
IApiKeySavingParams,
|
4 |
ISystemModelSettingSavingParams,
|
5 |
useAddLlm,
|
|
|
6 |
useDeleteLlm,
|
7 |
useSaveApiKey,
|
8 |
useSaveTenantInfo,
|
@@ -366,3 +367,18 @@ export const useHandleDeleteLlm = (llmFactory: string) => {
|
|
366 |
|
367 |
return { handleDeleteLlm };
|
368 |
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
IApiKeySavingParams,
|
4 |
ISystemModelSettingSavingParams,
|
5 |
useAddLlm,
|
6 |
+
useDeleteFactory,
|
7 |
useDeleteLlm,
|
8 |
useSaveApiKey,
|
9 |
useSaveTenantInfo,
|
|
|
367 |
|
368 |
return { handleDeleteLlm };
|
369 |
};
|
370 |
+
|
371 |
+
export const useHandleDeleteFactory = (llmFactory: string) => {
|
372 |
+
const { deleteFactory } = useDeleteFactory();
|
373 |
+
const showDeleteConfirm = useShowDeleteConfirm();
|
374 |
+
|
375 |
+
const handleDeleteFactory = () => {
|
376 |
+
showDeleteConfirm({
|
377 |
+
onOk: async () => {
|
378 |
+
deleteFactory({ llm_factory: llmFactory });
|
379 |
+
},
|
380 |
+
});
|
381 |
+
};
|
382 |
+
|
383 |
+
return { handleDeleteFactory };
|
384 |
+
};
|
web/src/pages/user-setting/setting-model/index.tsx
CHANGED
@@ -34,6 +34,7 @@ import { IconMap } from './constant';
|
|
34 |
import FishAudioModal from './fish-audio-modal';
|
35 |
import GoogleModal from './google-modal';
|
36 |
import {
|
|
|
37 |
useHandleDeleteLlm,
|
38 |
useSubmitApiKey,
|
39 |
useSubmitBedrock,
|
@@ -75,6 +76,7 @@ const ModelCard = ({ item, clickApiKey }: IModelCardProps) => {
|
|
75 |
const { visible, switchVisible } = useSetModalState();
|
76 |
const { t } = useTranslate('setting');
|
77 |
const { handleDeleteLlm } = useHandleDeleteLlm(item.name);
|
|
|
78 |
|
79 |
const handleApiKeyClick = () => {
|
80 |
clickApiKey(item.name);
|
@@ -118,6 +120,9 @@ const ModelCard = ({ item, clickApiKey }: IModelCardProps) => {
|
|
118 |
<MoreModelIcon />
|
119 |
</Flex>
|
120 |
</Button>
|
|
|
|
|
|
|
121 |
</Space>
|
122 |
</Col>
|
123 |
</Row>
|
|
|
34 |
import FishAudioModal from './fish-audio-modal';
|
35 |
import GoogleModal from './google-modal';
|
36 |
import {
|
37 |
+
useHandleDeleteFactory,
|
38 |
useHandleDeleteLlm,
|
39 |
useSubmitApiKey,
|
40 |
useSubmitBedrock,
|
|
|
76 |
const { visible, switchVisible } = useSetModalState();
|
77 |
const { t } = useTranslate('setting');
|
78 |
const { handleDeleteLlm } = useHandleDeleteLlm(item.name);
|
79 |
+
const { handleDeleteFactory } = useHandleDeleteFactory(item.name);
|
80 |
|
81 |
const handleApiKeyClick = () => {
|
82 |
clickApiKey(item.name);
|
|
|
120 |
<MoreModelIcon />
|
121 |
</Flex>
|
122 |
</Button>
|
123 |
+
<Button type={'text'} onClick={handleDeleteFactory}>
|
124 |
+
<CloseCircleOutlined style={{ color: '#D92D20' }} />
|
125 |
+
</Button>
|
126 |
</Space>
|
127 |
</Col>
|
128 |
</Row>
|
web/src/services/user-service.ts
CHANGED
@@ -16,6 +16,7 @@ const {
|
|
16 |
set_tenant_info,
|
17 |
add_llm,
|
18 |
delete_llm,
|
|
|
19 |
getSystemStatus,
|
20 |
getSystemVersion,
|
21 |
} = api;
|
@@ -81,6 +82,10 @@ const methods = {
|
|
81 |
url: getSystemVersion,
|
82 |
method: 'get',
|
83 |
},
|
|
|
|
|
|
|
|
|
84 |
} as const;
|
85 |
|
86 |
const userService = registerServer<keyof typeof methods>(methods, request);
|
|
|
16 |
set_tenant_info,
|
17 |
add_llm,
|
18 |
delete_llm,
|
19 |
+
deleteFactory,
|
20 |
getSystemStatus,
|
21 |
getSystemVersion,
|
22 |
} = api;
|
|
|
82 |
url: getSystemVersion,
|
83 |
method: 'get',
|
84 |
},
|
85 |
+
deleteFactory: {
|
86 |
+
url: deleteFactory,
|
87 |
+
method: 'post',
|
88 |
+
},
|
89 |
} as const;
|
90 |
|
91 |
const userService = registerServer<keyof typeof methods>(methods, request);
|
web/src/utils/api.ts
CHANGED
@@ -19,6 +19,7 @@ export default {
|
|
19 |
set_api_key: `${api_host}/llm/set_api_key`,
|
20 |
add_llm: `${api_host}/llm/add_llm`,
|
21 |
delete_llm: `${api_host}/llm/delete_llm`,
|
|
|
22 |
|
23 |
// knowledge base
|
24 |
kb_list: `${api_host}/kb/list`,
|
|
|
19 |
set_api_key: `${api_host}/llm/set_api_key`,
|
20 |
add_llm: `${api_host}/llm/add_llm`,
|
21 |
delete_llm: `${api_host}/llm/delete_llm`,
|
22 |
+
deleteFactory: `${api_host}/llm/delete_factory`,
|
23 |
|
24 |
// knowledge base
|
25 |
kb_list: `${api_host}/kb/list`,
|