fix: do not get the backend when local path blur

This commit is contained in:
jialin
2025-03-12 17:41:38 +08:00
parent a7170a4eee
commit fc0899d9d3
5 changed files with 38 additions and 25 deletions
+2 -2
View File
@@ -113,7 +113,7 @@ export default {
'models.form.moreparameters': 'Parameter Description',
'models.table.vram.allocated': 'Allocated VRAM',
'models.form.backend.warning':
'The backend for GGUF format models uses llama-box.',
'The backend for .gguf format models uses llama-box.',
'models.form.backend.warning.llamabox':
'Llama-box only supports GGUF format models. If your model files were downloaded from Ollama, you can ignore this warning.'
'Llama-box only supports .gguf format models. If your model files were downloaded from Ollama, you can ignore this warning.'
};
+2 -2
View File
@@ -108,7 +108,7 @@ export default {
'models.form.releases': '版本',
'models.form.moreparameters': '参数说明',
'models.table.vram.allocated': '分配显存',
'models.form.backend.warning': 'GGUF 格式模型后端用 llama-box。',
'models.form.backend.warning': '.gguf 格式模型后端用 llama-box。',
'models.form.backend.warning.llamabox':
'llama-box 仅支持 GGUF 格式模型,如果您的模型是从 Ollama 下载的模型文件,忽略此警告。'
'llama-box 仅支持 .gguf 格式模型,如果您的模型是从 Ollama 下载的模型文件,忽略此警告。'
};
@@ -79,10 +79,11 @@ const AddModal: React.FC<AddModalProps> = (props) => {
}
};
const updateShowWarning = () => {
const backend = form.current?.getFieldValue?.('backend');
const updateShowWarning = (backend: string) => {
const localPath = form.current?.getFieldValue?.('local_path');
console.log('upateShowWarning', backend, localPath);
if (source !== modelSourceMap.local_path_value || !localPath) {
return;
}
@@ -116,7 +117,7 @@ const AddModal: React.FC<AddModalProps> = (props) => {
if (backend === backendOptionsMap.llamaBox) {
setIsGGUF(true);
}
updateShowWarning();
updateShowWarning(backend);
};
const handleCancel = useCallback(() => {
@@ -95,8 +95,7 @@ const UpdateModal: React.FC<AddModalProps> = (props) => {
}
};
const updateShowWarning = () => {
const backend = form.getFieldValue?.('backend');
const updateShowWarning = (backend: string) => {
const localPath = form.getFieldValue?.('local_path');
if (formData?.source !== modelSourceMap.local_path_value || !localPath) {
@@ -133,7 +132,7 @@ const UpdateModal: React.FC<AddModalProps> = (props) => {
}
form.setFieldValue('backend_version', '');
handleSetGPUIds(val);
updateShowWarning();
updateShowWarning(backend);
};
const handleOnFocus = () => {
+28 -15
View File
@@ -176,21 +176,26 @@ const Models: React.FC = () => {
});
};
const createModelsChunkRequest = useCallback(async () => {
chunkRequedtRef.current?.current?.cancel?.();
try {
const query = {
search: queryParams.search,
categories: queryParams.categories
};
chunkRequedtRef.current = setChunkRequest({
url: `${MODELS_API}?${qs.stringify(_.pickBy(query, (val: any) => !!val))}`,
handler: updateHandler
});
} catch (error) {
// ignore
}
}, [queryParams.categories, queryParams.search]);
const createModelsChunkRequest = useCallback(
async (params?: { search: string; categories: any[] }) => {
const search = params?.search || queryParams.search;
const categories = params?.categories || queryParams.categories;
chunkRequedtRef.current?.current?.cancel?.();
try {
const query = {
search: search,
categories: categories
};
chunkRequedtRef.current = setChunkRequest({
url: `${MODELS_API}?${qs.stringify(_.pickBy(query, (val: any) => !!val))}`,
handler: updateHandler
});
} catch (error) {
// ignore
}
},
[queryParams.categories, queryParams.search]
);
const createModelsInstanceChunkRequest = useCallback(async () => {
chunkInstanceRequedtRef.current?.current?.cancel?.();
@@ -241,6 +246,10 @@ const Models: React.FC = () => {
search: e.target.value
}
});
createModelsChunkRequest({
search: e.target.value,
categories: queryParams.categories
});
}, 350);
const handleNameChange = useCallback(debounceUpdateFilter, [queryParams]);
@@ -259,6 +268,10 @@ const Models: React.FC = () => {
categories: value
}
});
createModelsChunkRequest({
search: queryParams.search,
categories: value
});
},
[queryParams]
);