mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-14 05:36:02 +08:00
fix: Could not load the logo of workflow as Tool in Agent Node (#18243)
This commit is contained in:
parent
6d66e3f680
commit
9d139fa306
@ -10,6 +10,7 @@ import { Group } from '@/app/components/base/icons/src/vender/other'
|
|||||||
type Status = 'not-installed' | 'not-authorized' | undefined
|
type Status = 'not-installed' | 'not-authorized' | undefined
|
||||||
|
|
||||||
export type ToolIconProps = {
|
export type ToolIconProps = {
|
||||||
|
id: string
|
||||||
providerName: string
|
providerName: string
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -29,10 +30,11 @@ export const ToolIcon = memo(({ providerName }: ToolIconProps) => {
|
|||||||
const author = providerNameParts[0]
|
const author = providerNameParts[0]
|
||||||
const name = providerNameParts[1]
|
const name = providerNameParts[1]
|
||||||
const icon = useMemo(() => {
|
const icon = useMemo(() => {
|
||||||
|
if (!isDataReady) return ''
|
||||||
if (currentProvider) return currentProvider.icon as string
|
if (currentProvider) return currentProvider.icon as string
|
||||||
const iconFromMarketPlace = getIconFromMarketPlace(`${author}/${name}`)
|
const iconFromMarketPlace = getIconFromMarketPlace(`${author}/${name}`)
|
||||||
return iconFromMarketPlace
|
return iconFromMarketPlace
|
||||||
}, [author, currentProvider, name])
|
}, [author, currentProvider, name, isDataReady])
|
||||||
const status: Status = useMemo(() => {
|
const status: Status = useMemo(() => {
|
||||||
if (!isDataReady) return undefined
|
if (!isDataReady) return undefined
|
||||||
if (!currentProvider) return 'not-installed'
|
if (!currentProvider) return 'not-installed'
|
||||||
@ -60,7 +62,7 @@ export const ToolIcon = memo(({ providerName }: ToolIconProps) => {
|
|||||||
)}
|
)}
|
||||||
ref={containerRef}
|
ref={containerRef}
|
||||||
>
|
>
|
||||||
{!iconFetchError
|
{(!iconFetchError && isDataReady)
|
||||||
|
|
||||||
? <img
|
? <img
|
||||||
src={icon}
|
src={icon}
|
||||||
|
@ -39,12 +39,13 @@ const AgentNode: FC<NodeProps<AgentNodeType>> = (props) => {
|
|||||||
|
|
||||||
const tools = useMemo(() => {
|
const tools = useMemo(() => {
|
||||||
const tools: Array<ToolIconProps> = []
|
const tools: Array<ToolIconProps> = []
|
||||||
currentStrategy?.parameters.forEach((param) => {
|
currentStrategy?.parameters.forEach((param, i) => {
|
||||||
if (param.type === FormTypeEnum.toolSelector) {
|
if (param.type === FormTypeEnum.toolSelector) {
|
||||||
const field = param.name
|
const field = param.name
|
||||||
const value = inputs.agent_parameters?.[field]?.value
|
const value = inputs.agent_parameters?.[field]?.value
|
||||||
if (value) {
|
if (value) {
|
||||||
tools.push({
|
tools.push({
|
||||||
|
id: `${param.name}-${i}`,
|
||||||
providerName: value.provider_name as any,
|
providerName: value.provider_name as any,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -55,6 +56,7 @@ const AgentNode: FC<NodeProps<AgentNodeType>> = (props) => {
|
|||||||
if (value) {
|
if (value) {
|
||||||
(value as unknown as any[]).forEach((item) => {
|
(value as unknown as any[]).forEach((item) => {
|
||||||
tools.push({
|
tools.push({
|
||||||
|
id: `${param.name}-${i}`,
|
||||||
providerName: item.provider_name,
|
providerName: item.provider_name,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -102,8 +104,7 @@ const AgentNode: FC<NodeProps<AgentNodeType>> = (props) => {
|
|||||||
{t('workflow.nodes.agent.toolbox')}
|
{t('workflow.nodes.agent.toolbox')}
|
||||||
</GroupLabel>}>
|
</GroupLabel>}>
|
||||||
<div className='grid grid-cols-10 gap-0.5'>
|
<div className='grid grid-cols-10 gap-0.5'>
|
||||||
{/* eslint-disable-next-line sonarjs/no-uniq-key */}
|
{tools.map(tool => <ToolIcon {...tool} key={tool.id} />)}
|
||||||
{tools.map(tool => <ToolIcon {...tool} key={Math.random()} />)}
|
|
||||||
</div>
|
</div>
|
||||||
</Group>}
|
</Group>}
|
||||||
</div>
|
</div>
|
||||||
|
@ -54,7 +54,6 @@ const AgentPanel: FC<NodePanelProps<AgentNodeType>> = (props) => {
|
|||||||
outputSchema,
|
outputSchema,
|
||||||
handleMemoryChange,
|
handleMemoryChange,
|
||||||
} = useConfig(props.id, props.data)
|
} = useConfig(props.id, props.data)
|
||||||
console.log('currentStrategy', currentStrategy)
|
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const nodeInfo = useMemo(() => {
|
const nodeInfo = useMemo(() => {
|
||||||
if (!runResult)
|
if (!runResult)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user