fix: image edit ux
This commit is contained in:
@@ -7,7 +7,12 @@ import { Button, Drawer } from 'antd';
|
||||
import _ from 'lodash';
|
||||
import { memo, useCallback, useEffect, useRef, useState } from 'react';
|
||||
import { queryCatalogItemSpec } from '../apis';
|
||||
import { backendOptionsMap, modelSourceMap, sourceOptions } from '../config';
|
||||
import {
|
||||
backendOptionsMap,
|
||||
modelCategoriesMap,
|
||||
modelSourceMap,
|
||||
sourceOptions
|
||||
} from '../config';
|
||||
import { CatalogSpec, FormData, ListItem } from '../config/types';
|
||||
import ColumnWrapper from './column-wrapper';
|
||||
import DataForm from './data-form';
|
||||
@@ -40,6 +45,7 @@ const backendOptions = [
|
||||
];
|
||||
|
||||
const defaultQuant = ['Q4_K_M'];
|
||||
const EmbeddingRerankFirstQuant = ['FP16'];
|
||||
const AddModal: React.FC<AddModalProps> = (props) => {
|
||||
const {
|
||||
title,
|
||||
@@ -51,7 +57,6 @@ const AddModal: React.FC<AddModalProps> = (props) => {
|
||||
current,
|
||||
width = 600
|
||||
} = props || {};
|
||||
const SEARCH_SOURCE = [];
|
||||
|
||||
const form = useRef<any>({});
|
||||
const intl = useIntl();
|
||||
@@ -69,6 +74,16 @@ const AddModal: React.FC<AddModalProps> = (props) => {
|
||||
form.current?.submit?.();
|
||||
};
|
||||
|
||||
const getDefaultQuant = (data: { category: string; quantOption: string }) => {
|
||||
if (
|
||||
data.category === modelCategoriesMap.embedding ||
|
||||
data.category === modelCategoriesMap.reranker
|
||||
) {
|
||||
return EmbeddingRerankFirstQuant.includes(data.quantOption);
|
||||
}
|
||||
return defaultQuant.includes(data.quantOption);
|
||||
};
|
||||
|
||||
const getModelFile = (spec: CatalogSpec) => {
|
||||
let modelInfo = {};
|
||||
if (spec.source === modelSourceMap.huggingface_value) {
|
||||
@@ -234,7 +249,10 @@ const AddModal: React.FC<AddModalProps> = (props) => {
|
||||
size: _.get(sizeList, '0.value', 0),
|
||||
quantization:
|
||||
_.find(quantizaList, (item: { label: string; value: string }) =>
|
||||
defaultQuant.includes(item.value)
|
||||
getDefaultQuant({
|
||||
category: _.get(current, 'categories.0', ''),
|
||||
quantOption: item.value
|
||||
})
|
||||
)?.value || _.get(quantizaList, '0.value', '')
|
||||
});
|
||||
|
||||
@@ -264,7 +282,10 @@ const AddModal: React.FC<AddModalProps> = (props) => {
|
||||
const source = _.get(sources, '0.value', '');
|
||||
const defaultSpec =
|
||||
_.find(groupList[source], (item: CatalogSpec) => {
|
||||
return defaultQuant.includes(item.quantization);
|
||||
return getDefaultQuant({
|
||||
category: _.get(current, 'categories.0', ''),
|
||||
quantOption: item.quantization
|
||||
});
|
||||
}) || _.get(groupList, `${source}.0`, {});
|
||||
|
||||
setSourceList(sources);
|
||||
@@ -320,7 +341,10 @@ const AddModal: React.FC<AddModalProps> = (props) => {
|
||||
size: val,
|
||||
quantization:
|
||||
_.find(list, (item: { label: string; value: string }) =>
|
||||
defaultQuant.includes(item.value)
|
||||
getDefaultQuant({
|
||||
category: _.get(current, 'categories.0', ''),
|
||||
quantOption: item.value
|
||||
})
|
||||
)?.value || _.get(list, '0.value', '')
|
||||
});
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ import UpdateModel from './update-modal';
|
||||
import ViewLogsModal from './view-logs-modal';
|
||||
|
||||
interface ModelsProps {
|
||||
handleSearch: (e: any) => void;
|
||||
handleSearch: () => void;
|
||||
handleNameChange: (e: any) => void;
|
||||
handleShowSizeChange?: (page: number, size: number) => void;
|
||||
handlePageChange: (page: number, pageSize: number | undefined) => void;
|
||||
@@ -337,7 +337,6 @@ const Models: React.FC<ModelsProps> = ({
|
||||
const handleModalOk = useCallback(
|
||||
async (data: FormData) => {
|
||||
try {
|
||||
console.log('data:', data, openDeployModal);
|
||||
const result = getSourceRepoConfigValue(currentData?.source, data);
|
||||
await updateModel({
|
||||
data: {
|
||||
@@ -348,6 +347,7 @@ const Models: React.FC<ModelsProps> = ({
|
||||
});
|
||||
setOpenAddModal(false);
|
||||
message.success(intl.formatMessage({ id: 'common.message.success' }));
|
||||
handleSearch();
|
||||
} catch (error) {}
|
||||
},
|
||||
[currentData]
|
||||
@@ -385,6 +385,7 @@ const Models: React.FC<ModelsProps> = ({
|
||||
updateExpandedRowKeys([modelData.id, ...expandedRowKeys]);
|
||||
}, 300);
|
||||
message.success(intl.formatMessage({ id: 'common.message.success' }));
|
||||
handleSearch?.();
|
||||
} catch (error) {}
|
||||
},
|
||||
[openDeployModal]
|
||||
@@ -405,6 +406,7 @@ const Models: React.FC<ModelsProps> = ({
|
||||
removeExpandedRowKey([row.id]);
|
||||
rowSelection.removeSelectedKey(row.id);
|
||||
handleDeleteSuccess();
|
||||
handleSearch();
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -419,6 +421,7 @@ const Models: React.FC<ModelsProps> = ({
|
||||
rowSelection.clearSelections();
|
||||
removeExpandedRowKey(rowSelection.selectedRowKeys);
|
||||
handleDeleteSuccess();
|
||||
handleSearch();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user