fix: an edge case when start a model with relative model path
This commit is contained in:
parent
a773e169fc
commit
0847b32e87
@ -15,6 +15,7 @@ import {
|
||||
InferenceEngine,
|
||||
getJanDataFolderPath,
|
||||
extractModelLoadParams,
|
||||
fs,
|
||||
} from '@janhq/core'
|
||||
import PQueue from 'p-queue'
|
||||
import ky from 'ky'
|
||||
@ -96,22 +97,24 @@ export default class JanInferenceCortexExtension extends LocalOAIEngine {
|
||||
model.settings = settings
|
||||
}
|
||||
|
||||
return await this.queue.add(() => ky
|
||||
.post(`${CORTEX_API_URL}/v1/models/start`, {
|
||||
json: {
|
||||
...extractModelLoadParams(model.settings),
|
||||
model: model.id,
|
||||
engine:
|
||||
model.engine === InferenceEngine.nitro // Legacy model cache
|
||||
? InferenceEngine.cortex_llamacpp
|
||||
: model.engine,
|
||||
},
|
||||
})
|
||||
.json()
|
||||
.catch(async (e) => {
|
||||
throw (await e.response?.json()) ?? e
|
||||
})
|
||||
.then())
|
||||
return await this.queue.add(() =>
|
||||
ky
|
||||
.post(`${CORTEX_API_URL}/v1/models/start`, {
|
||||
json: {
|
||||
...extractModelLoadParams(model.settings),
|
||||
model: model.id,
|
||||
engine:
|
||||
model.engine === InferenceEngine.nitro // Legacy model cache
|
||||
? InferenceEngine.cortex_llamacpp
|
||||
: model.engine,
|
||||
},
|
||||
})
|
||||
.json()
|
||||
.catch(async (e) => {
|
||||
throw (await e.response?.json()) ?? e
|
||||
})
|
||||
.then()
|
||||
)
|
||||
}
|
||||
|
||||
override async unloadModel(model: Model): Promise<void> {
|
||||
@ -159,7 +162,10 @@ export const getModelFilePath = async (
|
||||
file: string
|
||||
): Promise<string> => {
|
||||
// Symlink to the model file
|
||||
if (!model.sources[0]?.url.startsWith('http')) {
|
||||
if (
|
||||
!model.sources[0]?.url.startsWith('http') &&
|
||||
(await fs.existsSync(model.sources[0].url))
|
||||
) {
|
||||
return model.sources[0]?.url
|
||||
}
|
||||
return joinPath([await getJanDataFolderPath(), 'models', model.id, file])
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user