forked from janhq/jan
-
Notifications
You must be signed in to change notification settings - Fork 0
/
extensionService.ts
33 lines (30 loc) · 968 Bytes
/
extensionService.ts
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
/* eslint-disable @typescript-eslint/no-explicit-any */
'use client'
import { ExtensionTypeEnum } from '@janhq/core'
import { extensionManager } from '@/extension/ExtensionManager'
export const isCoreExtensionInstalled = () => {
if (!extensionManager.get(ExtensionTypeEnum.Conversational)) {
return false
}
if (!extensionManager.get(ExtensionTypeEnum.Inference)) return false
if (!extensionManager.get(ExtensionTypeEnum.Model)) {
return false
}
return true
}
export const setupBaseExtensions = async () => {
if (typeof window === 'undefined') {
return
}
const baseExtensions = await window.core?.api.baseExtensions()
if (
!extensionManager.get(ExtensionTypeEnum.Conversational) ||
!extensionManager.get(ExtensionTypeEnum.Inference) ||
!extensionManager.get(ExtensionTypeEnum.Model)
) {
const installed = await extensionManager.install(baseExtensions)
if (installed) {
window.location.reload()
}
}
}