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.

chore: not set empty tool config to default value (#29338)

Joeld79d0a47a7a7
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 0d23d9aecd1..c5947495db0 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
@@ -16,7 +16,7 @@ import Description from '@/app/components/plugins/card/base/description'
import TabSlider from '@/app/components/base/tab-slider-plain'
import Button from '@/app/components/base/button'
import Form from '@/app/components/header/account-setting/model-provider-page/model-modal/Form'
-import { addDefaultValue, toolParametersToFormSchemas } from '@/app/components/tools/utils/to-form-schema'
+import { toolParametersToFormSchemas } from '@/app/components/tools/utils/to-form-schema'
import type { Collection, Tool } from '@/app/components/tools/types'
import { CollectionType } from '@/app/components/tools/types'
import { fetchBuiltInToolList, fetchCustomToolList, fetchModelToolList, fetchWorkflowToolList } from '@/service/tools'
@@ -73,15 +73,8 @@ const SettingBuiltInTool: FC<Props> = ({
const [currType, setCurrType] = useState('info')
const isInfoActive = currType === 'info'
useEffect(() => {
- if (!collection)
+ if (!collection || hasPassedTools)
return
- if (hasPassedTools) {
- if (currTool) {
- const formSchemas = toolParametersToFormSchemas(currTool.parameters)
- setTempSetting(addDefaultValue(setting, formSchemas))
- }
- return
- }
(async () => {
setIsLoading(true)
@@ -99,15 +92,11 @@ const SettingBuiltInTool: FC<Props> = ({
}())
})
setTools(list)
- const currTool = list.find(tool => tool.name === toolName)
- if (currTool) {
- const formSchemas = toolParametersToFormSchemas(currTool.parameters)
- setTempSetting(addDefaultValue(setting, formSchemas))
- }
}
catch { }
setIsLoading(false)
})()
+ // eslint-disable-next-line react-hooks/exhaustive-deps
}, [collection?.name, collection?.id, collection?.type])
useEffect(() => {
@@ -256,7 +245,7 @@ const SettingBuiltInTool: FC<Props> = ({
{!readonly && !isInfoActive && (
<div className='flex shrink-0 justify-end space-x-2 rounded-b-[10px] bg-components-panel-bg py-2'>
<Button className='flex h-8 items-center !px-3 !text-[13px] font-medium ' onClick={onHide}>{t('common.operation.cancel')}</Button>
- <Button className='flex h-8 items-center !px-3 !text-[13px] font-medium' variant='primary' disabled={!isValid} onClick={() => onSave?.(addDefaultValue(tempSetting, formSchemas))}>{t('common.operation.save')}</Button>
+ <Button className='flex h-8 items-center !px-3 !text-[13px] font-medium' variant='primary' disabled={!isValid} onClick={() => onSave?.(tempSetting)}>{t('common.operation.save')}</Button>
</div>
)}
</div>