Jan is an open source alternative to ChatGPT that runs 100% offline on your computer.
fix: compatibility imported model
Faisal Amirf6e4d55f5ec5
diff --git a/web-app/src/containers/ModelSupportStatus.tsx b/web-app/src/containers/ModelSupportStatus.tsxindex 3667f4461..43827f58e 100644--- a/web-app/src/containers/ModelSupportStatus.tsx+++ b/web-app/src/containers/ModelSupportStatus.tsx@@ -7,7 +7,8 @@ import {TooltipTrigger,} from '@/components/ui/tooltip'import { isModelSupported } from '@/services/models'-import { getJanDataFolderPath, joinPath } from '@janhq/core'+import { getJanDataFolderPath, joinPath, fs } from '@janhq/core'+import { invoke } from '@tauri-apps/api/core'interface ModelSupportStatusProps {modelId: string | undefined@@ -31,12 +32,12 @@ export const ModelSupportStatus = ({async (id: string,ctxSize: number- ): Promise<'RED' | 'YELLOW' | 'GREEN'> => {+ ): Promise<'RED' | 'YELLOW' | 'GREEN' | null> => {try {- // Get Jan's data folder path and construct the full model file path- // Following the llamacpp extension structure: <Jan's data folder>/llamacpp/models/<modelId>/model.ggufconst janDataFolder = await getJanDataFolderPath()- const modelFilePath = await joinPath([++ // First try the standard downloaded model path+ const ggufModelPath = await joinPath([janDataFolder,'llamacpp','models',@@ -44,14 +45,47 @@ export const ModelSupportStatus = ({'model.gguf',])- return await isModelSupported(modelFilePath, ctxSize)+ // Check if the standard model.gguf file exists+ if (await fs.existsSync(ggufModelPath)) {+ return await isModelSupported(ggufModelPath, ctxSize)+ }++ // If model.gguf doesn't exist, try reading from model.yml (for imported models)+ const modelConfigPath = await joinPath([+ janDataFolder,+ 'llamacpp',+ 'models',+ id,+ 'model.yml',+ ])++ if (!(await fs.existsSync(modelConfigPath))) {+ console.error(+ `Neither model.gguf nor model.yml found for model: ${id}`+ )+ return null+ }++ // Read the model configuration to get the actual model path+ const modelConfig = await invoke<{ model_path: string }>('read_yaml', {+ path: `llamacpp/models/${id}/model.yml`,+ })++ // Handle both absolute and relative paths+ const actualModelPath =+ modelConfig.model_path.startsWith('/') ||+ modelConfig.model_path.match(/^[A-Za-z]:/)+ ? modelConfig.model_path // absolute path, use as-is+ : await joinPath([janDataFolder, modelConfig.model_path]) // relative path, join with data folder++ return await isModelSupported(actualModelPath, ctxSize)} catch (error) {console.error(- 'Error checking model support with constructed path:',+ 'Error checking model support with path resolution:',error)// If path construction or model support check fails, assume not supported- return 'RED'+ return null}},[]