fix: thread title for remote model from first prompt (#3712)

* fix: generate title using first prompt for remote model

* fix: disable react-hooks/exhaustive-deps
This commit is contained in:
Faisal Amir 2024-09-20 18:15:06 +07:00 committed by GitHub
parent 302b73ae73
commit 9471481e33
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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]
)
@ -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