Merge pull request #4307 from janhq/fix/thread-error-handling

fix: thread error handling
This commit is contained in:
Louis 2024-12-20 16:55:00 +07:00 committed by GitHub
commit 1acbb33677
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 7 deletions

View File

@ -302,15 +302,10 @@ export default function ModelHandler() {
const generateThreadTitle = (message: ThreadMessage, thread: Thread) => {
// If this is the first ever prompt in the thread
if (
(thread.title ?? thread.metadata?.title)?.trim() !== defaultThreadTitle
) {
if ((thread.title ?? thread.metadata?.title)?.trim() !== defaultThreadTitle)
return
}
if (!activeModelRef.current) {
return
}
if (!activeModelRef.current) return
// Check model engine; we don't want to generate a title when it's not a local engine. remote model using first promp
if (!isLocalEngine(activeModelRef.current?.engine as InferenceEngine)) {
@ -332,6 +327,7 @@ export default function ModelHandler() {
...updatedThread,
})
})
.catch(console.error)
}
// This is the first time message comes in on a new thread

View File

@ -37,9 +37,16 @@ export default function useDeleteThread() {
async (threadId: string) => {
const thread = threads.find((c) => c.id === threadId)
if (!thread) return
const availableThreads = threads.filter((c) => c.id !== threadId)
setThreads(availableThreads)
// delete the thread state
deleteThreadState(threadId)
const assistantInfo = await extensionManager
.get<ConversationalExtension>(ExtensionTypeEnum.Conversational)
?.getThreadAssistant(thread.id)
.catch(console.error)
if (!assistantInfo) return
const model = models.find((c) => c.id === assistantInfo?.model?.id)