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