fix: missing load model error message (#2581)
This commit is contained in:
parent
9797e5b05f
commit
6f0ee23776
@ -107,7 +107,7 @@ export function useActiveModel() {
|
|||||||
toaster({
|
toaster({
|
||||||
title: 'Failed!',
|
title: 'Failed!',
|
||||||
description: `Model ${model.id} failed to start.`,
|
description: `Model ${model.id} failed to start.`,
|
||||||
type: 'success',
|
type: 'error',
|
||||||
})
|
})
|
||||||
setLoadModelError(error)
|
setLoadModelError(error)
|
||||||
return Promise.reject(error)
|
return Promise.reject(error)
|
||||||
|
|||||||
@ -3,10 +3,14 @@ import ScrollToBottom from 'react-scroll-to-bottom'
|
|||||||
import { MessageStatus } from '@janhq/core'
|
import { MessageStatus } from '@janhq/core'
|
||||||
import { useAtomValue } from 'jotai'
|
import { useAtomValue } from 'jotai'
|
||||||
|
|
||||||
|
import { loadModelErrorAtom } from '@/hooks/useActiveModel'
|
||||||
|
|
||||||
import ChatItem from '../ChatItem'
|
import ChatItem from '../ChatItem'
|
||||||
|
|
||||||
import ErrorMessage from '../ErrorMessage'
|
import ErrorMessage from '../ErrorMessage'
|
||||||
|
|
||||||
|
import LoadModelError from '../LoadModelError'
|
||||||
|
|
||||||
import EmptyModel from './EmptyModel'
|
import EmptyModel from './EmptyModel'
|
||||||
import EmptyThread from './EmptyThread'
|
import EmptyThread from './EmptyThread'
|
||||||
|
|
||||||
@ -16,6 +20,7 @@ import { downloadedModelsAtom } from '@/helpers/atoms/Model.atom'
|
|||||||
const ChatBody: React.FC = () => {
|
const ChatBody: React.FC = () => {
|
||||||
const messages = useAtomValue(getCurrentChatMessagesAtom)
|
const messages = useAtomValue(getCurrentChatMessagesAtom)
|
||||||
const downloadedModels = useAtomValue(downloadedModelsAtom)
|
const downloadedModels = useAtomValue(downloadedModelsAtom)
|
||||||
|
const loadModelError = useAtomValue(loadModelErrorAtom)
|
||||||
|
|
||||||
if (downloadedModels.length === 0) return <EmptyModel />
|
if (downloadedModels.length === 0) return <EmptyModel />
|
||||||
if (messages.length === 0) return <EmptyThread />
|
if (messages.length === 0) return <EmptyThread />
|
||||||
@ -29,9 +34,15 @@ const ChatBody: React.FC = () => {
|
|||||||
<ChatItem {...message} key={message.id} />
|
<ChatItem {...message} key={message.id} />
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{(message.status === MessageStatus.Error ||
|
{loadModelError ? (
|
||||||
message.status === MessageStatus.Stopped) &&
|
<LoadModelError />
|
||||||
index === messages.length - 1 && <ErrorMessage message={message} />}
|
) : (
|
||||||
|
index === messages.length - 1 &&
|
||||||
|
message.status !== MessageStatus.Pending &&
|
||||||
|
message.status !== MessageStatus.Ready && (
|
||||||
|
<ErrorMessage message={message} />
|
||||||
|
)
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
</ScrollToBottom>
|
</ScrollToBottom>
|
||||||
|
|||||||
@ -10,7 +10,6 @@ import ModalTroubleShooting, {
|
|||||||
|
|
||||||
import { MainViewState } from '@/constants/screens'
|
import { MainViewState } from '@/constants/screens'
|
||||||
|
|
||||||
import { loadModelErrorAtom } from '@/hooks/useActiveModel'
|
|
||||||
import useSendChatMessage from '@/hooks/useSendChatMessage'
|
import useSendChatMessage from '@/hooks/useSendChatMessage'
|
||||||
|
|
||||||
import { mainViewStateAtom } from '@/helpers/atoms/App.atom'
|
import { mainViewStateAtom } from '@/helpers/atoms/App.atom'
|
||||||
@ -20,9 +19,7 @@ const ErrorMessage = ({ message }: { message: ThreadMessage }) => {
|
|||||||
const messages = useAtomValue(getCurrentChatMessagesAtom)
|
const messages = useAtomValue(getCurrentChatMessagesAtom)
|
||||||
const { resendChatMessage } = useSendChatMessage()
|
const { resendChatMessage } = useSendChatMessage()
|
||||||
const setModalTroubleShooting = useSetAtom(modalTroubleShootingAtom)
|
const setModalTroubleShooting = useSetAtom(modalTroubleShootingAtom)
|
||||||
const loadModelError = useAtomValue(loadModelErrorAtom)
|
|
||||||
const setMainState = useSetAtom(mainViewStateAtom)
|
const setMainState = useSetAtom(mainViewStateAtom)
|
||||||
const PORT_NOT_AVAILABLE = 'PORT_NOT_AVAILABLE'
|
|
||||||
|
|
||||||
const regenerateMessage = async () => {
|
const regenerateMessage = async () => {
|
||||||
const lastMessageIndex = messages.length - 1
|
const lastMessageIndex = messages.length - 1
|
||||||
@ -77,63 +74,23 @@ const ErrorMessage = ({ message }: { message: ThreadMessage }) => {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{message.status === MessageStatus.Error && (
|
{message.status === MessageStatus.Error && (
|
||||||
<>
|
<div
|
||||||
{loadModelError === PORT_NOT_AVAILABLE ? (
|
key={message.id}
|
||||||
<div
|
className="mx-6 flex flex-col items-center space-y-2 text-center text-sm font-medium text-gray-500"
|
||||||
key={message.id}
|
>
|
||||||
className="flex w-full flex-col items-center text-center text-sm font-medium text-gray-500"
|
{getErrorTitle()}
|
||||||
|
<p>
|
||||||
|
Jan’s in beta. Access
|
||||||
|
<span
|
||||||
|
className="cursor-pointer text-primary dark:text-blue-400"
|
||||||
|
onClick={() => setModalTroubleShooting(true)}
|
||||||
>
|
>
|
||||||
<p className="w-[90%]">
|
troubleshooting assistance
|
||||||
Port 3928 is currently unavailable. Check for conflicting apps,
|
</span>
|
||||||
or access
|
now.
|
||||||
<span
|
</p>
|
||||||
className="cursor-pointer text-primary dark:text-blue-400"
|
<ModalTroubleShooting />
|
||||||
onClick={() => setModalTroubleShooting(true)}
|
</div>
|
||||||
>
|
|
||||||
troubleshooting assistance
|
|
||||||
</span>
|
|
||||||
for further support.
|
|
||||||
</p>
|
|
||||||
<ModalTroubleShooting />
|
|
||||||
</div>
|
|
||||||
) : loadModelError &&
|
|
||||||
loadModelError?.includes('EXTENSION_IS_NOT_INSTALLED') ? (
|
|
||||||
<div
|
|
||||||
key={message.id}
|
|
||||||
className="flex w-full flex-col items-center text-center text-sm font-medium text-gray-500"
|
|
||||||
>
|
|
||||||
<p className="w-[90%]">
|
|
||||||
Model is currently unavailable. Please switch to a different
|
|
||||||
model or install the{' '}
|
|
||||||
<button
|
|
||||||
className="font-medium text-primary dark:text-blue-400"
|
|
||||||
onClick={() => setMainState(MainViewState.Settings)}
|
|
||||||
>
|
|
||||||
{loadModelError.split('::')[1] ?? ''}
|
|
||||||
</button>{' '}
|
|
||||||
to continue using it.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
) : (
|
|
||||||
<div
|
|
||||||
key={message.id}
|
|
||||||
className="mx-6 flex flex-col items-center space-y-2 text-center text-sm font-medium text-gray-500"
|
|
||||||
>
|
|
||||||
{getErrorTitle()}
|
|
||||||
<p>
|
|
||||||
Jan’s in beta. Access
|
|
||||||
<span
|
|
||||||
className="cursor-pointer text-primary dark:text-blue-400"
|
|
||||||
onClick={() => setModalTroubleShooting(true)}
|
|
||||||
>
|
|
||||||
troubleshooting assistance
|
|
||||||
</span>
|
|
||||||
now.
|
|
||||||
</p>
|
|
||||||
<ModalTroubleShooting />
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</>
|
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|||||||
70
web/screens/Chat/LoadModelError/index.tsx
Normal file
70
web/screens/Chat/LoadModelError/index.tsx
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
import { useAtomValue, useSetAtom } from 'jotai'
|
||||||
|
|
||||||
|
import ModalTroubleShooting, {
|
||||||
|
modalTroubleShootingAtom,
|
||||||
|
} from '@/containers/ModalTroubleShoot'
|
||||||
|
|
||||||
|
import { MainViewState } from '@/constants/screens'
|
||||||
|
|
||||||
|
import { loadModelErrorAtom } from '@/hooks/useActiveModel'
|
||||||
|
|
||||||
|
import { mainViewStateAtom } from '@/helpers/atoms/App.atom'
|
||||||
|
|
||||||
|
const LoadModelError = () => {
|
||||||
|
const setModalTroubleShooting = useSetAtom(modalTroubleShootingAtom)
|
||||||
|
const loadModelError = useAtomValue(loadModelErrorAtom)
|
||||||
|
const setMainState = useSetAtom(mainViewStateAtom)
|
||||||
|
const PORT_NOT_AVAILABLE = 'PORT_NOT_AVAILABLE'
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="mt-10">
|
||||||
|
{loadModelError === PORT_NOT_AVAILABLE ? (
|
||||||
|
<div className="flex w-full flex-col items-center text-center text-sm font-medium text-gray-500">
|
||||||
|
<p className="w-[90%]">
|
||||||
|
Port 3928 is currently unavailable. Check for conflicting apps, or
|
||||||
|
access
|
||||||
|
<span
|
||||||
|
className="cursor-pointer text-primary dark:text-blue-400"
|
||||||
|
onClick={() => setModalTroubleShooting(true)}
|
||||||
|
>
|
||||||
|
troubleshooting assistance
|
||||||
|
</span>
|
||||||
|
for further support.
|
||||||
|
</p>
|
||||||
|
<ModalTroubleShooting />
|
||||||
|
</div>
|
||||||
|
) : loadModelError &&
|
||||||
|
loadModelError?.includes('EXTENSION_IS_NOT_INSTALLED') ? (
|
||||||
|
<div className="flex w-full flex-col items-center text-center text-sm font-medium text-gray-500">
|
||||||
|
<p className="w-[90%]">
|
||||||
|
Model is currently unavailable. Please switch to a different model
|
||||||
|
or install the{' '}
|
||||||
|
<button
|
||||||
|
className="font-medium text-primary dark:text-blue-400"
|
||||||
|
onClick={() => setMainState(MainViewState.Settings)}
|
||||||
|
>
|
||||||
|
{loadModelError.split('::')[1] ?? ''}
|
||||||
|
</button>{' '}
|
||||||
|
to continue using it.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<div className="mx-6 flex flex-col items-center space-y-2 text-center text-sm font-medium text-gray-500">
|
||||||
|
Apologies, something’s amiss!
|
||||||
|
<p>
|
||||||
|
Jan’s in beta. Access
|
||||||
|
<span
|
||||||
|
className="cursor-pointer text-primary dark:text-blue-400"
|
||||||
|
onClick={() => setModalTroubleShooting(true)}
|
||||||
|
>
|
||||||
|
troubleshooting assistance
|
||||||
|
</span>
|
||||||
|
now.
|
||||||
|
</p>
|
||||||
|
<ModalTroubleShooting />
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
export default LoadModelError
|
||||||
Loading…
x
Reference in New Issue
Block a user