Merge branch 'feat/plugins' of https://github.com/langgenius/dify into feat/plugins
This commit is contained in:
commit
e207894d7e
@ -20,7 +20,7 @@ const Badge = ({
|
|||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={cn(
|
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',
|
uppercase ? 'system-2xs-medium-uppercase' : 'system-xs-medium',
|
||||||
className,
|
className,
|
||||||
)}
|
)}
|
||||||
|
@ -9,6 +9,7 @@ import AgentStrategyList from './agent-strategy-list'
|
|||||||
import Drawer from '@/app/components/base/drawer'
|
import Drawer from '@/app/components/base/drawer'
|
||||||
import type { PluginDetail } from '@/app/components/plugins/types'
|
import type { PluginDetail } from '@/app/components/plugins/types'
|
||||||
import cn from '@/utils/classnames'
|
import cn from '@/utils/classnames'
|
||||||
|
import ToolSelector from '@/app/components/plugins/plugin-detail-panel/tool-selector'
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
detail?: PluginDetail
|
detail?: PluginDetail
|
||||||
@ -27,6 +28,16 @@ const PluginDetailPanel: FC<Props> = ({
|
|||||||
onUpdate()
|
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)
|
if (!detail)
|
||||||
return null
|
return null
|
||||||
|
|
||||||
@ -52,6 +63,17 @@ const PluginDetailPanel: FC<Props> = ({
|
|||||||
{!!detail.declaration.agent_strategy && <AgentStrategyList detail={detail} />}
|
{!!detail.declaration.agent_strategy && <AgentStrategyList detail={detail} />}
|
||||||
{!!detail.declaration.endpoint && <EndpointList detail={detail} />}
|
{!!detail.declaration.endpoint && <EndpointList detail={detail} />}
|
||||||
{!!detail.declaration.model && <ModelList 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>
|
</div>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
@ -32,7 +32,7 @@ import {
|
|||||||
useInvalidateAllBuiltInTools,
|
useInvalidateAllBuiltInTools,
|
||||||
useUpdateProviderCredentials,
|
useUpdateProviderCredentials,
|
||||||
} from '@/service/use-tools'
|
} 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 { usePluginInstalledCheck } from '@/app/components/plugins/plugin-detail-panel/tool-selector/hooks'
|
||||||
import { CollectionType } from '@/app/components/tools/types'
|
import { CollectionType } from '@/app/components/tools/types'
|
||||||
import type { ToolDefaultValue } from '@/app/components/workflow/block-selector/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: customTools } = useAllCustomTools()
|
||||||
const { data: workflowTools } = useAllWorkflowTools()
|
const { data: workflowTools } = useAllWorkflowTools()
|
||||||
const invalidateAllBuiltinTools = useInvalidateAllBuiltInTools()
|
const invalidateAllBuiltinTools = useInvalidateAllBuiltInTools()
|
||||||
|
const invalidateInstalledPluginList = useInvalidateInstalledPluginList()
|
||||||
|
|
||||||
// plugin info check
|
// plugin info check
|
||||||
const { inMarketPlace, manifest } = usePluginInstalledCheck(value?.provider_name)
|
const { inMarketPlace, manifest } = usePluginInstalledCheck(value?.provider_name)
|
||||||
@ -183,6 +184,7 @@ const ToolSelector: FC<Props> = ({
|
|||||||
try {
|
try {
|
||||||
await installPackageFromMarketPlace(manifest.latest_package_identifier)
|
await installPackageFromMarketPlace(manifest.latest_package_identifier)
|
||||||
invalidateAllBuiltinTools()
|
invalidateAllBuiltinTools()
|
||||||
|
invalidateInstalledPluginList()
|
||||||
}
|
}
|
||||||
catch (e: any) {
|
catch (e: any) {
|
||||||
Toast.notify({ type: 'error', message: `${e.message || e}` })
|
Toast.notify({ type: 'error', message: `${e.message || e}` })
|
||||||
|
@ -21,7 +21,7 @@ import Action from './action'
|
|||||||
import cn from '@/utils/classnames'
|
import cn from '@/utils/classnames'
|
||||||
import { API_PREFIX, MARKETPLACE_URL_PREFIX } from '@/config'
|
import { API_PREFIX, MARKETPLACE_URL_PREFIX } from '@/config'
|
||||||
import { useInvalidateInstalledPluginList } from '@/service/use-plugins'
|
import { useInvalidateInstalledPluginList } from '@/service/use-plugins'
|
||||||
import { useInvalidateAllToolProviders } from '@/service/use-tools'
|
import { useInvalidateAllBuiltInTools, useInvalidateAllToolProviders } from '@/service/use-tools'
|
||||||
import { useCategories } from '../hooks'
|
import { useCategories } from '../hooks'
|
||||||
import { useProviderContext } from '@/context/provider-context'
|
import { useProviderContext } from '@/context/provider-context'
|
||||||
import { useRenderI18nObject } from '@/hooks/use-i18n'
|
import { useRenderI18nObject } from '@/hooks/use-i18n'
|
||||||
@ -41,6 +41,7 @@ const PluginItem: FC<Props> = ({
|
|||||||
const setCurrentPluginID = usePluginPageContext(v => v.setCurrentPluginID)
|
const setCurrentPluginID = usePluginPageContext(v => v.setCurrentPluginID)
|
||||||
const invalidateInstalledPluginList = useInvalidateInstalledPluginList()
|
const invalidateInstalledPluginList = useInvalidateInstalledPluginList()
|
||||||
const invalidateAllToolProviders = useInvalidateAllToolProviders()
|
const invalidateAllToolProviders = useInvalidateAllToolProviders()
|
||||||
|
const invalidateAllBuiltinTools = useInvalidateAllBuiltInTools()
|
||||||
const { refreshModelProviders } = useProviderContext()
|
const { refreshModelProviders } = useProviderContext()
|
||||||
|
|
||||||
const {
|
const {
|
||||||
@ -62,8 +63,10 @@ const PluginItem: FC<Props> = ({
|
|||||||
invalidateInstalledPluginList()
|
invalidateInstalledPluginList()
|
||||||
if (PluginType.model.includes(category))
|
if (PluginType.model.includes(category))
|
||||||
refreshModelProviders()
|
refreshModelProviders()
|
||||||
if (PluginType.tool.includes(category))
|
if (PluginType.tool.includes(category)) {
|
||||||
invalidateAllToolProviders()
|
invalidateAllToolProviders()
|
||||||
|
invalidateAllBuiltinTools()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
const getValueFromI18nObject = useRenderI18nObject()
|
const getValueFromI18nObject = useRenderI18nObject()
|
||||||
const title = getValueFromI18nObject(label)
|
const title = getValueFromI18nObject(label)
|
||||||
|
Loading…
Reference in New Issue
Block a user