Skip to content

Commit

Permalink
fix: the input field of tool panel not worked as expected (#6003)
Browse files Browse the repository at this point in the history
  • Loading branch information
hjlarry authored Jul 6, 2024
1 parent ab847c8 commit eee779a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
12 changes: 6 additions & 6 deletions api/core/tools/tool_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def get_tool_runtime(cls, provider_type: str,
'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')
Expand Down Expand Up @@ -201,7 +201,7 @@ def _init_runtime_parameter(cls, parameter_rule: ToolParameter, parameters: dict
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:
Expand Down Expand Up @@ -321,14 +321,14 @@ def list_builtin_providers(cls) -> Generator[BuiltinToolProviderController, None
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]:
"""
Expand Down Expand Up @@ -492,7 +492,7 @@ def get_api_provider_controller(cls, tenant_id: str, provider_id: str) -> tuple[

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)
Expand Down
1 change: 1 addition & 0 deletions web/app/components/base/select/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)}
Expand Down Expand Up @@ -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))
Expand All @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down

0 comments on commit eee779a

Please sign in to comment.