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,
|
InferenceEngine,
|
||||||
getJanDataFolderPath,
|
getJanDataFolderPath,
|
||||||
extractModelLoadParams,
|
extractModelLoadParams,
|
||||||
|
fs,
|
||||||
} from '@janhq/core'
|
} from '@janhq/core'
|
||||||
import PQueue from 'p-queue'
|
import PQueue from 'p-queue'
|
||||||
import ky from 'ky'
|
import ky from 'ky'
|
||||||
@ -96,7 +97,8 @@ export default class JanInferenceCortexExtension extends LocalOAIEngine {
|
|||||||
model.settings = settings
|
model.settings = settings
|
||||||
}
|
}
|
||||||
|
|
||||||
return await this.queue.add(() => ky
|
return await this.queue.add(() =>
|
||||||
|
ky
|
||||||
.post(`${CORTEX_API_URL}/v1/models/start`, {
|
.post(`${CORTEX_API_URL}/v1/models/start`, {
|
||||||
json: {
|
json: {
|
||||||
...extractModelLoadParams(model.settings),
|
...extractModelLoadParams(model.settings),
|
||||||
@ -111,7 +113,8 @@ export default class JanInferenceCortexExtension extends LocalOAIEngine {
|
|||||||
.catch(async (e) => {
|
.catch(async (e) => {
|
||||||
throw (await e.response?.json()) ?? e
|
throw (await e.response?.json()) ?? e
|
||||||
})
|
})
|
||||||
.then())
|
.then()
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
override async unloadModel(model: Model): Promise<void> {
|
override async unloadModel(model: Model): Promise<void> {
|
||||||
@ -159,7 +162,10 @@ export const getModelFilePath = async (
|
|||||||
file: string
|
file: string
|
||||||
): Promise<string> => {
|
): Promise<string> => {
|
||||||
// Symlink to the model file
|
// 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 model.sources[0]?.url
|
||||||
}
|
}
|
||||||
return joinPath([await getJanDataFolderPath(), 'models', model.id, file])
|
return joinPath([await getJanDataFolderPath(), 'models', model.id, file])
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user