feat: add version incompatible case

pull/12560/head
Yi 1 year ago
parent d17932d723
commit 17dfb3654f

@ -13,12 +13,14 @@ type ModelIconProps = {
modelName?: string modelName?: string
className?: string className?: string
isDeprecated?: boolean isDeprecated?: boolean
isInModelList?: boolean
} }
const ModelIcon: FC<ModelIconProps> = ({ const ModelIcon: FC<ModelIconProps> = ({
provider, provider,
className, className,
modelName, modelName,
isDeprecated = false, isDeprecated = false,
isInModelList = false,
}) => { }) => {
const language = useLanguage() const language = useLanguage()
if (provider?.provider.includes('openai') && modelName?.includes('gpt-4o')) if (provider?.provider.includes('openai') && modelName?.includes('gpt-4o'))
@ -26,7 +28,7 @@ const ModelIcon: FC<ModelIconProps> = ({
if (provider?.provider.includes('openai') && modelName?.startsWith('gpt-4')) if (provider?.provider.includes('openai') && modelName?.startsWith('gpt-4'))
return <div className='flex items-center justify-center'><OpenaiViolet className={cn('w-5 h-5', className)}/></div> return <div className='flex items-center justify-center'><OpenaiViolet className={cn('w-5 h-5', className)}/></div>
if (provider?.icon_small) { if (provider?.icon_small && isInModelList) {
return ( return (
<div className={`flex items-center justify-center w-5 h-5 ${isDeprecated ? 'opacity-50' : ''}`}> <div className={`flex items-center justify-center w-5 h-5 ${isDeprecated ? 'opacity-50' : ''}`}>
<img <img
@ -40,7 +42,7 @@ const ModelIcon: FC<ModelIconProps> = ({
return ( return (
<div className={cn( <div className={cn(
'flex items-center justify-center rounded-md border-[0.5px] border-components-panel-border-subtle bg-background-default-subtle', 'flex items-center justify-center rounded-md border-[0.5px] w-5 h-5 border-components-panel-border-subtle bg-background-default-subtle',
className, className,
)}> )}>
<div className='flex w-5 h-5 items-center justify-center opacity-35'> <div className='flex w-5 h-5 items-center justify-center opacity-35'>

@ -26,6 +26,7 @@ import cn from '@/utils/classnames'
import { useProviderContext } from '@/context/provider-context' import { useProviderContext } from '@/context/provider-context'
import { RiEqualizer2Line } from '@remixicon/react' import { RiEqualizer2Line } from '@remixicon/react'
import { fetchPluginInfoFromMarketPlace } from '@/service/plugins' import { fetchPluginInfoFromMarketPlace } from '@/service/plugins'
import { fetchModelProviderModelList } from '@/service/common'
export type AgentModelTriggerProps = { export type AgentModelTriggerProps = {
open?: boolean open?: boolean
@ -67,6 +68,7 @@ const AgentModelTrigger: FC<AgentModelTriggerProps> = ({
const [pluginInfo, setPluginInfo] = useState<PluginInfoFromMarketPlace | null>(null) const [pluginInfo, setPluginInfo] = useState<PluginInfoFromMarketPlace | null>(null)
const [isPluginChecked, setIsPluginChecked] = useState(false) const [isPluginChecked, setIsPluginChecked] = useState(false)
const [installed, setInstalled] = useState(false) const [installed, setInstalled] = useState(false)
const [inModelList, setInModelList] = useState(false)
const invalidateInstalledPluginList = useInvalidateInstalledPluginList() const invalidateInstalledPluginList = useInvalidateInstalledPluginList()
const handleOpenModal = useModelModalHandler() const handleOpenModal = useModelModalHandler()
useEffect(() => { useEffect(() => {
@ -77,6 +79,9 @@ const AgentModelTrigger: FC<AgentModelTriggerProps> = ({
const name = parts[1] const name = parts[1]
try { try {
const pluginInfo = await fetchPluginInfoFromMarketPlace({ org, name }) const pluginInfo = await fetchPluginInfoFromMarketPlace({ org, name })
const modelsData = await fetchModelProviderModelList(`/workspaces/current/model-providers/${providerName}/models`)
if (modelId && modelsData.data.find(item => item.model === modelId))
setInModelList(true)
if (pluginInfo.data.plugin.category === PluginType.model) if (pluginInfo.data.plugin.category === PluginType.model)
setPluginInfo(pluginInfo.data.plugin) setPluginInfo(pluginInfo.data.plugin)
} }
@ -89,7 +94,7 @@ const AgentModelTrigger: FC<AgentModelTriggerProps> = ({
setIsPluginChecked(true) setIsPluginChecked(true)
} }
})() })()
}, [providerName, modelProvider]) }, [providerName, modelProvider, modelId])
if (modelId && !isPluginChecked) if (modelId && !isPluginChecked)
return null return null
@ -107,6 +112,7 @@ const AgentModelTrigger: FC<AgentModelTriggerProps> = ({
provider={currentProvider || modelProvider} provider={currentProvider || modelProvider}
modelName={currentModel?.model || modelId} modelName={currentModel?.model || modelId}
isDeprecated={hasDeprecated} isDeprecated={hasDeprecated}
isInModelList={inModelList}
/> />
<ModelDisplay <ModelDisplay
currentModel={currentModel} currentModel={currentModel}
@ -121,6 +127,7 @@ const AgentModelTrigger: FC<AgentModelTriggerProps> = ({
<StatusIndicators <StatusIndicators
needsConfiguration={needsConfiguration} needsConfiguration={needsConfiguration}
modelProvider={!!modelProvider} modelProvider={!!modelProvider}
inModelList={inModelList}
disabled={!!disabled} disabled={!!disabled}
pluginInfo={pluginInfo} pluginInfo={pluginInfo}
t={t} t={t}

@ -5,42 +5,74 @@ import { RiErrorWarningFill } from '@remixicon/react'
type StatusIndicatorsProps = { type StatusIndicatorsProps = {
needsConfiguration: boolean needsConfiguration: boolean
modelProvider: boolean modelProvider: boolean
inModelList: boolean
disabled: boolean disabled: boolean
pluginInfo: any pluginInfo: any
t: any t: any
} }
const StatusIndicators = ({ needsConfiguration, modelProvider, disabled, pluginInfo, t }: StatusIndicatorsProps) => { const StatusIndicators = ({ needsConfiguration, modelProvider, inModelList, disabled, pluginInfo, t }: StatusIndicatorsProps) => {
const renderTooltipContent = (title: string, description?: string, linkText?: string, linkHref?: string) => {
return ( return (
<>
{!needsConfiguration && modelProvider && disabled && (
<Tooltip
popupContent={t('workflow.nodes.agent.modelSelectorTooltips.deprecated')}
asChild={false}
>
<RiErrorWarningFill className='w-4 h-4 text-text-destructive' />
</Tooltip>
)}
{!modelProvider && !pluginInfo && (
<Tooltip
popupContent={
<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'>
<div className='text-text-primary title-xs-semi-bold'>{t('workflow.nodes.agent.modelNotInMarketplace.title')}</div> <div className='text-text-primary title-xs-semi-bold'>{title}</div>
{description && (
<div className='min-w-[200px] text-text-secondary body-xs-regular'> <div className='min-w-[200px] text-text-secondary body-xs-regular'>
{t('workflow.nodes.agent.modelNotInMarketplace.desc')} {description}
</div> </div>
)}
{linkText && linkHref && (
<div className='text-text-accent body-xs-regular cursor-pointer z-[100]'> <div className='text-text-accent body-xs-regular cursor-pointer z-[100]'>
<Link <Link
href={'/plugins'} href={linkHref}
onClick={(e) => { onClick={(e) => {
e.stopPropagation() e.stopPropagation()
}} }}
> >
{t('workflow.nodes.agent.linkToPlugin')} {linkText}
</Link> </Link>
</div> </div>
)}
</div> </div>
)
}
return (
<>
{/* plugin installed and model is in model list but disabled */}
{!needsConfiguration && modelProvider && disabled && inModelList && (
<Tooltip
popupContent={t('workflow.nodes.agent.modelSelectorTooltips.deprecated')}
asChild={false}
>
<RiErrorWarningFill className='w-4 h-4 text-text-destructive' />
</Tooltip>
)}
{/* plugin installed from github/local and model is not in model list */}
{
modelProvider && !inModelList && (
<Tooltip
popupContent={renderTooltipContent(
t('workflow.nodes.agent.modelNotSupport.title'),
t('workflow.nodes.agent.modelNotSupport.desc'),
!pluginInfo ? t('workflow.nodes.agent.linkToPlugin') : '',
!pluginInfo ? '/plugins' : '',
)}
asChild={false}
needsDelay
>
<RiErrorWarningFill className='w-4 h-4 text-text-destructive' />
</Tooltip>
)
} }
{/* plugin not installed and not in marketplace */}
{!modelProvider && !pluginInfo && (
<Tooltip
popupContent={renderTooltipContent(
t('workflow.nodes.agent.modelNotInMarketplace.title'),
t('workflow.nodes.agent.modelNotInMarketplace.desc'),
t('workflow.nodes.agent.linkToPlugin'),
'/plugins',
)}
asChild={false} asChild={false}
needsDelay needsDelay
> >

@ -22,11 +22,11 @@ const ModelTrigger: FC<ModelTriggerProps> = ({
return ( return (
<div <div
className={cn('group flex flex-grow items-center p-[3px] pl-1 h-6 gap-1 rounded-lg bg-components-input-bg-disabled cursor-pointer', className)} className={cn('group flex flex-grow items-center p-[3px] pl-1 h-8 gap-1 rounded-lg bg-components-input-bg-disabled cursor-pointer', className)}
> >
<div className='flex items-center py-[1px] gap-1 grow'> <div className='flex items-center py-[1px] gap-1 grow'>
<ModelIcon <ModelIcon
className="m-0.5 w-4 h-4" className="w-4 h-4"
provider={currentProvider} provider={currentProvider}
modelName={modelName} modelName={modelName}
/> />

Loading…
Cancel
Save