fix: backend is not updated after changing model

This commit is contained in:
jialin
2025-04-02 11:24:26 +08:00
parent 28a84a90cf
commit b1d7bb9fd7
6 changed files with 40 additions and 18 deletions
+13 -1
View File
@@ -214,6 +214,8 @@ export const useCheckCompatibility = () => {
const intl = useIntl();
const checkTokenRef = useRef<any>(null);
const submitAnyway = useRef<boolean>(false);
const requestIdRef = useRef(0);
const [warningStatus, setWarningStatus] = useState<{
show: boolean;
title?: string;
@@ -225,6 +227,11 @@ export const useCheckCompatibility = () => {
message: []
});
const updateRequestId = () => {
requestIdRef.current += 1;
return requestIdRef.current;
};
const handleEvaluate = async (data: any) => {
try {
checkTokenRef.current?.cancel();
@@ -392,11 +399,15 @@ export const useCheckCompatibility = () => {
const data = getSourceRepoConfigValue(source, allValues);
const gpuSelector = generateGPUIds(data.values);
const currentRequestId = updateRequestId();
const evalutionData = await handleEvaluate({
...data.values,
...gpuSelector
});
handleShowCompatibleAlert?.(evalutionData);
if (currentRequestId === requestIdRef.current) {
handleShowCompatibleAlert?.(evalutionData);
}
}
};
@@ -415,6 +426,7 @@ export const useCheckCompatibility = () => {
handleOnValuesChange: debounceHandleValuesChange,
warningStatus,
checkTokenRef,
submitAnyway,
generateGPUIds,
handleEvaluate,
setWarningStatus