fix: image editor fit view incorrect, do not query gguf files when gguf unchecked
This commit is contained in:
@@ -128,6 +128,8 @@ const AddModal: React.FC<AddModalProps> = (props) => {
|
||||
'backend_version',
|
||||
'backend_parameters'
|
||||
]);
|
||||
|
||||
// if the backend_parameters is empty, use the defaultSpec.backend_parameters
|
||||
return {
|
||||
...currentData,
|
||||
backend_parameters:
|
||||
|
||||
@@ -3,7 +3,7 @@ import { PageActionType } from '@/config/types';
|
||||
import { CloseOutlined } from '@ant-design/icons';
|
||||
import { useIntl } from '@umijs/max';
|
||||
import { Button, Drawer } from 'antd';
|
||||
import _, { debounce } from 'lodash';
|
||||
import _ from 'lodash';
|
||||
import { FC, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
||||
import styled from 'styled-components';
|
||||
import {
|
||||
@@ -75,6 +75,14 @@ type AddModalProps = {
|
||||
onCancel: () => void;
|
||||
};
|
||||
|
||||
type EvaluateProccessType = 'model' | 'file' | 'form';
|
||||
|
||||
const EvaluateProccess: Record<string, EvaluateProccessType> = {
|
||||
model: 'model',
|
||||
file: 'file',
|
||||
form: 'form'
|
||||
};
|
||||
|
||||
const AddModal: FC<AddModalProps> = (props) => {
|
||||
const {
|
||||
title,
|
||||
@@ -118,7 +126,7 @@ const AddModal: FC<AddModalProps> = (props) => {
|
||||
model: false,
|
||||
file: false
|
||||
});
|
||||
const evaluateStateRef = useRef<{ state: 'model' | 'file' | 'form' }>({
|
||||
const evaluateStateRef = useRef<{ state: EvaluateProccessType }>({
|
||||
state: 'form'
|
||||
});
|
||||
|
||||
@@ -126,7 +134,7 @@ const AddModal: FC<AddModalProps> = (props) => {
|
||||
*
|
||||
* @param state target to distinguish the evaluate state
|
||||
*/
|
||||
const setEvaluteState = (state: 'model' | 'file' | 'form') => {
|
||||
const setEvaluteState = (state: EvaluateProccessType) => {
|
||||
evaluateStateRef.current.state = state;
|
||||
};
|
||||
|
||||
@@ -146,7 +154,7 @@ const AddModal: FC<AddModalProps> = (props) => {
|
||||
allValues: any;
|
||||
source: SourceType;
|
||||
}) => {
|
||||
setEvaluteState('form');
|
||||
setEvaluteState(EvaluateProccess.form);
|
||||
handleOnValuesChangeBefore(data);
|
||||
};
|
||||
|
||||
@@ -186,7 +194,7 @@ const AddModal: FC<AddModalProps> = (props) => {
|
||||
});
|
||||
|
||||
if (item.fakeName) {
|
||||
setEvaluteState('file');
|
||||
setEvaluteState(EvaluateProccess.file);
|
||||
const evaluateRes = await handleEvaluateOnChange?.({
|
||||
changedValues: {},
|
||||
allValues: form.current?.form?.getFieldsValue?.(),
|
||||
@@ -199,7 +207,6 @@ const AddModal: FC<AddModalProps> = (props) => {
|
||||
/**
|
||||
* do not reset backend_parameters when select a model file
|
||||
*/
|
||||
|
||||
const formBackendParameters =
|
||||
form.current?.getFieldValue?.('backend_parameters') || [];
|
||||
|
||||
@@ -219,7 +226,7 @@ const AddModal: FC<AddModalProps> = (props) => {
|
||||
const handleOnSelectModel = (item: any, evaluate?: boolean) => {
|
||||
// when select a model not from the evaluate result,
|
||||
if (!evaluate) {
|
||||
setEvaluteState('model');
|
||||
setEvaluteState(EvaluateProccess.model);
|
||||
setSelectedModel(item);
|
||||
form.current?.form?.resetFields(resetFieldsByModel);
|
||||
const modelInfo = onSelectModel(item, props.source);
|
||||
@@ -260,14 +267,16 @@ const AddModal: FC<AddModalProps> = (props) => {
|
||||
form.current?.submit?.();
|
||||
};
|
||||
|
||||
const debounceFetchModelFiles = debounce(() => {
|
||||
modelFileRef.current?.fetchModelFiles?.();
|
||||
}, 100);
|
||||
|
||||
const handleSetIsGGUF = (flag: boolean) => {
|
||||
const handleSetIsGGUF = async (flag: boolean) => {
|
||||
console.log('handleSetIsGGUF', flag);
|
||||
setIsGGUF(flag);
|
||||
await new Promise((resolve) => {
|
||||
setTimeout(() => {
|
||||
resolve(true);
|
||||
}, 0);
|
||||
});
|
||||
if (flag) {
|
||||
debounceFetchModelFiles();
|
||||
modelFileRef.current?.fetchModelFiles?.();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -313,7 +313,7 @@ const HFModelFile: React.FC<HFModelFileProps> = forwardRef((props, ref) => {
|
||||
return sortType === 'size' ? item.size : item.path;
|
||||
});
|
||||
|
||||
handleSelectModelFile(sortList[0]);
|
||||
handleSelectModelFile(sortList[0] || {});
|
||||
setDataSource({ fileList: sortList, loading: false });
|
||||
} catch (error) {
|
||||
setDataSource({ fileList: [], loading: false });
|
||||
@@ -329,12 +329,6 @@ const HFModelFile: React.FC<HFModelFileProps> = forwardRef((props, ref) => {
|
||||
setDataSource({ ...dataSource, fileList: list });
|
||||
};
|
||||
|
||||
const handleOnEnter = (e: any, item: any) => {
|
||||
e.stopPropagation();
|
||||
if (e.key === 'Enter') {
|
||||
handleSelectModelFile(item);
|
||||
}
|
||||
};
|
||||
useImperativeHandle(ref, () => ({
|
||||
fetchModelFiles: handleFetchModelFiles
|
||||
}));
|
||||
@@ -398,7 +392,6 @@ const HFModelFile: React.FC<HFModelFileProps> = forwardRef((props, ref) => {
|
||||
isEvaluating={isEvaluating}
|
||||
active={item.path === current}
|
||||
handleSelectModelFile={handleSelectModelFile}
|
||||
handleOnEnter={handleOnEnter}
|
||||
></ModelFileItem>
|
||||
);
|
||||
})}
|
||||
|
||||
@@ -17,7 +17,6 @@ interface ModelFileItemProps {
|
||||
isEvaluating: boolean;
|
||||
active: boolean;
|
||||
handleSelectModelFile: (item: any) => void;
|
||||
handleOnEnter: (e: any, item: any) => void;
|
||||
}
|
||||
|
||||
const FilePartsTag = (props: { parts: any[] }) => {
|
||||
@@ -50,13 +49,7 @@ const FilePartsTag = (props: { parts: any[] }) => {
|
||||
};
|
||||
|
||||
const ModelFileItem: React.FC<ModelFileItemProps> = (props) => {
|
||||
const {
|
||||
data: item,
|
||||
isEvaluating,
|
||||
active,
|
||||
handleSelectModelFile,
|
||||
handleOnEnter
|
||||
} = props;
|
||||
const { data: item, isEvaluating, active, handleSelectModelFile } = props;
|
||||
|
||||
const getModelQuantizationType = (item: any) => {
|
||||
let path = item.path;
|
||||
@@ -88,7 +81,6 @@ const ModelFileItem: React.FC<ModelFileItemProps> = (props) => {
|
||||
})}
|
||||
tabIndex={0}
|
||||
onClick={() => handleSelectModelFile(item)}
|
||||
onKeyDown={(e) => handleOnEnter(e, item)}
|
||||
>
|
||||
<div className="title">{item.path}</div>
|
||||
<div className="tags flex-between">
|
||||
|
||||
Reference in New Issue
Block a user