Skip to content

Commit

Permalink
Merge pull request #4307 from janhq/fix/thread-error-handling
Browse files Browse the repository at this point in the history
fix: thread error handling
  • Loading branch information
louis-menlo authored Dec 20, 2024
2 parents 9603d36 + 11f4f20 commit 1acbb33
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
10 changes: 3 additions & 7 deletions web/containers/Providers/ModelHandler.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand All @@ -332,6 +327,7 @@ export default function ModelHandler() {
...updatedThread,
})
})
.catch(console.error)
}

// This is the first time message comes in on a new thread
Expand Down
7 changes: 7 additions & 0 deletions web/hooks/useDeleteThread.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 1acbb33

Please sign in to comment.