diff --git a/web/hooks/useSendChatMessage.ts b/web/hooks/useSendChatMessage.ts index d946adacd0..1ba68f85e0 100644 --- a/web/hooks/useSendChatMessage.ts +++ b/web/hooks/useSendChatMessage.ts @@ -249,6 +249,15 @@ export default function useSendChatMessage() { let modelRequest = selectedModelRef?.current ?? activeThreadRef.current.assistants[0].model + + // Fallback support for previous broken threads + if (activeThreadRef.current?.assistants[0]?.model?.id === '*') { + activeThreadRef.current.assistants[0].model = { + id: modelRequest.id, + settings: modelRequest.settings, + parameters: modelRequest.parameters, + } + } if (runtimeParams.stream == null) { runtimeParams.stream = true } diff --git a/web/screens/Chat/ThreadList/index.tsx b/web/screens/Chat/ThreadList/index.tsx index eb372f6643..d10fca81ba 100644 --- a/web/screens/Chat/ThreadList/index.tsx +++ b/web/screens/Chat/ThreadList/index.tsx @@ -9,6 +9,7 @@ import { GalleryHorizontalEndIcon, MoreVerticalIcon } from 'lucide-react' import { twMerge } from 'tailwind-merge' import { useCreateNewThread } from '@/hooks/useCreateNewThread' +import useRecommendedModel from '@/hooks/useRecommendedModel' import useSetActiveThread from '@/hooks/useSetActiveThread' import { displayDate } from '@/utils/datetime' @@ -35,6 +36,7 @@ export default function ThreadList() { const threadDataReady = useAtomValue(threadDataReadyAtom) const { requestCreateNewThread } = useCreateNewThread() const setEditMessage = useSetAtom(editMessageAtom) + const { recommendedModel, downloadedModels } = useRecommendedModel() const onThreadClick = useCallback( (thread: Thread) => { @@ -50,8 +52,14 @@ export default function ThreadList() { * and there are no threads available */ useEffect(() => { - if (threadDataReady && assistants.length > 0 && threads.length === 0) { - requestCreateNewThread(assistants[0]) + if ( + threadDataReady && + assistants.length > 0 && + threads.length === 0 && + (recommendedModel || downloadedModels[0]) + ) { + const model = recommendedModel || downloadedModels[0] + requestCreateNewThread(assistants[0], model) } else if (threadDataReady && !activeThreadId) { setActiveThread(threads[0]) } @@ -62,6 +70,8 @@ export default function ThreadList() { requestCreateNewThread, activeThreadId, setActiveThread, + recommendedModel, + downloadedModels, ]) return (