feat: add version switch in model selector

This commit is contained in:
Yi 2025-01-08 16:39:56 +08:00
parent f58eef74b3
commit 369e3eb97f
5 changed files with 12 additions and 6 deletions

View File

@ -83,7 +83,7 @@ const AgentModelTrigger: FC<AgentModelTriggerProps> = ({
// pass
}
}
if (providerName && !modelProvider) {
if (providerName) {
const parts = providerName.split('/')
const org = parts[0]
const name = parts[1]
@ -101,7 +101,7 @@ const AgentModelTrigger: FC<AgentModelTriggerProps> = ({
setIsPluginChecked(true)
}
})()
}, [providerName, modelProvider, modelId, currentProvider])
}, [providerName, modelId, currentProvider])
if (modelId && !isPluginChecked)
return null

View File

@ -1,5 +1,7 @@
import Tooltip from '@/app/components/base/tooltip'
import Link from 'next/link'
import { SwitchPluginVersion } from '@/app/components/workflow/nodes/_base/components/switch-plugin-version'
import { useInstalledPluginList } from '@/service/use-plugins'
import { RiErrorWarningFill } from '@remixicon/react'
type StatusIndicatorsProps = {
@ -12,9 +14,10 @@ type StatusIndicatorsProps = {
}
const StatusIndicators = ({ needsConfiguration, modelProvider, inModelList, disabled, pluginInfo, t }: StatusIndicatorsProps) => {
const { data: pluginList } = useInstalledPluginList()
const renderTooltipContent = (title: string, description?: string, linkText?: string, linkHref?: string) => {
return (
<div className='flex w-[240px] max-w-[240px] gap-1 flex-col px-1 py-1.5'>
<div className='flex w-[240px] max-w-[240px] gap-1 flex-col px-1 py-1.5' onClick={e => e.stopPropagation()}>
<div className='text-text-primary title-xs-semi-bold'>{title}</div>
{description && (
<div className='min-w-[200px] text-text-secondary body-xs-regular'>
@ -36,6 +39,7 @@ const StatusIndicators = ({ needsConfiguration, modelProvider, inModelList, disa
</div>
)
}
// const installedPluginUniqueIdentifier = pluginList?.plugins.find(plugin => plugin.name === pluginInfo.name)?.plugin_unique_identifier
return (
<>
{/* plugin installed and model is in model list but disabled */}
@ -45,7 +49,7 @@ const StatusIndicators = ({ needsConfiguration, modelProvider, inModelList, disa
popupContent={inModelList ? t('workflow.nodes.agent.modelSelectorTooltips.deprecated')
: renderTooltipContent(
t('workflow.nodes.agent.modelNotSupport.title'),
t('workflow.nodes.agent.modelNotSupport.desc'),
!pluginInfo ? t('workflow.nodes.agent.modelNotSupport.desc') : t('workflow.nodes.agent.modelNotSupport.descForVersionSwitch'),
!pluginInfo ? t('workflow.nodes.agent.linkToPlugin') : '',
!pluginInfo ? '/plugins' : '',
)
@ -53,7 +57,7 @@ const StatusIndicators = ({ needsConfiguration, modelProvider, inModelList, disa
asChild={false}
needsDelay={!inModelList}
>
<RiErrorWarningFill className='w-4 h-4 text-text-destructive' />
{!pluginInfo ? <RiErrorWarningFill className='w-4 h-4 text-text-destructive' /> : <SwitchPluginVersion uniqueIdentifier={pluginList?.plugins.find(plugin => plugin.name === pluginInfo.name)?.plugin_unique_identifier ?? ''} />}
</Tooltip>
)}
{!modelProvider && !pluginInfo && (

View File

@ -61,7 +61,7 @@ export const SwitchPluginVersion: FC<SwitchPluginVersionProps> = (props) => {
}
const { t } = useTranslation()
return <Tooltip popupContent={!isShow && !isShowUpdateModal && tooltip} triggerMethod='hover'>
<div className={cn('w-fit', className)}>
<div className={cn('w-fit flex items-center justify-center', className)}>
{isShowUpdateModal && pluginDetail && <PluginMutationModel
onCancel={hideUpdateModal}
plugin={pluginManifestToCardPluginProps({

View File

@ -725,6 +725,7 @@ const translation = {
modelNotSupport: {
title: 'Unsupported Model',
desc: 'The installed plugin version does not provide this model.',
descForVersionSwitch: 'The installed plugin version does not provide this model. Click to switch version.',
},
configureModel: 'Configure Model',
notAuthorized: 'Not Authorized',

View File

@ -725,6 +725,7 @@ const translation = {
modelNotSupport: {
title: '不支持的模型',
desc: '已安装的插件版本不提供此模型。',
descForVersionSwitch: '已安装的插件版本不提供此模型。点击切换版本。',
},
model: '模型',
toolbox: '工具箱',