@@ -206,6 +206,11 @@ const AddModal: FC<AddModalProps> = (props) => {
|
||||
source: props.source
|
||||
});
|
||||
|
||||
// for cancel evaluate request case
|
||||
if (!evaluateRes) {
|
||||
return;
|
||||
}
|
||||
|
||||
const defaultSpec = getDefaultSpec({
|
||||
evaluateResult: evaluateRes
|
||||
});
|
||||
@@ -254,10 +259,14 @@ const AddModal: FC<AddModalProps> = (props) => {
|
||||
}
|
||||
};
|
||||
|
||||
const handleCancelFiles = () => {
|
||||
cancelEvaluate();
|
||||
modelFileRef.current?.cancelRequest();
|
||||
};
|
||||
const handleOnSelectModel = async (item: any) => {
|
||||
// If the item is empty or the same as the selected model, do nothing
|
||||
console.log('handleOnSelectModel', item, selectedModel);
|
||||
modelFileRef.current?.cancelRequest();
|
||||
handleCancelFiles();
|
||||
if (
|
||||
_.isEmpty(item) ||
|
||||
(item.isGGUF === selectedModel.isGGUF && item.name === selectedModel.name)
|
||||
@@ -304,12 +313,18 @@ const AddModal: FC<AddModalProps> = (props) => {
|
||||
state: EvaluateProccess.model,
|
||||
requestModelId: updateRequestModelId()
|
||||
});
|
||||
modelFileRef.current?.cancelRequest();
|
||||
handleCancelFiles();
|
||||
const modelInfo = onSelectModel(item, props.source);
|
||||
|
||||
console.log(
|
||||
'handleOnSelectModelAfterEvaluate',
|
||||
item,
|
||||
evaluateStateRef.current
|
||||
);
|
||||
|
||||
if (
|
||||
evaluateStateRef.current.state === EvaluateProccess.model &&
|
||||
item.evaluateResult
|
||||
item.evaluated
|
||||
) {
|
||||
handleShowCompatibleAlert(item.evaluateResult);
|
||||
form.current?.setFieldsValue?.({
|
||||
@@ -425,6 +440,7 @@ const AddModal: FC<AddModalProps> = (props) => {
|
||||
handleOnOpen();
|
||||
} else {
|
||||
cancelEvaluate();
|
||||
clearCahceFormValues();
|
||||
}
|
||||
return () => {
|
||||
setSelectedModel({});
|
||||
|
||||
@@ -569,7 +569,6 @@ const Models: React.FC<ModelsProps> = ({
|
||||
operation: 'common.start.confirm',
|
||||
async onOk() {
|
||||
await handleBatchRequest(rowSelection.selectedRows, handleStartModel);
|
||||
rowSelection.clearSelections();
|
||||
onStart?.();
|
||||
}
|
||||
});
|
||||
@@ -583,7 +582,6 @@ const Models: React.FC<ModelsProps> = ({
|
||||
operation: 'common.stop.confirm',
|
||||
async onOk() {
|
||||
await handleBatchRequest(rowSelection.selectedRows, handleStopModel);
|
||||
rowSelection.clearSelections();
|
||||
onStop?.(rowSelection.selectedRowKeys as number[]);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -298,6 +298,7 @@ export const useCheckCompatibility = () => {
|
||||
options?: WarningStausOptions
|
||||
) => {
|
||||
const { lockAfterUpdate = false, override = false } = options || {};
|
||||
console.log('updateWarningStatus', params, options);
|
||||
|
||||
setWarningStatus((prev: MessageStatus) => {
|
||||
if (isLockWarningStatus.current && !override) {
|
||||
@@ -348,6 +349,7 @@ export const useCheckCompatibility = () => {
|
||||
const handleCheckCompatibility = (
|
||||
evaluateResult: EvaluateResult | null
|
||||
): MessageStatus => {
|
||||
console.log('handleCheckCompatibility', evaluateResult);
|
||||
if (!evaluateResult) {
|
||||
return {
|
||||
show: false,
|
||||
@@ -586,14 +588,16 @@ export const useCheckCompatibility = () => {
|
||||
);
|
||||
|
||||
const cancelEvaluate = () => {
|
||||
// update the requestId to cancel the current evaluation
|
||||
updateRequestId();
|
||||
checkTokenRef.current?.cancel();
|
||||
checkTokenRef.current = null;
|
||||
cacheFormValuesRef.current = {};
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
return () => {
|
||||
cancelEvaluate();
|
||||
clearCahceFormValues();
|
||||
};
|
||||
}, []);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user