Merge pull request #4050 from janhq/fix/handle-model-import-failure-with-latest-cortex-cpp

fix: handle symlink model import failure - fallback to legacy model run
This commit is contained in:
Louis 2024-11-19 23:29:48 +07:00 committed by GitHub
commit cc2b0c2eb1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -100,12 +100,10 @@ export default class JanInferenceCortexExtension extends LocalOAIEngine {
// Legacy chat model support // Legacy chat model support
model.settings = { model.settings = {
...model.settings, ...model.settings,
llama_model_path: model.file_path llama_model_path: await getModelFilePath(
? await joinPath([ model,
await dirName(model.file_path), model.settings.llama_model_path
model.settings.llama_model_path, ),
])
: await getModelFilePath(model, model.settings.llama_model_path),
} }
} else { } else {
const { llama_model_path, ...settings } = model.settings const { llama_model_path, ...settings } = model.settings
@ -262,7 +260,7 @@ export default class JanInferenceCortexExtension extends LocalOAIEngine {
/// Legacy /// Legacy
const getModelFilePath = async ( const getModelFilePath = async (
model: Model, model: Model & { file_path?: string },
file: string file: string
): Promise<string> => { ): Promise<string> => {
// Symlink to the model file // Symlink to the model file
@ -272,6 +270,9 @@ const getModelFilePath = async (
) { ) {
return model.sources[0]?.url return model.sources[0]?.url
} }
if (model.file_path) {
await joinPath([await dirName(model.file_path), file])
}
return joinPath([await getJanDataFolderPath(), 'models', model.id, file]) return joinPath([await getJanDataFolderPath(), 'models', model.id, file])
} }
/// ///