feat: add version switch in model selector

pull/12560/head
Yi 1 year ago
parent f58eef74b3
commit 369e3eb97f

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

@ -1,5 +1,7 @@
import Tooltip from '@/app/components/base/tooltip' import Tooltip from '@/app/components/base/tooltip'
import Link from 'next/link' 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' import { RiErrorWarningFill } from '@remixicon/react'
type StatusIndicatorsProps = { type StatusIndicatorsProps = {
@ -12,9 +14,10 @@ type StatusIndicatorsProps = {
} }
const StatusIndicators = ({ needsConfiguration, modelProvider, inModelList, disabled, pluginInfo, t }: StatusIndicatorsProps) => { const StatusIndicators = ({ needsConfiguration, modelProvider, inModelList, disabled, pluginInfo, t }: StatusIndicatorsProps) => {
const { data: pluginList } = useInstalledPluginList()
const renderTooltipContent = (title: string, description?: string, linkText?: string, linkHref?: string) => { const renderTooltipContent = (title: string, description?: string, linkText?: string, linkHref?: string) => {
return ( 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> <div className='text-text-primary title-xs-semi-bold'>{title}</div>
{description && ( {description && (
<div className='min-w-[200px] text-text-secondary body-xs-regular'> <div className='min-w-[200px] text-text-secondary body-xs-regular'>
@ -36,6 +39,7 @@ const StatusIndicators = ({ needsConfiguration, modelProvider, inModelList, disa
</div> </div>
) )
} }
// const installedPluginUniqueIdentifier = pluginList?.plugins.find(plugin => plugin.name === pluginInfo.name)?.plugin_unique_identifier
return ( return (
<> <>
{/* plugin installed and model is in model list but disabled */} {/* 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') popupContent={inModelList ? t('workflow.nodes.agent.modelSelectorTooltips.deprecated')
: renderTooltipContent( : renderTooltipContent(
t('workflow.nodes.agent.modelNotSupport.title'), 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 ? t('workflow.nodes.agent.linkToPlugin') : '',
!pluginInfo ? '/plugins' : '', !pluginInfo ? '/plugins' : '',
) )
@ -53,7 +57,7 @@ const StatusIndicators = ({ needsConfiguration, modelProvider, inModelList, disa
asChild={false} asChild={false}
needsDelay={!inModelList} 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> </Tooltip>
)} )}
{!modelProvider && !pluginInfo && ( {!modelProvider && !pluginInfo && (

@ -61,7 +61,7 @@ export const SwitchPluginVersion: FC<SwitchPluginVersionProps> = (props) => {
} }
const { t } = useTranslation() const { t } = useTranslation()
return <Tooltip popupContent={!isShow && !isShowUpdateModal && tooltip} triggerMethod='hover'> 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 {isShowUpdateModal && pluginDetail && <PluginMutationModel
onCancel={hideUpdateModal} onCancel={hideUpdateModal}
plugin={pluginManifestToCardPluginProps({ plugin={pluginManifestToCardPluginProps({

@ -725,6 +725,7 @@ const translation = {
modelNotSupport: { modelNotSupport: {
title: 'Unsupported Model', title: 'Unsupported Model',
desc: 'The installed plugin version does not provide this 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', configureModel: 'Configure Model',
notAuthorized: 'Not Authorized', notAuthorized: 'Not Authorized',

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

Loading…
Cancel
Save