fix: thread error handling
This commit is contained in:
parent
9603d36a1f
commit
11f4f20120
@ -302,15 +302,10 @@ export default function ModelHandler() {
|
|||||||
|
|
||||||
const generateThreadTitle = (message: ThreadMessage, thread: Thread) => {
|
const generateThreadTitle = (message: ThreadMessage, thread: Thread) => {
|
||||||
// If this is the first ever prompt in the thread
|
// If this is the first ever prompt in the thread
|
||||||
if (
|
if ((thread.title ?? thread.metadata?.title)?.trim() !== defaultThreadTitle)
|
||||||
(thread.title ?? thread.metadata?.title)?.trim() !== defaultThreadTitle
|
|
||||||
) {
|
|
||||||
return
|
return
|
||||||
}
|
|
||||||
|
|
||||||
if (!activeModelRef.current) {
|
if (!activeModelRef.current) return
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check model engine; we don't want to generate a title when it's not a local engine. remote model using first promp
|
// 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)) {
|
if (!isLocalEngine(activeModelRef.current?.engine as InferenceEngine)) {
|
||||||
@ -332,6 +327,7 @@ export default function ModelHandler() {
|
|||||||
...updatedThread,
|
...updatedThread,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
.catch(console.error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is the first time message comes in on a new thread
|
// This is the first time message comes in on a new thread
|
||||||
|
|||||||
@ -37,9 +37,16 @@ export default function useDeleteThread() {
|
|||||||
async (threadId: string) => {
|
async (threadId: string) => {
|
||||||
const thread = threads.find((c) => c.id === threadId)
|
const thread = threads.find((c) => c.id === threadId)
|
||||||
if (!thread) return
|
if (!thread) return
|
||||||
|
const availableThreads = threads.filter((c) => c.id !== threadId)
|
||||||
|
setThreads(availableThreads)
|
||||||
|
|
||||||
|
// delete the thread state
|
||||||
|
deleteThreadState(threadId)
|
||||||
|
|
||||||
const assistantInfo = await extensionManager
|
const assistantInfo = await extensionManager
|
||||||
.get<ConversationalExtension>(ExtensionTypeEnum.Conversational)
|
.get<ConversationalExtension>(ExtensionTypeEnum.Conversational)
|
||||||
?.getThreadAssistant(thread.id)
|
?.getThreadAssistant(thread.id)
|
||||||
|
.catch(console.error)
|
||||||
|
|
||||||
if (!assistantInfo) return
|
if (!assistantInfo) return
|
||||||
const model = models.find((c) => c.id === assistantInfo?.model?.id)
|
const model = models.find((c) => c.id === assistantInfo?.model?.id)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user