fix: tool id (#13932)

This commit is contained in:
zxhlyh
2025-02-18 18:17:41 +08:00
committed by GitHub
parent 653f6c2d46
commit 3460c1dfbd
10 changed files with 53 additions and 25 deletions

View File

@@ -26,6 +26,7 @@ import { CollectionType } from '@/app/components/tools/types'
import { useGetLanguage } from '@/context/i18n'
import type { AgentNodeType } from '../nodes/agent/types'
import { useStrategyProviders } from '@/service/use-strategy'
import { canFindTool } from '@/utils'
export const useChecklist = (nodes: Node[], edges: Edge[]) => {
const { t } = useTranslation()
@@ -51,7 +52,7 @@ export const useChecklist = (nodes: Node[], edges: Edge[]) => {
moreDataForCheckValid = getToolCheckParams(node.data as ToolNodeType, buildInTools, customTools, workflowTools, language)
if (provider_type === CollectionType.builtIn)
toolIcon = buildInTools.find(tool => tool.id === node.data.provider_id)?.icon
toolIcon = buildInTools.find(tool => canFindTool(tool.id, node.data.provider_id || ''))?.icon
if (provider_type === CollectionType.custom)
toolIcon = customTools.find(tool => tool.id === node.data.provider_id)?.icon

View File

@@ -58,6 +58,7 @@ import I18n from '@/context/i18n'
import { CollectionType } from '@/app/components/tools/types'
import { CUSTOM_ITERATION_START_NODE } from '@/app/components/workflow/nodes/iteration-start/constants'
import { useWorkflowConfig } from '@/service/use-workflow'
import { canFindTool } from '@/utils'
export const useIsChatMode = () => {
const appDetail = useAppStore(s => s.appDetail)
@@ -608,11 +609,7 @@ export const useToolIcon = (data: Node['data']) => {
targetTools = customTools
else
targetTools = workflowTools
return targetTools.find((toolWithProvider) => {
return toolWithProvider.id === data.provider_id
|| toolWithProvider.id === `langgenius/${data.provider_id}/${data.provider_id}`
|| toolWithProvider.id === `langgenius/${data.provider_id}_tool/${data.provider_id}`
})?.icon
return targetTools.find(toolWithProvider => canFindTool(toolWithProvider.id, data.provider_id))?.icon
}
}, [data, buildInTools, customTools, workflowTools])

View File

@@ -22,6 +22,7 @@ import type { Node } from '@/app/components/workflow/types'
import { BlockEnum } from '@/app/components/workflow/types'
import { useGetLanguage } from '@/context/i18n'
import { CollectionType } from '@/app/components/tools/types'
import { canFindTool } from '@/utils'
type PanelOperatorPopupProps = {
id: string
@@ -57,7 +58,7 @@ const PanelOperatorPopup = ({
return nodesExtraData[data.type].author
if (data.provider_type === CollectionType.builtIn)
return buildInTools.find(toolWithProvider => toolWithProvider.id === data.provider_id)?.author
return buildInTools.find(toolWithProvider => canFindTool(toolWithProvider.id, data.provider_id))?.author
if (data.provider_type === CollectionType.workflow)
return workflowTools.find(toolWithProvider => toolWithProvider.id === data.provider_id)?.author
@@ -70,7 +71,7 @@ const PanelOperatorPopup = ({
return nodesExtraData[data.type].about
if (data.provider_type === CollectionType.builtIn)
return buildInTools.find(toolWithProvider => toolWithProvider.id === data.provider_id)?.description[language]
return buildInTools.find(toolWithProvider => canFindTool(toolWithProvider.id, data.provider_id))?.description[language]
if (data.provider_type === CollectionType.workflow)
return workflowTools.find(toolWithProvider => toolWithProvider.id === data.provider_id)?.description[language]

View File

@@ -14,6 +14,7 @@ import type { ToolParameter } from '@/app/components/tools/types'
import { CollectionType } from '@/app/components/tools/types'
import type { BlockEnum } from '@/app/components/workflow/types'
import { useLanguage } from '@/app/components/header/account-setting/model-provider-page/hooks'
import { canFindTool } from '@/utils'
const i18nPrefix = 'workflow.nodes.parameterExtractor'
@@ -56,7 +57,7 @@ const ImportFromTool: FC<Props> = ({
return []
}
})()
const currCollection = currentTools.find(item => item.id === provider_id)
const currCollection = currentTools.find(item => canFindTool(item.id, provider_id))
const currTool = currCollection?.tools.find(tool => tool.name === tool_name)
const toExactParams = (currTool?.parameters || []).filter((item: any) => item.form === 'llm')
const formattedParams = toParmExactParams(toExactParams, language)

View File

@@ -18,6 +18,7 @@ import {
useFetchToolsData,
useNodesReadOnly,
} from '@/app/components/workflow/hooks'
import { canFindTool } from '@/utils'
const useConfig = (id: string, payload: ToolNodeType) => {
const { nodesReadOnly: readOnly } = useNodesReadOnly()
@@ -49,7 +50,7 @@ const useConfig = (id: string, payload: ToolNodeType) => {
return []
}
})()
const currCollection = currentTools.find(item => item.id === provider_id)
const currCollection = currentTools.find(item => canFindTool(item.id, provider_id))
// Auth
const needAuth = !!currCollection?.allow_delete

View File

@@ -41,7 +41,7 @@ import type { ToolNodeType } from './nodes/tool/types'
import type { IterationNodeType } from './nodes/iteration/types'
import { CollectionType } from '@/app/components/tools/types'
import { toolParametersToFormSchemas } from '@/app/components/tools/utils/to-form-schema'
import { correctProvider } from '@/utils'
import { canFindTool, correctModelProvider } from '@/utils'
const WHITE = 'WHITE'
const GRAY = 'GRAY'
@@ -284,16 +284,16 @@ export const initialNodes = (originNodes: Node[], originEdges: Edge[]) => {
// legacy provider handle
if (node.data.type === BlockEnum.LLM)
(node as any).data.model.provider = correctProvider((node as any).data.model.provider)
(node as any).data.model.provider = correctModelProvider((node as any).data.model.provider)
if (node.data.type === BlockEnum.KnowledgeRetrieval && (node as any).data.multiple_retrieval_config.reranking_model)
(node as any).data.multiple_retrieval_config.reranking_model.provider = correctProvider((node as any).data.multiple_retrieval_config.reranking_model.provider)
(node as any).data.multiple_retrieval_config.reranking_model.provider = correctModelProvider((node as any).data.multiple_retrieval_config.reranking_model.provider)
if (node.data.type === BlockEnum.QuestionClassifier)
(node as any).data.model.provider = correctProvider((node as any).data.model.provider)
(node as any).data.model.provider = correctModelProvider((node as any).data.model.provider)
if (node.data.type === BlockEnum.ParameterExtractor)
(node as any).data.model.provider = correctProvider((node as any).data.model.provider)
(node as any).data.model.provider = correctModelProvider((node as any).data.model.provider)
if (node.data.type === BlockEnum.HttpRequest && !node.data.retry_config) {
node.data.retry_config = {
retry_enabled: true,
@@ -517,7 +517,7 @@ export const getToolCheckParams = (
const { provider_id, provider_type, tool_name } = toolData
const isBuiltIn = provider_type === CollectionType.builtIn
const currentTools = provider_type === CollectionType.builtIn ? buildInTools : provider_type === CollectionType.custom ? customTools : workflowTools
const currCollection = currentTools.find(item => item.id === provider_id)
const currCollection = currentTools.find(item => canFindTool(item.id, provider_id))
const currTool = currCollection?.tools.find(tool => tool.name === tool_name)
const formSchemas = currTool ? toolParametersToFormSchemas(currTool.parameters) : []
const toolInputVarSchema = formSchemas.filter((item: any) => item.form === 'llm')