feat: 模型管理相关接口完成联调
parent
7a37d4db6e
commit
cff535675c
@ -0,0 +1,9 @@
|
||||
/*
|
||||
* @Author: donghao donghao@supervision.ltd
|
||||
* @Date: 2024-05-31 14:46:59
|
||||
* @LastEditors: donghao donghao@supervision.ltd
|
||||
* @LastEditTime: 2024-05-31 14:47:08
|
||||
* @FilePath: \general-ai-platform-web\config\defaultApi.ts
|
||||
* @Description: 通用api配置
|
||||
*/
|
||||
export const fileApiActionUrl = '/api/v1/file/upload';
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,164 @@
|
||||
import { apiModelClassificationList, apiModelEdit } from '@/services/business/model';
|
||||
import { isSuccessApi } from '@/utils/forApi';
|
||||
import {
|
||||
ModalForm,
|
||||
ProForm,
|
||||
ProFormRadio,
|
||||
ProFormSelect,
|
||||
ProFormText,
|
||||
ProFormTextArea,
|
||||
} from '@ant-design/pro-components';
|
||||
import { FormattedMessage, useIntl } from '@umijs/max';
|
||||
import { Form, message } from 'antd';
|
||||
import React, { useEffect } from 'react';
|
||||
import {
|
||||
proFormSmallItemStyleProps,
|
||||
proFormSmallModelWidth,
|
||||
} from '../../../../../config/defaultForm';
|
||||
|
||||
export type UpdateFormProps = {
|
||||
updateModalOpen: boolean;
|
||||
values: Record<string, any>;
|
||||
handleModal: () => void;
|
||||
reload: any;
|
||||
};
|
||||
|
||||
const UpdateForm: React.FC<UpdateFormProps> = (props) => {
|
||||
const intl = useIntl();
|
||||
const [form] = Form.useForm<Record<string, any>>();
|
||||
function resetForm() {
|
||||
form.resetFields();
|
||||
}
|
||||
useEffect(() => {
|
||||
if (props.updateModalOpen && props.values?.id) {
|
||||
form.setFieldsValue({ ...props.values, classification: props.values?.classification_id });
|
||||
console.log(props.values, 'useEffect_values');
|
||||
} else {
|
||||
resetForm();
|
||||
}
|
||||
}, [props.updateModalOpen, props.values]);
|
||||
return (
|
||||
<ModalForm<Record<string, any>>
|
||||
className="gn_form gn_modal_form"
|
||||
width={proFormSmallModelWidth}
|
||||
title={intl.formatMessage({
|
||||
id: 'model_index.form.action.edit',
|
||||
defaultMessage: '编辑',
|
||||
})}
|
||||
open={props.updateModalOpen}
|
||||
form={form}
|
||||
autoFocusFirstInput
|
||||
modalProps={{
|
||||
destroyOnClose: true,
|
||||
onCancel: () => props.handleModal(),
|
||||
}}
|
||||
submitTimeout={2000}
|
||||
onFinish={async (values) => {
|
||||
console.log(values, 'add_finish_values');
|
||||
let resp = await apiModelEdit({
|
||||
...values,
|
||||
id: props.values?.id,
|
||||
});
|
||||
if (isSuccessApi(resp)) {
|
||||
message.success(
|
||||
intl.formatMessage({ id: 'common.action.success', defaultMessage: '$$$' }),
|
||||
);
|
||||
props.reload();
|
||||
props.handleModal();
|
||||
} else {
|
||||
message.error(
|
||||
resp?.meta?.message ||
|
||||
intl.formatMessage({ id: 'common.action.failure', defaultMessage: '$$$' }),
|
||||
);
|
||||
}
|
||||
props.handleModal();
|
||||
return true;
|
||||
}}
|
||||
>
|
||||
<ProForm.Group>
|
||||
<ProFormText
|
||||
width={proFormSmallItemStyleProps.width}
|
||||
name="name"
|
||||
label={<FormattedMessage id="model_index.create.form.name" defaultMessage="名称" />}
|
||||
placeholder={`${intl.formatMessage({
|
||||
id: 'common.please_input',
|
||||
defaultMessage: '$$$',
|
||||
})}${intl.formatMessage({
|
||||
id: 'model_index.create.form.name',
|
||||
defaultMessage: '$$$',
|
||||
})}`}
|
||||
required={true}
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: (
|
||||
<FormattedMessage
|
||||
id="model_index.create.form.rule.required.name"
|
||||
defaultMessage="name is required"
|
||||
/>
|
||||
),
|
||||
},
|
||||
]}
|
||||
/>
|
||||
<ProFormRadio.Group
|
||||
name="model_type"
|
||||
label={<FormattedMessage id="model_index.create.form.type" defaultMessage="分类" />}
|
||||
radioType="button"
|
||||
options={[
|
||||
{ label: '经典算法', value: 1001 },
|
||||
{ label: '机器学习', value: 1002 },
|
||||
]}
|
||||
required={true}
|
||||
/>
|
||||
<ProFormSelect
|
||||
width={proFormSmallItemStyleProps.width}
|
||||
name="classification"
|
||||
label={<FormattedMessage id="model_index.create.form.industry" defaultMessage="行业" />}
|
||||
placeholder={`${intl.formatMessage({
|
||||
id: 'common.please_select',
|
||||
defaultMessage: '$$$',
|
||||
})}${intl.formatMessage({
|
||||
id: 'model_index.create.form.industry',
|
||||
defaultMessage: '$$$',
|
||||
})}`}
|
||||
required={true}
|
||||
showSearch
|
||||
debounceTime={500}
|
||||
request={async () => {
|
||||
const { data } = await apiModelClassificationList();
|
||||
console.log(data, 'apiModelClassificationList_data');
|
||||
return data?.data?.map((v: Record<string, any>) => {
|
||||
return { ...v, label: v.name, value: v.id };
|
||||
});
|
||||
}}
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: (
|
||||
<FormattedMessage
|
||||
id="model_index.create.form.rule.required.industry"
|
||||
defaultMessage="name is required"
|
||||
/>
|
||||
),
|
||||
},
|
||||
]}
|
||||
/>
|
||||
<ProFormTextArea
|
||||
width={proFormSmallItemStyleProps.width}
|
||||
name="comment"
|
||||
label={<FormattedMessage id="model_index.create.form.remark" defaultMessage="简介" />}
|
||||
placeholder={`${intl.formatMessage({
|
||||
id: 'common.please_input',
|
||||
defaultMessage: '$$$',
|
||||
})}${intl.formatMessage({
|
||||
id: 'model_index.create.form.remark',
|
||||
defaultMessage: '$$$',
|
||||
})}`}
|
||||
required={false}
|
||||
disabled={false}
|
||||
/>
|
||||
</ProForm.Group>
|
||||
</ModalForm>
|
||||
);
|
||||
};
|
||||
export default UpdateForm;
|
@ -1,308 +0,0 @@
|
||||
/*
|
||||
* @Author: donghao donghao@supervision.ltd
|
||||
* @Date: 2024-05-24 17:57:19
|
||||
* @LastEditors: donghao donghao@supervision.ltd
|
||||
* @LastEditTime: 2024-05-30 14:44:21
|
||||
* @FilePath: \general-ai-platform-web\src\services\business\basemodel.ts
|
||||
* @Description: 基础模型
|
||||
*/
|
||||
// @ts-ignore
|
||||
/* eslint-disable */
|
||||
import { request } from '@umijs/max';
|
||||
|
||||
/** 基础模型管理 */
|
||||
// 添加模型分类
|
||||
export async function apiBasemodelClassificationAdd(body: any, options?: { [key: string]: any }) {
|
||||
return request<API.Response & { data?: API.ENTITY_INDEX_DATA; msg?: string }>(
|
||||
`/api/v1/basemodel/classification/add`,
|
||||
{
|
||||
method: 'POST',
|
||||
headers: {
|
||||
// 'Content-Type': 'application/json',
|
||||
// "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
|
||||
},
|
||||
data: body,
|
||||
...(options || {}),
|
||||
},
|
||||
);
|
||||
}
|
||||
// 模型分类列表
|
||||
export async function apiBasemodelClassificationList(body: any, options?: { [key: string]: any }) {
|
||||
return request<API.Response & { data?: API.ENTITY_INDEX_DATA; msg?: string }>(
|
||||
`/api/v1/basemodel/classification/list`,
|
||||
{
|
||||
method: 'POST',
|
||||
headers: {
|
||||
// 'Content-Type': 'application/json',
|
||||
// "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
|
||||
},
|
||||
data: body,
|
||||
...(options || {}),
|
||||
},
|
||||
);
|
||||
}
|
||||
// 删除模型分类
|
||||
export async function apiBasemodelClassificationDelete(
|
||||
body: any,
|
||||
options?: { [key: string]: any },
|
||||
) {
|
||||
return request<API.Response & { data?: API.ENTITY_INDEX_DATA; msg?: string }>(
|
||||
`/api/v1/basemodel/classification/delete`,
|
||||
{
|
||||
method: 'POST',
|
||||
headers: {
|
||||
// 'Content-Type': 'application/json',
|
||||
// "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
|
||||
},
|
||||
data: body,
|
||||
...(options || {}),
|
||||
},
|
||||
);
|
||||
}
|
||||
// 添加模型
|
||||
export async function apiBasemodelAdd(body: any, options?: { [key: string]: any }) {
|
||||
return request<API.Response & { data?: API.ENTITY_INDEX_DATA; msg?: string }>(
|
||||
`/api/v1/basemodel/add`,
|
||||
{
|
||||
method: 'POST',
|
||||
headers: {
|
||||
// 'Content-Type': 'application/json',
|
||||
// "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
|
||||
},
|
||||
data: body,
|
||||
...(options || {}),
|
||||
},
|
||||
);
|
||||
}
|
||||
// 模型列表
|
||||
export async function apiBasemodelList(body: any, options?: { [key: string]: any }) {
|
||||
return request<API.Response & { data?: API.ENTITY_INDEX_DATA; msg?: string }>(
|
||||
`/api/v1/basemodel/list`,
|
||||
{
|
||||
method: 'POST',
|
||||
headers: {
|
||||
// 'Content-Type': 'application/json',
|
||||
// "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
|
||||
},
|
||||
data: body,
|
||||
...(options || {}),
|
||||
},
|
||||
);
|
||||
}
|
||||
// 删除模型
|
||||
export async function apiBasemodelDelete(body: any, options?: { [key: string]: any }) {
|
||||
return request<API.Response & { data?: API.ENTITY_INDEX_DATA; msg?: string }>(
|
||||
`/api/v1/basemodel/delete`,
|
||||
{
|
||||
method: 'POST',
|
||||
headers: {
|
||||
// 'Content-Type': 'application/json',
|
||||
// "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
|
||||
},
|
||||
data: body,
|
||||
...(options || {}),
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
// 编辑模型
|
||||
export async function apiBasemodelEdit(body: any, options?: { [key: string]: any }) {
|
||||
return request<API.Response & { data?: API.ENTITY_INDEX_DATA; msg?: string }>(
|
||||
`/api/v1/basemodel/edit`,
|
||||
{
|
||||
method: 'POST',
|
||||
headers: {
|
||||
// 'Content-Type': 'application/json',
|
||||
// "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
|
||||
},
|
||||
data: body,
|
||||
...(options || {}),
|
||||
},
|
||||
);
|
||||
}
|
||||
// 模型信息
|
||||
export async function apiBasemodelInfo(body: any, options?: { [key: string]: any }) {
|
||||
return request<API.Response & { data?: API.ENTITY_INDEX_DATA; msg?: string }>(
|
||||
`/api/v1/basemodel/info`,
|
||||
{
|
||||
method: 'POST',
|
||||
headers: {
|
||||
// 'Content-Type': 'application/json',
|
||||
// "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
|
||||
},
|
||||
data: body,
|
||||
...(options || {}),
|
||||
},
|
||||
);
|
||||
}
|
||||
/** 模型版本 */
|
||||
// 添加模型版本
|
||||
export async function apiBasemodelVersionAdd(body: any, options?: { [key: string]: any }) {
|
||||
return request<API.Response & { data?: API.ENTITY_INDEX_DATA; msg?: string }>(
|
||||
`/api/v1/basemodel/version/add`,
|
||||
{
|
||||
method: 'POST',
|
||||
headers: {
|
||||
// 'Content-Type': 'application/json',
|
||||
// "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
|
||||
},
|
||||
data: body,
|
||||
...(options || {}),
|
||||
},
|
||||
);
|
||||
}
|
||||
// 编辑模型版本
|
||||
export async function apiBasemodelVersionEdit(body: any, options?: { [key: string]: any }) {
|
||||
return request<API.Response & { data?: API.ENTITY_INDEX_DATA; msg?: string }>(
|
||||
`/api/v1/basemodel/version/edit`,
|
||||
{
|
||||
method: 'POST',
|
||||
headers: {
|
||||
// 'Content-Type': 'application/json',
|
||||
// "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
|
||||
},
|
||||
data: body,
|
||||
...(options || {}),
|
||||
},
|
||||
);
|
||||
}
|
||||
// 模型版本列表
|
||||
export async function apiBasemodelVersionList(body: any, options?: { [key: string]: any }) {
|
||||
return request<API.Response & { data?: API.ENTITY_INDEX_DATA; msg?: string }>(
|
||||
`/api/v1/basemodel/version/list`,
|
||||
{
|
||||
method: 'POST',
|
||||
headers: {
|
||||
// 'Content-Type': 'application/json',
|
||||
// "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
|
||||
},
|
||||
data: body,
|
||||
...(options || {}),
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
// 模型版本信息
|
||||
export async function apiBasemodelVersionInfo(body: any, options?: { [key: string]: any }) {
|
||||
return request<API.Response & { data?: API.ENTITY_INDEX_DATA; msg?: string }>(
|
||||
`/api/v1/basemodel/version/info`,
|
||||
{
|
||||
method: 'POST',
|
||||
headers: {
|
||||
// 'Content-Type': 'application/json',
|
||||
// "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
|
||||
},
|
||||
data: body,
|
||||
...(options || {}),
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
// 设置模型默认版本
|
||||
export async function apiBasemodelVersionSetdefault(body: any, options?: { [key: string]: any }) {
|
||||
return request<API.Response & { data?: API.ENTITY_INDEX_DATA; msg?: string }>(
|
||||
`/api/v1/basemodel/version/setdefault`,
|
||||
{
|
||||
method: 'POST',
|
||||
headers: {
|
||||
// 'Content-Type': 'application/json',
|
||||
// "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
|
||||
},
|
||||
data: body,
|
||||
...(options || {}),
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
// 删除模型版本
|
||||
export async function apiBasemodelVersionDelete(body: any, options?: { [key: string]: any }) {
|
||||
return request<API.Response & { data?: API.ENTITY_INDEX_DATA; msg?: string }>(
|
||||
`/api/v1/basemodel/version/delete`,
|
||||
{
|
||||
method: 'POST',
|
||||
headers: {
|
||||
// 'Content-Type': 'application/json',
|
||||
// "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
|
||||
},
|
||||
data: body,
|
||||
...(options || {}),
|
||||
},
|
||||
);
|
||||
}
|
||||
/** 模型运行库 */
|
||||
// 添加模型运行库
|
||||
export async function apiBasemodelHubAdd(body: any, options?: { [key: string]: any }) {
|
||||
return request<API.Response & { data?: API.ENTITY_INDEX_DATA; msg?: string }>(
|
||||
`/api/v1/basemodel/hub/add`,
|
||||
{
|
||||
method: 'POST',
|
||||
headers: {
|
||||
// 'Content-Type': 'application/json',
|
||||
// "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
|
||||
},
|
||||
data: body,
|
||||
...(options || {}),
|
||||
},
|
||||
);
|
||||
}
|
||||
// 编辑模型运行库
|
||||
export async function apiBasemodelHubEdit(body: any, options?: { [key: string]: any }) {
|
||||
return request<API.Response & { data?: API.ENTITY_INDEX_DATA; msg?: string }>(
|
||||
`/api/v1/basemodel/hub/edit`,
|
||||
{
|
||||
method: 'POST',
|
||||
headers: {
|
||||
// 'Content-Type': 'application/json',
|
||||
// "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
|
||||
},
|
||||
data: body,
|
||||
...(options || {}),
|
||||
},
|
||||
);
|
||||
}
|
||||
// 模型运行库列表
|
||||
export async function apiBasemodelHubList(body: any, options?: { [key: string]: any }) {
|
||||
return request<API.Response & { data?: API.ENTITY_INDEX_DATA; msg?: string }>(
|
||||
`/api/v1/basemodel/hub/list`,
|
||||
{
|
||||
method: 'POST',
|
||||
headers: {
|
||||
// 'Content-Type': 'application/json',
|
||||
// "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
|
||||
},
|
||||
data: body,
|
||||
...(options || {}),
|
||||
},
|
||||
);
|
||||
}
|
||||
// 删除模型运行库
|
||||
export async function apiBasemodelHubDelete(body: any, options?: { [key: string]: any }) {
|
||||
return request<API.Response & { data?: API.ENTITY_INDEX_DATA; msg?: string }>(
|
||||
`/api/v1/basemodel/hub/delete`,
|
||||
{
|
||||
method: 'POST',
|
||||
headers: {
|
||||
// 'Content-Type': 'application/json',
|
||||
// "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
|
||||
},
|
||||
data: body,
|
||||
...(options || {}),
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
// 模型运行库信息
|
||||
export async function apiBasemodelHubInfo(body: any, options?: { [key: string]: any }) {
|
||||
return request<API.Response & { data?: API.ENTITY_INDEX_DATA; msg?: string }>(
|
||||
`/api/v1/basemodel/hub/info`,
|
||||
{
|
||||
method: 'POST',
|
||||
headers: {
|
||||
// 'Content-Type': 'application/json',
|
||||
// "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
|
||||
},
|
||||
data: body,
|
||||
...(options || {}),
|
||||
},
|
||||
);
|
||||
}
|
Loading…
Reference in New Issue