Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

fix: agent app add tool hasn't add default params config (#29330)

Joelf5d676f3f155
diff --git a/web/app/components/app/configuration/config/agent/agent-tools/index.tsx b/web/app/components/app/configuration/config/agent/agent-tools/index.tsx
index b51c2ad94d6..5716bfd92d7 100644
--- a/web/app/components/app/configuration/config/agent/agent-tools/index.tsx
+++ b/web/app/components/app/configuration/config/agent/agent-tools/index.tsx
@@ -32,6 +32,7 @@ import { canFindTool } from '@/utils'
import { useAllBuiltInTools, useAllCustomTools, useAllMCPTools, useAllWorkflowTools } from '@/service/use-tools'
import type { ToolWithProvider } from '@/app/components/workflow/types'
import { useMittContextSelector } from '@/context/mitt-context'
+import { addDefaultValue, toolParametersToFormSchemas } from '@/app/components/tools/utils/to-form-schema'
type AgentToolWithMoreInfo = AgentTool & { icon: any; collection?: Collection } | null
const AgentTools: FC = () => {
@@ -93,13 +94,17 @@ const AgentTools: FC = () => {
const [isDeleting, setIsDeleting] = useState<number>(-1)
const getToolValue = (tool: ToolDefaultValue) => {
+ const currToolInCollections = collectionList.find(c => c.id === tool.provider_id)
+ const currToolWithConfigs = currToolInCollections?.tools.find(t => t.name === tool.tool_name)
+ const formSchemas = currToolWithConfigs ? toolParametersToFormSchemas(currToolWithConfigs.parameters) : []
+ const paramsWithDefaultValue = addDefaultValue(tool.params, formSchemas)
return {
provider_id: tool.provider_id,
provider_type: tool.provider_type as CollectionType,
provider_name: tool.provider_name,
tool_name: tool.tool_name,
tool_label: tool.tool_label,
- tool_parameters: tool.params,
+ tool_parameters: paramsWithDefaultValue,
notAuthor: !tool.is_team_authorization,
enabled: true,
}
@@ -119,7 +124,7 @@ const AgentTools: FC = () => {
}
const getProviderShowName = (item: AgentTool) => {
const type = item.provider_type
- if(type === CollectionType.builtIn)
+ if (type === CollectionType.builtIn)
return item.provider_name.split('/').pop()
return item.provider_name
}
diff --git a/web/app/components/app/configuration/config/agent/agent-tools/setting-built-in-tool.tsx b/web/app/components/app/configuration/config/agent/agent-tools/setting-built-in-tool.tsx
index ef28dd222c5..0d23d9aecd1 100644
--- a/web/app/components/app/configuration/config/agent/agent-tools/setting-built-in-tool.tsx
+++ b/web/app/components/app/configuration/config/agent/agent-tools/setting-built-in-tool.tsx
@@ -73,8 +73,15 @@ const SettingBuiltInTool: FC<Props> = ({
const [currType, setCurrType] = useState('info')
const isInfoActive = currType === 'info'
useEffect(() => {
- if (!collection || hasPassedTools)
+ if (!collection)
return
+ if (hasPassedTools) {
+ if (currTool) {
+ const formSchemas = toolParametersToFormSchemas(currTool.parameters)
+ setTempSetting(addDefaultValue(setting, formSchemas))
+ }
+ return
+ }
(async () => {
setIsLoading(true)