fix: Add OnModelStopped Event
This commit is contained in:
parent
a8e33c2a97
commit
a51b206cb8
@ -7,6 +7,7 @@ import {
|
|||||||
ThreadMessage,
|
ThreadMessage,
|
||||||
ExtensionType,
|
ExtensionType,
|
||||||
MessageStatus,
|
MessageStatus,
|
||||||
|
Model,
|
||||||
} from '@janhq/core'
|
} from '@janhq/core'
|
||||||
import { ConversationalExtension } from '@janhq/core'
|
import { ConversationalExtension } from '@janhq/core'
|
||||||
import { useAtomValue, useSetAtom } from 'jotai'
|
import { useAtomValue, useSetAtom } from 'jotai'
|
||||||
@ -64,13 +65,13 @@ export default function EventHandler({ children }: { children: ReactNode }) {
|
|||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handleModelStop(res: any) {
|
async function handleModelStopped(model: Model) {
|
||||||
setTimeout(async () => {
|
setTimeout(async () => {
|
||||||
setActiveModel(undefined)
|
setActiveModel(undefined)
|
||||||
setStateModel({ state: 'start', loading: false, model: '' })
|
setStateModel({ state: 'start', loading: false, model: '' })
|
||||||
toaster({
|
toaster({
|
||||||
title: 'Success!',
|
title: 'Success!',
|
||||||
description: `Model ${res.modelId} has been stopped.`,
|
description: `Model ${model.id} has been stopped.`,
|
||||||
})
|
})
|
||||||
}, 500)
|
}, 500)
|
||||||
}
|
}
|
||||||
@ -123,7 +124,7 @@ export default function EventHandler({ children }: { children: ReactNode }) {
|
|||||||
events.on(EventName.OnMessageUpdate, handleMessageResponseUpdate)
|
events.on(EventName.OnMessageUpdate, handleMessageResponseUpdate)
|
||||||
events.on(EventName.OnModelReady, handleModelReady)
|
events.on(EventName.OnModelReady, handleModelReady)
|
||||||
events.on(EventName.OnModelFail, handleModelFail)
|
events.on(EventName.OnModelFail, handleModelFail)
|
||||||
events.on(EventName.OnModelStop, handleModelStop)
|
events.on(EventName.OnModelStopped, handleModelStopped)
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [])
|
}, [])
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user