Merge branch 'feat/plugins' of https://github.com/langgenius/dify into feat/plugins

This commit is contained in:
Yi 2025-01-07 14:45:00 +08:00
commit e207894d7e
4 changed files with 31 additions and 4 deletions

View File

@ -20,7 +20,7 @@ const Badge = ({
return (
<div
className={cn(
'inline-flex items-center px-[5px] h-5 rounded-[5px] border border-divider-deep leading-3 text-text-tertiary',
'relative inline-flex items-center px-[5px] h-5 rounded-[5px] border border-divider-deep leading-3 text-text-tertiary',
uppercase ? 'system-2xs-medium-uppercase' : 'system-xs-medium',
className,
)}

View File

@ -9,6 +9,7 @@ import AgentStrategyList from './agent-strategy-list'
import Drawer from '@/app/components/base/drawer'
import type { PluginDetail } from '@/app/components/plugins/types'
import cn from '@/utils/classnames'
import ToolSelector from '@/app/components/plugins/plugin-detail-panel/tool-selector'
type Props = {
detail?: PluginDetail
@ -27,6 +28,16 @@ const PluginDetailPanel: FC<Props> = ({
onUpdate()
}
const [value, setValue] = React.useState({
provider_name: 'langgenius/google/google',
tool_name: 'google_search',
})
const testHandle = (item: any) => {
console.log(item)
setValue(item)
}
if (!detail)
return null
@ -52,6 +63,17 @@ const PluginDetailPanel: FC<Props> = ({
{!!detail.declaration.agent_strategy && <AgentStrategyList detail={detail} />}
{!!detail.declaration.endpoint && <EndpointList detail={detail} />}
{!!detail.declaration.model && <ModelList detail={detail} />}
{false && (
<div className='px-4'>
<ToolSelector
scope={'all'}
value={value}
onSelect={item => testHandle(item)}
onDelete={() => testHandle(null)}
supportEnableSwitch
/>
</div>
)}
</div>
</>
)}

View File

@ -32,7 +32,7 @@ import {
useInvalidateAllBuiltInTools,
useUpdateProviderCredentials,
} from '@/service/use-tools'
import { useInstallPackageFromMarketPlace } from '@/service/use-plugins'
import { useInstallPackageFromMarketPlace, useInvalidateInstalledPluginList } from '@/service/use-plugins'
import { usePluginInstalledCheck } from '@/app/components/plugins/plugin-detail-panel/tool-selector/hooks'
import { CollectionType } from '@/app/components/tools/types'
import type { ToolDefaultValue } from '@/app/components/workflow/block-selector/types'
@ -94,6 +94,7 @@ const ToolSelector: FC<Props> = ({
const { data: customTools } = useAllCustomTools()
const { data: workflowTools } = useAllWorkflowTools()
const invalidateAllBuiltinTools = useInvalidateAllBuiltInTools()
const invalidateInstalledPluginList = useInvalidateInstalledPluginList()
// plugin info check
const { inMarketPlace, manifest } = usePluginInstalledCheck(value?.provider_name)
@ -183,6 +184,7 @@ const ToolSelector: FC<Props> = ({
try {
await installPackageFromMarketPlace(manifest.latest_package_identifier)
invalidateAllBuiltinTools()
invalidateInstalledPluginList()
}
catch (e: any) {
Toast.notify({ type: 'error', message: `${e.message || e}` })

View File

@ -21,7 +21,7 @@ import Action from './action'
import cn from '@/utils/classnames'
import { API_PREFIX, MARKETPLACE_URL_PREFIX } from '@/config'
import { useInvalidateInstalledPluginList } from '@/service/use-plugins'
import { useInvalidateAllToolProviders } from '@/service/use-tools'
import { useInvalidateAllBuiltInTools, useInvalidateAllToolProviders } from '@/service/use-tools'
import { useCategories } from '../hooks'
import { useProviderContext } from '@/context/provider-context'
import { useRenderI18nObject } from '@/hooks/use-i18n'
@ -41,6 +41,7 @@ const PluginItem: FC<Props> = ({
const setCurrentPluginID = usePluginPageContext(v => v.setCurrentPluginID)
const invalidateInstalledPluginList = useInvalidateInstalledPluginList()
const invalidateAllToolProviders = useInvalidateAllToolProviders()
const invalidateAllBuiltinTools = useInvalidateAllBuiltInTools()
const { refreshModelProviders } = useProviderContext()
const {
@ -62,8 +63,10 @@ const PluginItem: FC<Props> = ({
invalidateInstalledPluginList()
if (PluginType.model.includes(category))
refreshModelProviders()
if (PluginType.tool.includes(category))
if (PluginType.tool.includes(category)) {
invalidateAllToolProviders()
invalidateAllBuiltinTools()
}
}
const getValueFromI18nObject = useRenderI18nObject()
const title = getValueFromI18nObject(label)