chore: support editing the model repoID, filename, model path

This commit is contained in:
jialin
2024-12-10 15:43:29 +08:00
parent acf99a6a9e
commit f64e696f7a
12 changed files with 122 additions and 43 deletions
@@ -36,7 +36,6 @@ interface AdvanceConfigProps {
gpuOptions: Array<any>;
action: PageActionType;
source: string;
modelTask: Record<string, any>;
}
const AdvanceConfig: React.FC<AdvanceConfigProps> = (props) => {
+1 -2
View File
@@ -291,7 +291,7 @@ const DataForm: React.FC<DataFormProps> = forwardRef((props, ref) => {
<SealAutoComplete
filterOption
defaultActiveFirstOption
disabled={action === PageAction.EDIT}
disabled={false}
options={ollamaModelOptions}
label={intl.formatMessage({ id: 'model.form.ollama.model' })}
placeholder={intl.formatMessage({ id: 'model.form.ollamaholder' })}
@@ -503,7 +503,6 @@ const DataForm: React.FC<DataFormProps> = forwardRef((props, ref) => {
form={form}
gpuOptions={gpuOptions}
isGGUF={isGGUF}
modelTask={modelTask}
action={action}
source={props.source}
></AdvanceConfig>
+28 -6
View File
@@ -82,8 +82,12 @@ const Models: React.FC<ModelsProps> = ({
const intl = useIntl();
const navigate = useNavigate();
const rowSelection = useTableRowSelection();
const { handleExpandChange, updateExpandedRowKeys, expandedRowKeys } =
useExpandedRowKeys();
const {
handleExpandChange,
updateExpandedRowKeys,
removeExpandedRowKey,
expandedRowKeys
} = useExpandedRowKeys();
const { sortOrder, setSortOrder } = useTableSort({
defaultSortOrder: 'descend'
});
@@ -152,6 +156,20 @@ const Models: React.FC<ModelsProps> = ({
enabled: !openAddModal && !openDeployModal.show && !openLogModal
}
);
useHotkeys(
HotKeys.NEW4.join(','),
() => {
setOpenDeployModal({
show: true,
width: 600,
source: modelSourceMap.local_path_value
});
},
{
preventDefault: true,
enabled: !openAddModal && !openDeployModal.show && !openLogModal
}
);
const sourceOptions = [
{
@@ -299,16 +317,20 @@ const Models: React.FC<ModelsProps> = ({
const result = getSourceRepoConfigValue(openDeployModal.source, data);
await createModel({
const modelData = await createModel({
data: {
...result.values,
..._.omit(data, result.omits)
}
});
console.log('modelData:', modelData);
setOpenDeployModal({
...openDeployModal,
show: false
});
setTimeout(() => {
updateExpandedRowKeys([modelData.id]);
}, 300);
message.success(intl.formatMessage({ id: 'common.message.success' }));
} catch (error) {}
},
@@ -324,7 +346,7 @@ const Models: React.FC<ModelsProps> = ({
name: row.name,
async onOk() {
await deleteModel(row.id);
updateExpandedRowKeys([row.id]);
removeExpandedRowKey([row.id]);
rowSelection.removeSelectedKey(row.id);
}
});
@@ -336,7 +358,7 @@ const Models: React.FC<ModelsProps> = ({
async onOk() {
await handleBatchRequest(rowSelection.selectedRowKeys, deleteModel);
rowSelection.clearSelections();
updateExpandedRowKeys(rowSelection.selectedRowKeys);
removeExpandedRowKey(rowSelection.selectedRowKeys);
}
});
};
@@ -386,7 +408,7 @@ const Models: React.FC<ModelsProps> = ({
async onOk() {
await deleteModelInstance(row.id);
if (list.length === 1) {
updateExpandedRowKeys([row.model_id]);
removeExpandedRowKey([row.model_id]);
}
}
});
+30 -11
View File
@@ -1,3 +1,4 @@
import IconFont from '@/components/icon-font';
import ModalFooter from '@/components/modal-footer';
import SealAutoComplete from '@/components/seal-form/auto-complete';
import SealInput from '@/components/seal-form/seal-input';
@@ -5,7 +6,7 @@ import SealSelect from '@/components/seal-form/seal-select';
import { PageAction } from '@/config';
import { PageActionType } from '@/config/types';
import { useIntl } from '@umijs/max';
import { Form, Modal } from 'antd';
import { Form, Modal, Tooltip, Typography } from 'antd';
import _ from 'lodash';
import React, { memo, useEffect, useMemo, useState } from 'react';
import SimpleBar from 'simplebar-react';
@@ -14,6 +15,7 @@ import { queryGPUList } from '../apis';
import {
backendOptionsMap,
modelSourceMap,
ollamaModelOptions,
setSourceRepoConfigValue
} from '../config';
import { FormData, GPUListItem, ListItem } from '../config/types';
@@ -119,7 +121,7 @@ const UpdateModal: React.FC<AddModalProps> = (props) => {
<SealInput.Input
label={intl.formatMessage({ id: 'models.form.repoid' })}
required
disabled={true}
disabled={false}
></SealInput.Input>
</Form.Item>
{isGGUF && (
@@ -137,14 +139,12 @@ const UpdateModal: React.FC<AddModalProps> = (props) => {
}
]}
>
<SealAutoComplete
filterOption
<SealInput.Input
label={intl.formatMessage({ id: 'models.form.filename' })}
required
options={[]}
loading={loading}
disabled={action === PageAction.EDIT}
></SealAutoComplete>
disabled={false}
></SealInput.Input>
</Form.Item>
)}
</>
@@ -196,12 +196,31 @@ const UpdateModal: React.FC<AddModalProps> = (props) => {
}
]}
>
<SealInput.Input
disabled={action === PageAction.EDIT}
<SealAutoComplete
filterOption
defaultActiveFirstOption
disabled={false}
options={ollamaModelOptions}
label={intl.formatMessage({ id: 'model.form.ollama.model' })}
placeholder={intl.formatMessage({ id: 'model.form.ollamaholder' })}
addAfter={
<Typography.Link
href="https://www.ollama.com/library"
target="_blank"
>
<Tooltip
title={intl.formatMessage({ id: 'models.form.ollamalink' })}
placement="topRight"
>
<IconFont
type="icon-external-link"
className="font-size-14"
></IconFont>
</Tooltip>
</Typography.Link>
}
required
></SealInput.Input>
></SealAutoComplete>
</Form.Item>
</>
);
@@ -226,7 +245,7 @@ const UpdateModal: React.FC<AddModalProps> = (props) => {
]}
>
<SealInput.Input
disabled={action === PageAction.EDIT}
disabled={false}
label={intl.formatMessage({ id: 'models.form.filePath' })}
required
></SealInput.Input>