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: the input field of tool panel not worked as expected (#6003)

非法操作eee779a9238d
diff --git a/api/core/tools/tool_manager.py b/api/core/tools/tool_manager.py
index 9fcadbd3913..e30a905cbcf 100644
--- a/api/core/tools/tool_manager.py
+++ b/api/core/tools/tool_manager.py
@@ -154,7 +154,7 @@ class ToolManager:
'invoke_from': invoke_from,
'tool_invoke_from': tool_invoke_from,
})
-
+
elif provider_type == 'api':
if tenant_id is None:
raise ValueError('tenant id is required for api provider')
@@ -201,7 +201,7 @@ class ToolManager:
init runtime parameter
"""
parameter_value = parameters.get(parameter_rule.name)
- if not parameter_value:
+ if not parameter_value and parameter_value != 0:
# get default value
parameter_value = parameter_rule.default
if not parameter_value and parameter_rule.required:
@@ -321,14 +321,14 @@ class ToolManager:
if cls._builtin_providers_loaded:
yield from list(cls._builtin_providers.values())
return
-
+
with cls._builtin_provider_lock:
if cls._builtin_providers_loaded:
yield from list(cls._builtin_providers.values())
return
-
+
yield from cls._list_builtin_providers()
-
+
@classmethod
def _list_builtin_providers(cls) -> Generator[BuiltinToolProviderController, None, None]:
"""
@@ -492,7 +492,7 @@ class ToolManager:
controller = ApiToolProviderController.from_db(
provider,
- ApiProviderAuthType.API_KEY if provider.credentials['auth_type'] == 'api_key' else
+ ApiProviderAuthType.API_KEY if provider.credentials['auth_type'] == 'api_key' else
ApiProviderAuthType.NONE
)
controller.load_bundled_tools(provider.tools)
diff --git a/web/app/components/base/select/index.tsx b/web/app/components/base/select/index.tsx
index 51e371ac09a..b342ef29bbb 100644
--- a/web/app/components/base/select/index.tsx
+++ b/web/app/components/base/select/index.tsx
@@ -191,6 +191,7 @@ const SimpleSelect: FC<ISelectProps> = ({
onClick={(e) => {
e.stopPropagation()
setSelectedItem(null)
+ onSelect({ value: null })
}}
className="h-5 w-5 text-gray-400 cursor-pointer"
aria-hidden="false"
diff --git a/web/app/components/header/account-setting/model-provider-page/model-modal/Form.tsx b/web/app/components/header/account-setting/model-provider-page/model-modal/Form.tsx
index ca9f3cbd38c..cc8aa92fec7 100644
--- a/web/app/components/header/account-setting/model-provider-page/model-modal/Form.tsx
+++ b/web/app/components/header/account-setting/model-provider-page/model-modal/Form.tsx
@@ -114,7 +114,7 @@ const Form: FC<FormProps> = ({
validated={validatedSuccess}
placeholder={placeholder?.[language] || placeholder?.en_US}
disabled={disabed}
- type={formSchema.type === FormTypeEnum.textNumber ? 'number' : 'text'}
+ type={formSchema.type === FormTypeEnum.textNumber ? 'number' : formSchema.type === FormTypeEnum.secretInput ? 'password' : 'text'}
{...(formSchema.type === FormTypeEnum.textNumber ? { min: (formSchema as CredentialFormSchemaNumberInput).min, max: (formSchema as CredentialFormSchemaNumberInput).max } : {})}
/>
{fieldMoreInfo?.(formSchema)}
@@ -229,6 +229,7 @@ const Form: FC<FormProps> = ({
variable,
label,
show_on,
+ required,
} = formSchema as CredentialFormSchemaRadio
if (show_on.length && !show_on.every(showOnItem => value[showOnItem.variable] === showOnItem.value))
@@ -239,11 +240,16 @@ const Form: FC<FormProps> = ({
<div className='flex items-center justify-between py-2 text-sm text-gray-900'>
<div className='flex items-center space-x-2'>
<span className={cn(fieldLabelClassName, 'py-2 text-sm text-gray-900')}>{label[language] || label.en_US}</span>
+ {
+ required && (
+ <span className='ml-1 text-red-500'>*</span>
+ )
+ }
{tooltipContent}
</div>
<Radio.Group
className='flex items-center'
- value={value[variable] ? 1 : 0}
+ value={value[variable] === null ? undefined : (value[variable] ? 1 : 0)}
onChange={val => handleFormChange(variable, val === 1)}
>
<Radio value={1} className='!mr-1'>True</Radio>
diff --git a/web/app/components/header/account-setting/model-provider-page/model-modal/Input.tsx b/web/app/components/header/account-setting/model-provider-page/model-modal/Input.tsx
index 12244a5cef8..86d52619e69 100644
--- a/web/app/components/header/account-setting/model-provider-page/model-modal/Input.tsx
+++ b/web/app/components/header/account-setting/model-provider-page/model-modal/Input.tsx
@@ -53,7 +53,7 @@ const Input: FC<InputProps> = ({
onChange={e => onChange(e.target.value)}
onBlur={e => toLimit(e.target.value)}
onFocus={onFocus}
- value={value || ''}
+ value={value}
disabled={disabled}
type={type}
min={min}