enhancement: receommended label engine variant (#4740)
This commit is contained in:
parent
f0ad526aa9
commit
ecb14b3621
@ -7,7 +7,7 @@ import './styles.scss'
|
|||||||
import { twMerge } from 'tailwind-merge'
|
import { twMerge } from 'tailwind-merge'
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
options?: { name: string; value: string }[]
|
options?: { name: string; value: string; recommend?: boolean }[]
|
||||||
open?: boolean
|
open?: boolean
|
||||||
block?: boolean
|
block?: boolean
|
||||||
value?: string
|
value?: string
|
||||||
@ -62,9 +62,16 @@ const Select = ({
|
|||||||
className="select__item"
|
className="select__item"
|
||||||
value={item.value}
|
value={item.value}
|
||||||
>
|
>
|
||||||
|
<div className="flex items-center gap-x-2">
|
||||||
<SelectPrimitive.ItemText>
|
<SelectPrimitive.ItemText>
|
||||||
{item.name}
|
<span>{item.name}</span>
|
||||||
</SelectPrimitive.ItemText>
|
</SelectPrimitive.ItemText>
|
||||||
|
{item.recommend && (
|
||||||
|
<span className="rounded bg-[hsla(var(--secondary-bg))] px-2 py-0.5 text-xs font-medium">
|
||||||
|
Recommended
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
<SelectPrimitive.ItemIndicator className="select__item-indicator">
|
<SelectPrimitive.ItemIndicator className="select__item-indicator">
|
||||||
<CheckIcon />
|
<CheckIcon />
|
||||||
</SelectPrimitive.ItemIndicator>
|
</SelectPrimitive.ItemIndicator>
|
||||||
|
|||||||
@ -10,6 +10,13 @@ export const defaultJanDataFolderAtom = atom<string>('')
|
|||||||
|
|
||||||
export const LocalEngineDefaultVariantAtom = atom<string>('')
|
export const LocalEngineDefaultVariantAtom = atom<string>('')
|
||||||
|
|
||||||
|
export const RecommendEngineVariantAtom = atomWithStorage<string>(
|
||||||
|
'recommendEngineVariant',
|
||||||
|
'',
|
||||||
|
undefined,
|
||||||
|
{ getOnInit: true }
|
||||||
|
)
|
||||||
|
|
||||||
const SHOW_RIGHT_PANEL = 'showRightPanel'
|
const SHOW_RIGHT_PANEL = 'showRightPanel'
|
||||||
|
|
||||||
// Store panel atom
|
// Store panel atom
|
||||||
|
|||||||
@ -29,7 +29,10 @@ import ExtensionSetting from '../ExtensionSetting'
|
|||||||
|
|
||||||
import DeleteEngineVariant from './DeleteEngineVariant'
|
import DeleteEngineVariant from './DeleteEngineVariant'
|
||||||
|
|
||||||
import { LocalEngineDefaultVariantAtom } from '@/helpers/atoms/App.atom'
|
import {
|
||||||
|
LocalEngineDefaultVariantAtom,
|
||||||
|
RecommendEngineVariantAtom,
|
||||||
|
} from '@/helpers/atoms/App.atom'
|
||||||
import { showScrollBarAtom } from '@/helpers/atoms/Setting.atom'
|
import { showScrollBarAtom } from '@/helpers/atoms/Setting.atom'
|
||||||
const os = () => {
|
const os = () => {
|
||||||
switch (PLATFORM) {
|
switch (PLATFORM) {
|
||||||
@ -60,6 +63,10 @@ const LocalEngineSettings = ({ engine }: { engine: InferenceEngine }) => {
|
|||||||
>(new Map())
|
>(new Map())
|
||||||
const { stopModel } = useActiveModel()
|
const { stopModel } = useActiveModel()
|
||||||
|
|
||||||
|
const [recommendEngineVariant, setRecommendEngineVariant] = useAtom(
|
||||||
|
RecommendEngineVariantAtom
|
||||||
|
)
|
||||||
|
|
||||||
const isEngineUpdated =
|
const isEngineUpdated =
|
||||||
latestReleasedEngine &&
|
latestReleasedEngine &&
|
||||||
latestReleasedEngine.some((item) =>
|
latestReleasedEngine.some((item) =>
|
||||||
@ -85,6 +92,7 @@ const LocalEngineSettings = ({ engine }: { engine: InferenceEngine }) => {
|
|||||||
.map((x: any) => ({
|
.map((x: any) => ({
|
||||||
name: x.name,
|
name: x.name,
|
||||||
value: x.name,
|
value: x.name,
|
||||||
|
recommend: recommendEngineVariant === x.name,
|
||||||
}))
|
}))
|
||||||
|
|
||||||
const installedEngineByVersion = installedEngines?.filter(
|
const installedEngineByVersion = installedEngines?.filter(
|
||||||
@ -107,7 +115,10 @@ const LocalEngineSettings = ({ engine }: { engine: InferenceEngine }) => {
|
|||||||
if (defaultEngineVariant?.variant) {
|
if (defaultEngineVariant?.variant) {
|
||||||
setSelectedVariants(defaultEngineVariant.variant || '')
|
setSelectedVariants(defaultEngineVariant.variant || '')
|
||||||
}
|
}
|
||||||
}, [defaultEngineVariant, setSelectedVariants])
|
if (!recommendEngineVariant.length) {
|
||||||
|
setRecommendEngineVariant(defaultEngineVariant?.variant || '')
|
||||||
|
}
|
||||||
|
}, [defaultEngineVariant, setSelectedVariants, setRecommendEngineVariant])
|
||||||
|
|
||||||
const handleEngineUpdate = useCallback(
|
const handleEngineUpdate = useCallback(
|
||||||
async (event: { id: string; type: DownloadEvent; percent: number }) => {
|
async (event: { id: string; type: DownloadEvent; percent: number }) => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user