Skip to content

Commit

Permalink
fix: thread title for remote model from first prompt (janhq#3712)
Browse files Browse the repository at this point in the history
* fix: generate title using first prompt for remote model

* fix: disable react-hooks/exhaustive-deps
  • Loading branch information
urmauur authored Sep 20, 2024
1 parent 302b73a commit 9471481
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions web/containers/Providers/EventHandler.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ export default function EventHandler({ children }: { children: ReactNode }) {
// Attempt to generate the title of the Thread when needed
generateThreadTitle(message, thread)
},
// eslint-disable-next-line react-hooks/exhaustive-deps
[setIsGeneratingResponse, updateMessage, updateThread, updateThreadWaiting]
)

Expand All @@ -236,12 +237,29 @@ export default function EventHandler({ children }: { children: ReactNode }) {
return
}

// Check model engine; we don't want to generate a title when it's not a local engine.
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 (
!activeModelRef.current ||
!localEngines.includes(activeModelRef.current?.engine as InferenceEngine)
) {
return
const updatedThread: Thread = {
...thread,
title: (thread.metadata?.lastMessage as string) || defaultThreadTitle,
metadata: thread.metadata,
}
return extensionManager
.get<ConversationalExtension>(ExtensionTypeEnum.Conversational)
?.saveThread({
...updatedThread,
})
.then(() => {
updateThread({
...updatedThread,
})
})
}

// This is the first time message comes in on a new thread
Expand Down

0 comments on commit 9471481

Please sign in to comment.