fix: warning message for gguf model
This commit is contained in:
@@ -116,7 +116,7 @@ export default {
|
|||||||
'models.form.moreparameters': '参数说明',
|
'models.form.moreparameters': '参数说明',
|
||||||
'models.table.vram.allocated': '分配显存',
|
'models.table.vram.allocated': '分配显存',
|
||||||
'models.form.backend.warning':
|
'models.form.backend.warning':
|
||||||
'当前后端不支持 GGUF 格式模型。请在“推理后端”中添加一个支持 GGUF 的后端后再继续。',
|
'当前后端不支持 GGUF 格式模型。请在“推理后端”中添加一个支持 GGUF 的后端。',
|
||||||
'models.form.backend.warning.gguf':
|
'models.form.backend.warning.gguf':
|
||||||
'请确认当前使用的自定义后端已支持 GGUF 格式模型。',
|
'请确认当前使用的自定义后端已支持 GGUF 格式模型。',
|
||||||
'models.form.ollama.warning': '部署 Ollama 模型后端使用 llama-box。',
|
'models.form.ollama.warning': '部署 Ollama 模型后端使用 llama-box。',
|
||||||
|
|||||||
@@ -317,6 +317,24 @@ export const useCheckCompatibility = () => {
|
|||||||
}, 300);
|
}, 300);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const checkIsGGUFFileOrNotSupport = (localPath: string, allValues?: any) => {
|
||||||
|
const isBlobFile = localPath?.split('/').pop()?.includes('sha256');
|
||||||
|
const isOllamaModel = localPath?.includes('ollama');
|
||||||
|
const isGGUFFile = localPath?.endsWith?.('.gguf');
|
||||||
|
|
||||||
|
const isOllamaModelFile = isBlobFile || isOllamaModel;
|
||||||
|
return (
|
||||||
|
isGGUFFile ||
|
||||||
|
isOllamaModelFile ||
|
||||||
|
allValues?.huggingface_filename?.endsWith?.('.gguf') ||
|
||||||
|
allValues?.model_scope_file_path?.endsWith?.('.gguf')
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const clearCacheFormValues = () => {
|
||||||
|
cacheFormValuesRef.current = {};
|
||||||
|
};
|
||||||
|
|
||||||
const updateShowWarning = (params: {
|
const updateShowWarning = (params: {
|
||||||
backend: string;
|
backend: string;
|
||||||
localPath: string;
|
localPath: string;
|
||||||
@@ -330,29 +348,17 @@ export const useCheckCompatibility = () => {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const isBlobFile = localPath?.split('/').pop()?.includes('sha256');
|
const isGGUFFile = checkIsGGUFFileOrNotSupport(localPath);
|
||||||
const isOllamaModel = localPath?.includes('ollama');
|
|
||||||
const isGGUFFile = localPath.endsWith('.gguf');
|
|
||||||
|
|
||||||
const isOllamaModelFile = isBlobFile || isOllamaModel;
|
|
||||||
|
|
||||||
let warningMessage = '';
|
let warningMessage = '';
|
||||||
if (
|
if (isGGUFFile && BuiltInBackendOptions.includes(backend)) {
|
||||||
(isGGUFFile || isOllamaModelFile) &&
|
|
||||||
BuiltInBackendOptions.includes(backend)
|
|
||||||
) {
|
|
||||||
warningMessage = intl.formatMessage({
|
warningMessage = intl.formatMessage({
|
||||||
id: 'models.form.backend.warning'
|
id: 'models.form.backend.warning'
|
||||||
});
|
});
|
||||||
} else if (
|
} else if (isGGUFFile && !BuiltInBackendOptions.includes(backend)) {
|
||||||
(isGGUFFile || isOllamaModelFile) &&
|
warningMessage = '';
|
||||||
!BuiltInBackendOptions.includes(backend)
|
|
||||||
) {
|
|
||||||
warningMessage = intl.formatMessage({
|
|
||||||
id: 'models.form.backend.warning.gguf'
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
clearCacheFormValues();
|
||||||
return {
|
return {
|
||||||
show: !!warningMessage,
|
show: !!warningMessage,
|
||||||
isHtml: true,
|
isHtml: true,
|
||||||
@@ -379,10 +385,6 @@ export const useCheckCompatibility = () => {
|
|||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
const clearCacheFormValues = () => {
|
|
||||||
cacheFormValuesRef.current = {};
|
|
||||||
};
|
|
||||||
|
|
||||||
const noLocalPathValue = (allValues: any) => {
|
const noLocalPathValue = (allValues: any) => {
|
||||||
return (
|
return (
|
||||||
allValues.source === modelSourceMap.local_path_value &&
|
allValues.source === modelSourceMap.local_path_value &&
|
||||||
@@ -396,7 +398,6 @@ export const useCheckCompatibility = () => {
|
|||||||
source: string;
|
source: string;
|
||||||
}) => {
|
}) => {
|
||||||
const { allValues, source } = params;
|
const { allValues, source } = params;
|
||||||
console.log('handleOnValuesChange', allValues);
|
|
||||||
if (
|
if (
|
||||||
_.isEqual(cacheFormValuesRef.current, allValues) ||
|
_.isEqual(cacheFormValuesRef.current, allValues) ||
|
||||||
noLocalPathValue(allValues) ||
|
noLocalPathValue(allValues) ||
|
||||||
@@ -406,6 +407,24 @@ export const useCheckCompatibility = () => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check gguf: for online and local path
|
||||||
|
if (
|
||||||
|
checkIsGGUFFileOrNotSupport(allValues.local_path, allValues) &&
|
||||||
|
BuiltInBackendOptions.includes(allValues.backend)
|
||||||
|
) {
|
||||||
|
clearCacheFormValues();
|
||||||
|
setWarningStatus({
|
||||||
|
show: true,
|
||||||
|
type: 'warning',
|
||||||
|
isHtml: true,
|
||||||
|
message: intl.formatMessage({
|
||||||
|
id: 'models.form.backend.warning'
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
cacheFormValuesRef.current = _.cloneDeep(allValues);
|
cacheFormValuesRef.current = _.cloneDeep(allValues);
|
||||||
const gpuSelector = generateGPUIds(allValues);
|
const gpuSelector = generateGPUIds(allValues);
|
||||||
return await handleDoEvalute({
|
return await handleDoEvalute({
|
||||||
|
|||||||
Reference in New Issue
Block a user