Merge pull request #4307 from janhq/fix/thread-error-handling
fix: thread error handling
This commit is contained in:
commit
1acbb33677
@ -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
|
||||
|
||||
@ -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)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user