-
Notifications
You must be signed in to change notification settings - Fork 1.6k
/
Copy pathindex.tsx
63 lines (57 loc) · 2.16 KB
/
index.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import { EngineManager, InferenceEngine } from '@janhq/core'
import { useAtomValue, useSetAtom } from 'jotai'
import ErrorMessage from '@/containers/ErrorMessage'
import ModalTroubleShooting, {
modalTroubleShootingAtom,
} from '@/containers/ModalTroubleShoot'
import { MainViewState } from '@/constants/screens'
import { loadModelErrorAtom } from '@/hooks/useActiveModel'
import { mainViewStateAtom } from '@/helpers/atoms/App.atom'
import { activeAssistantAtom } from '@/helpers/atoms/Assistant.atom'
import { selectedSettingAtom } from '@/helpers/atoms/Setting.atom'
const LoadModelError = () => {
const setModalTroubleShooting = useSetAtom(modalTroubleShootingAtom)
const loadModelError = useAtomValue(loadModelErrorAtom)
const setMainState = useSetAtom(mainViewStateAtom)
const setSelectedSettingScreen = useSetAtom(selectedSettingAtom)
const activeAssistant = useAtomValue(activeAssistantAtom)
return (
<ErrorMessage
errorComponent={
<div>
{typeof loadModelError?.includes === 'function' &&
loadModelError.includes('EXTENSION_IS_NOT_INSTALLED') ? (
<>
<p>
Model is currently unavailable. Please switch to a different
model or install the{' '}
<span
className="cursor-pointer font-medium text-[hsla(var(--app-link))]"
onClick={() => {
setMainState(MainViewState.Settings)
if (activeAssistant?.model.engine) {
const engine = EngineManager.instance().get(
InferenceEngine.cortex
)
engine?.name && setSelectedSettingScreen(engine.name)
}
}}
>
{loadModelError.split('::')[1] ?? ''}
</span>{' '}
to continue using it.
</p>
</>
) : (
<>
{loadModelError && (
<p className="first-letter:uppercase">{loadModelError}</p>
)}
</>
)}
</div>
}
/>
)
}
export default LoadModelError