chore: model id is optional on import
This commit is contained in:
parent
a986c6de2d
commit
b913af9f88
@ -4,8 +4,10 @@ import {
|
||||
ExtensionTypeEnum,
|
||||
ImportingModel,
|
||||
Model,
|
||||
ModelEvent,
|
||||
ModelExtension,
|
||||
OptionType,
|
||||
events,
|
||||
fs,
|
||||
} from '@janhq/core'
|
||||
|
||||
@ -58,16 +60,17 @@ const useImportModel = () => {
|
||||
|
||||
const importModels = useCallback(
|
||||
(models: ImportingModel[], optionType: OptionType) => {
|
||||
models
|
||||
.filter((e) => !!e.modelId)
|
||||
.map((model) => {
|
||||
if (model.modelId) {
|
||||
const modelId = model.modelId
|
||||
models.map((model) => {
|
||||
const modelId = model.modelId ?? model.path.split('/').pop()
|
||||
if (modelId) {
|
||||
addDownloadingModel(modelId)
|
||||
extensionManager
|
||||
.get<ModelExtension>(ExtensionTypeEnum.Model)
|
||||
?.importModel(model.modelId, model.path, model.name)
|
||||
.finally(() => removeDownloadingModel(modelId))
|
||||
?.importModel(modelId, model.path, model.name)
|
||||
.finally(() => {
|
||||
removeDownloadingModel(modelId)
|
||||
events.emit(ModelEvent.OnModelsUpdate, {})
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user