feat: Add Event OnModelStop emission to web

This commit is contained in:
hiro 2023-12-05 00:26:19 +07:00
parent a51b206cb8
commit ffbfaf1fd1

View File

@ -1,8 +1,6 @@
/* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/no-explicit-any */
import { import {
EventName, EventName,
ExtensionType,
InferenceExtension,
events, events,
} from '@janhq/core' } from '@janhq/core'
import { Model, ModelSettingParams } from '@janhq/core' import { Model, ModelSettingParams } from '@janhq/core'
@ -60,8 +58,9 @@ export function useActiveModel() {
} }
const stopModel = async (modelId: string) => { const stopModel = async (modelId: string) => {
const model = downloadedModels.find((e) => e.id === modelId)
setStateModel({ state: 'stop', loading: true, model: modelId }) setStateModel({ state: 'stop', loading: true, model: modelId })
events.emit(EventName.OnModelStop, modelId) events.emit(EventName.OnModelStop, model)
} }
return { activeModel, startModel, stopModel, stateModel } return { activeModel, startModel, stopModel, stateModel }