import {
EngineManager,
ErrorCode,
MessageStatus,
ThreadMessage,
} from '@janhq/core'
import { useAtomValue, useSetAtom } from 'jotai'
import AutoLink from '@/containers/AutoLink'
import ModalTroubleShooting, {
modalTroubleShootingAtom,
} from '@/containers/ModalTroubleShoot'
import { MainViewState } from '@/constants/screens'
import { mainViewStateAtom } from '@/helpers/atoms/App.atom'
import { selectedSettingAtom } from '@/helpers/atoms/Setting.atom'
import { activeThreadAtom } from '@/helpers/atoms/Thread.atom'
const ErrorMessage = ({ message }: { message: ThreadMessage }) => {
const setModalTroubleShooting = useSetAtom(modalTroubleShootingAtom)
const setMainState = useSetAtom(mainViewStateAtom)
const setSelectedSettingScreen = useSetAtom(selectedSettingAtom)
const activeThread = useAtomValue(activeThreadAtom)
const getErrorTitle = () => {
switch (message.error_code) {
case ErrorCode.Unknown:
return 'Apologies, something’s amiss!'
case ErrorCode.InvalidApiKey:
case ErrorCode.AuthenticationError:
case ErrorCode.InvalidRequestError:
return (
Invalid API key. Please check your API key from{' '}
{' '}
and try again.
)
default:
return (
<>
{message.content[0]?.text?.value && (
Jan’s in beta. Access setModalTroubleShooting(true)} > troubleshooting assistance now.