### What problem does this PR solve? Feat: Display operator icons on the agent form #3221 Fix: Fixed the issue where the form corresponding to the tool operator icon could not appear after clicking it #3211 ### Type of change - [x] New Feature (non-breaking change which adds functionality)tags/v0.20.0
| import { NodeHandleId, Operator } from '../../constant'; | import { NodeHandleId, Operator } from '../../constant'; | ||||
| import { ToolCard } from '../../form/agent-form/agent-tools'; | import { ToolCard } from '../../form/agent-form/agent-tools'; | ||||
| import { useFindMcpById } from '../../hooks/use-find-mcp-by-id'; | import { useFindMcpById } from '../../hooks/use-find-mcp-by-id'; | ||||
| import OperatorIcon from '../../operator-icon'; | |||||
| import useGraphStore from '../../store'; | import useGraphStore from '../../store'; | ||||
| import { NodeWrapper } from './node-wrapper'; | import { NodeWrapper } from './node-wrapper'; | ||||
| className="cursor-pointer" | className="cursor-pointer" | ||||
| data-tool={x.component_name} | data-tool={x.component_name} | ||||
| > | > | ||||
| {x.component_name} | |||||
| <div className="flex gap-1 items-center pointer-events-none"> | |||||
| <OperatorIcon name={x.component_name as Operator}></OperatorIcon> | |||||
| {x.component_name} | |||||
| </div> | |||||
| </ToolCard> | </ToolCard> | ||||
| ))} | ))} | ||||
| // no connection lines are allowed between key and value | // no connection lines are allowed between key and value | ||||
| export const RestrictedUpstreamMap = { | export const RestrictedUpstreamMap = { | ||||
| [Operator.Begin]: [Operator.Relevant], | [Operator.Begin]: [Operator.Relevant], | ||||
| [Operator.Categorize]: [ | |||||
| Operator.Begin, | |||||
| Operator.Categorize, | |||||
| Operator.Answer, | |||||
| Operator.Relevant, | |||||
| ], | |||||
| [Operator.Answer]: [ | |||||
| Operator.Begin, | |||||
| Operator.Answer, | |||||
| Operator.Message, | |||||
| Operator.Relevant, | |||||
| ], | |||||
| [Operator.Categorize]: [Operator.Begin, Operator.Categorize, Operator.Answer], | |||||
| [Operator.Answer]: [Operator.Begin, Operator.Answer, Operator.Message], | |||||
| [Operator.Retrieval]: [Operator.Begin, Operator.Retrieval], | [Operator.Retrieval]: [Operator.Begin, Operator.Retrieval], | ||||
| [Operator.Generate]: [Operator.Begin, Operator.Relevant], | [Operator.Generate]: [Operator.Begin, Operator.Relevant], | ||||
| [Operator.Message]: [ | [Operator.Message]: [ | ||||
| Operator.Retrieval, | Operator.Retrieval, | ||||
| Operator.RewriteQuestion, | Operator.RewriteQuestion, | ||||
| Operator.Categorize, | Operator.Categorize, | ||||
| Operator.Relevant, | |||||
| ], | ], | ||||
| [Operator.Relevant]: [Operator.Begin, Operator.Answer, Operator.Relevant], | |||||
| [Operator.Relevant]: [Operator.Begin, Operator.Answer], | |||||
| [Operator.RewriteQuestion]: [ | [Operator.RewriteQuestion]: [ | ||||
| Operator.Begin, | Operator.Begin, | ||||
| Operator.Message, | Operator.Message, | 
| import { AgentInstanceContext } from '../../context'; | import { AgentInstanceContext } from '../../context'; | ||||
| import { useFindMcpById } from '../../hooks/use-find-mcp-by-id'; | import { useFindMcpById } from '../../hooks/use-find-mcp-by-id'; | ||||
| import { INextOperatorForm } from '../../interface'; | import { INextOperatorForm } from '../../interface'; | ||||
| import OperatorIcon from '../../operator-icon'; | |||||
| import useGraphStore from '../../store'; | import useGraphStore from '../../store'; | ||||
| import { filterDownstreamAgentNodeIds } from '../../utils/filter-downstream-nodes'; | import { filterDownstreamAgentNodeIds } from '../../utils/filter-downstream-nodes'; | ||||
| import { ToolPopover } from './tool-popover'; | import { ToolPopover } from './tool-popover'; | ||||
| <ul className="space-y-2"> | <ul className="space-y-2"> | ||||
| {toolNames.map((x) => ( | {toolNames.map((x) => ( | ||||
| <ToolCard key={x}> | <ToolCard key={x}> | ||||
| {x} | |||||
| <div className="flex gap-2 items-center"> | |||||
| <OperatorIcon name={x as Operator}></OperatorIcon> | |||||
| {x} | |||||
| </div> | |||||
| <ActionButton | <ActionButton | ||||
| record={x} | record={x} | ||||
| deleteRecord={deleteNodeTool(x)} | deleteRecord={deleteNodeTool(x)} | 
| import { Calendar, CheckIcon } from 'lucide-react'; | |||||
| import { CheckIcon } from 'lucide-react'; | |||||
| import { | import { | ||||
| Command, | Command, | ||||
| import { useListMcpServer } from '@/hooks/use-mcp-request'; | import { useListMcpServer } from '@/hooks/use-mcp-request'; | ||||
| import { cn } from '@/lib/utils'; | import { cn } from '@/lib/utils'; | ||||
| import { Operator } from '@/pages/agent/constant'; | import { Operator } from '@/pages/agent/constant'; | ||||
| import OperatorIcon from '@/pages/agent/operator-icon'; | |||||
| import { lowerFirst } from 'lodash'; | |||||
| import { PropsWithChildren, useCallback, useEffect, useState } from 'react'; | import { PropsWithChildren, useCallback, useEffect, useState } from 'react'; | ||||
| import { useTranslation } from 'react-i18next'; | |||||
| const Menus = [ | const Menus = [ | ||||
| { | { | ||||
| Operator.TavilySearch, | Operator.TavilySearch, | ||||
| Operator.TavilyExtract, | Operator.TavilyExtract, | ||||
| Operator.Google, | Operator.Google, | ||||
| Operator.Bing, | |||||
| // Operator.Bing, | |||||
| Operator.DuckDuckGo, | Operator.DuckDuckGo, | ||||
| Operator.Wikipedia, | Operator.Wikipedia, | ||||
| Operator.YahooFinance, | Operator.YahooFinance, | ||||
| } | } | ||||
| export function ToolCommand({ value, onChange }: ToolCommandProps) { | export function ToolCommand({ value, onChange }: ToolCommandProps) { | ||||
| const { t } = useTranslation(); | |||||
| const { toggleOption, currentValue } = useHandleSelectChange({ | const { toggleOption, currentValue } = useHandleSelectChange({ | ||||
| onChange, | onChange, | ||||
| value, | value, | ||||
| isSelected={isSelected} | isSelected={isSelected} | ||||
| > | > | ||||
| <> | <> | ||||
| <Calendar /> | |||||
| <span>{y}</span> | |||||
| <OperatorIcon name={y as Operator}></OperatorIcon> | |||||
| <span>{t(`flow.${lowerFirst(y)}`)}</span> | |||||
| </> | </> | ||||
| </ToolCommandItem> | </ToolCommandItem> | ||||
| ); | ); |