Merge pull request #4457 from janhq/feat/move-cortex-extension-settings-to-engine
feat: move cortex extension settings to local engine page
This commit is contained in:
commit
dd791b9527
@ -23,6 +23,8 @@ import {
|
|||||||
|
|
||||||
import { formatDownloadPercentage } from '@/utils/converter'
|
import { formatDownloadPercentage } from '@/utils/converter'
|
||||||
|
|
||||||
|
import ExtensionSetting from '../ExtensionSetting'
|
||||||
|
|
||||||
import DeleteEngineVariant from './DeleteEngineVariant'
|
import DeleteEngineVariant from './DeleteEngineVariant'
|
||||||
const os = () => {
|
const os = () => {
|
||||||
switch (PLATFORM) {
|
switch (PLATFORM) {
|
||||||
@ -339,6 +341,11 @@ const LocalEngineSettings = ({ engine }: { engine: InferenceEngine }) => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div className="border-b border-[hsla(var(--app-border))]" />
|
||||||
|
<div className="flex w-full border-b border-[hsla(var(--app-border))]">
|
||||||
|
{/* TODO: Pull settings from engine when it's supported */}
|
||||||
|
<ExtensionSetting extensionName="@janhq/inference-cortex-extension" />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</ScrollArea>
|
</ScrollArea>
|
||||||
)
|
)
|
||||||
|
|||||||
@ -2,8 +2,7 @@ import React from 'react'
|
|||||||
|
|
||||||
import { InferenceEngine } from '@janhq/core'
|
import { InferenceEngine } from '@janhq/core'
|
||||||
import { ScrollArea } from '@janhq/joi'
|
import { ScrollArea } from '@janhq/joi'
|
||||||
|
import { useAtomValue } from 'jotai'
|
||||||
import { useGetEngines } from '@/hooks/useEngineManagement'
|
|
||||||
|
|
||||||
import { isLocalEngine } from '@/utils/modelEngine'
|
import { isLocalEngine } from '@/utils/modelEngine'
|
||||||
|
|
||||||
@ -11,8 +10,10 @@ import LocalEngineItems from './LocalEngineItem'
|
|||||||
import ModalAddRemoteEngine from './ModalAddRemoteEngine'
|
import ModalAddRemoteEngine from './ModalAddRemoteEngine'
|
||||||
import RemoteEngineItems from './RemoteEngineItem'
|
import RemoteEngineItems from './RemoteEngineItem'
|
||||||
|
|
||||||
|
import { installedEnginesAtom } from '@/helpers/atoms/Engines.atom'
|
||||||
|
|
||||||
const Engines = () => {
|
const Engines = () => {
|
||||||
const { engines } = useGetEngines()
|
const engines = useAtomValue(installedEnginesAtom)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ScrollArea className="h-full w-full">
|
<ScrollArea className="h-full w-full">
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import React, { Fragment, useEffect, useState } from 'react'
|
import React, { Fragment, useEffect, useMemo, useState } from 'react'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
BaseExtension,
|
BaseExtension,
|
||||||
@ -14,7 +14,7 @@ import SettingDetailItem from '../SettingDetail/SettingDetailItem'
|
|||||||
import { extensionManager } from '@/extension'
|
import { extensionManager } from '@/extension'
|
||||||
import { selectedSettingAtom } from '@/helpers/atoms/Setting.atom'
|
import { selectedSettingAtom } from '@/helpers/atoms/Setting.atom'
|
||||||
|
|
||||||
const ExtensionSetting = () => {
|
const ExtensionSetting = ({ extensionName }: { extensionName?: string }) => {
|
||||||
const selectedExtensionName = useAtomValue(selectedSettingAtom)
|
const selectedExtensionName = useAtomValue(selectedSettingAtom)
|
||||||
const [settings, setSettings] = useState<SettingComponentProps[]>([])
|
const [settings, setSettings] = useState<SettingComponentProps[]>([])
|
||||||
const [installationState, setInstallationState] =
|
const [installationState, setInstallationState] =
|
||||||
@ -23,11 +23,16 @@ const ExtensionSetting = () => {
|
|||||||
undefined
|
undefined
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const currentExtensionName = useMemo(
|
||||||
|
() => extensionName ?? selectedExtensionName,
|
||||||
|
[selectedExtensionName, extensionName]
|
||||||
|
)
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const getExtensionSettings = async () => {
|
const getExtensionSettings = async () => {
|
||||||
if (!selectedExtensionName) return
|
if (!currentExtensionName) return
|
||||||
const allSettings: SettingComponentProps[] = []
|
const allSettings: SettingComponentProps[] = []
|
||||||
const baseExtension = extensionManager.getByName(selectedExtensionName)
|
const baseExtension = extensionManager.getByName(currentExtensionName)
|
||||||
if (!baseExtension) return
|
if (!baseExtension) return
|
||||||
|
|
||||||
setBaseExtension(baseExtension)
|
setBaseExtension(baseExtension)
|
||||||
@ -40,7 +45,7 @@ const ExtensionSetting = () => {
|
|||||||
setInstallationState(await baseExtension.installationState())
|
setInstallationState(await baseExtension.installationState())
|
||||||
}
|
}
|
||||||
getExtensionSettings()
|
getExtensionSettings()
|
||||||
}, [selectedExtensionName])
|
}, [currentExtensionName])
|
||||||
|
|
||||||
const onValueChanged = async (
|
const onValueChanged = async (
|
||||||
key: string,
|
key: string,
|
||||||
|
|||||||
@ -87,7 +87,7 @@ const SettingDetailTextInputItem = ({
|
|||||||
<div
|
<div
|
||||||
className={twMerge(
|
className={twMerge(
|
||||||
'w-full flex-shrink-0 pr-1 sm:w-1/2',
|
'w-full flex-shrink-0 pr-1 sm:w-1/2',
|
||||||
type === 'number' && 'sm:w-22 w-24'
|
type === 'number' && 'sm:w-22 w-50'
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<Input
|
<Input
|
||||||
|
|||||||
@ -56,7 +56,7 @@ const SettingDetailItem = ({ componentProps, onValueUpdated }: Props) => {
|
|||||||
<div className="flex h-full w-full flex-col overflow-y-auto">
|
<div className="flex h-full w-full flex-col overflow-y-auto">
|
||||||
{components.map((component, index) => (
|
{components.map((component, index) => (
|
||||||
<div
|
<div
|
||||||
className={`mx-4 ${index === components.length - 1 ? '' : 'border-b border-[hsla(var(--app-border))]'}`}
|
className={`${index === components.length - 1 ? '' : 'border-b border-[hsla(var(--app-border))]'}`}
|
||||||
key={index}
|
key={index}
|
||||||
>
|
>
|
||||||
{component}
|
{component}
|
||||||
|
|||||||
@ -59,7 +59,11 @@ const SettingDetail = () => {
|
|||||||
<RemoteEngineSettings engine={selectedSetting as InferenceEngine} />
|
<RemoteEngineSettings engine={selectedSetting as InferenceEngine} />
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
return <ExtensionSetting />
|
return (
|
||||||
|
<div className="mx-4">
|
||||||
|
<ExtensionSetting />
|
||||||
|
</div>
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -148,6 +148,7 @@ const SettingLeftPanel = () => {
|
|||||||
|
|
||||||
{extensionHasSettings
|
{extensionHasSettings
|
||||||
.sort((a, b) => String(a.name).localeCompare(String(b.name)))
|
.sort((a, b) => String(a.name).localeCompare(String(b.name)))
|
||||||
|
.filter((e) => !e.name?.includes('Cortex'))
|
||||||
.map((item) => (
|
.map((item) => (
|
||||||
<SettingItem
|
<SettingItem
|
||||||
key={item.name}
|
key={item.name}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user