fix: check-dependencies typo and fetch model list typo

This commit is contained in:
Yi 2025-01-08 15:54:04 +08:00
parent fdfe724438
commit 23b29b1d21
4 changed files with 27 additions and 29 deletions

View File

@ -73,15 +73,22 @@ const AgentModelTrigger: FC<AgentModelTriggerProps> = ({
const handleOpenModal = useModelModalHandler()
useEffect(() => {
(async () => {
if (modelId && currentProvider) {
try {
const modelsData = await fetchModelProviderModelList(`/workspaces/current/model-providers/${currentProvider?.provider}/models`)
if (modelId && modelsData.data.find(item => item.model === modelId))
setInModelList(true)
}
catch (error) {
// pass
}
}
if (providerName && !modelProvider) {
const parts = providerName.split('/')
const org = parts[0]
const name = parts[1]
try {
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)
setPluginInfo(pluginInfo.data.plugin)
}
@ -94,7 +101,7 @@ const AgentModelTrigger: FC<AgentModelTriggerProps> = ({
setIsPluginChecked(true)
}
})()
}, [providerName, modelProvider, modelId])
}, [providerName, modelProvider, modelId, currentProvider])
if (modelId && !isPluginChecked)
return null

View File

@ -39,32 +39,23 @@ const StatusIndicators = ({ needsConfiguration, modelProvider, inModelList, disa
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(
{!needsConfiguration && modelProvider && disabled && (
<Tooltip
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.linkToPlugin') : '',
!pluginInfo ? '/plugins' : '',
)}
asChild={false}
needsDelay
>
<RiErrorWarningFill className='w-4 h-4 text-text-destructive' />
</Tooltip>
)
}
{/* plugin not installed and not in marketplace */}
)
}
asChild={false}
needsDelay={!inModelList}
>
<RiErrorWarningFill className='w-4 h-4 text-text-destructive' />
</Tooltip>
)}
{!modelProvider && !pluginInfo && (
<Tooltip
popupContent={renderTooltipContent(

View File

@ -1,9 +1,9 @@
import { useCallback } from 'react'
import { useStore as usePluginDependenciesStore } from './store'
import { useMutationCheckDependecies } from '@/service/use-plugins'
import { useMutationCheckDependencies } from '@/service/use-plugins'
export const usePluginDependencies = () => {
const { mutateAsync } = useMutationCheckDependecies()
const { mutateAsync } = useMutationCheckDependencies()
const handleCheckPluginDependencies = useCallback(async (appId: string) => {
const { leaked_dependencies } = await mutateAsync(appId)

View File

@ -423,10 +423,10 @@ export const useDownloadPlugin = (info: { organization: string; pluginName: stri
})
}
export const useMutationCheckDependecies = () => {
export const useMutationCheckDependencies = () => {
return useMutation({
mutationFn: (appId: string) => {
return get<{ leaked_dependencies: Dependency[] }>(`/apps/import/${appId}/check-dependencies`)
return get<{ leaked_dependencies: Dependency[] }>(`/apps/imports/${appId}/check-dependencies`)
},
})
}