From e04fc9b3049980fc3f27f121967fafba82400cea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9D=9E=E6=B3=95=E6=93=8D=E4=BD=9C?= Date: Wed, 12 Jun 2024 17:46:53 +0800 Subject: [PATCH] fix: select field not work when it is not required (#5101) --- api/core/tools/tool_manager.py | 2 +- web/app/components/base/select/index.tsx | 25 ++++++++++++++++++------ 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/api/core/tools/tool_manager.py b/api/core/tools/tool_manager.py index a0ca9f692a..aa184176a1 100644 --- a/api/core/tools/tool_manager.py +++ b/api/core/tools/tool_manager.py @@ -210,7 +210,7 @@ class ToolManager: if parameter_rule.type == ToolParameter.ToolParameterType.SELECT: # check if tool_parameter_config in options options = list(map(lambda x: x.value, parameter_rule.options)) - if parameter_value not in options: + if parameter_value is not None and parameter_value not in options: raise ValueError( f"tool parameter {parameter_rule.name} value {parameter_value} not in options {options}") diff --git a/web/app/components/base/select/index.tsx b/web/app/components/base/select/index.tsx index 503aeab635..51e371ac09 100644 --- a/web/app/components/base/select/index.tsx +++ b/web/app/components/base/select/index.tsx @@ -3,7 +3,7 @@ import type { FC } from 'react' import React, { Fragment, useEffect, useState } from 'react' import { Combobox, Listbox, Transition } from '@headlessui/react' import classNames from 'classnames' -import { CheckIcon, ChevronDownIcon, ChevronUpIcon } from '@heroicons/react/20/solid' +import { CheckIcon, ChevronDownIcon, ChevronUpIcon, XMarkIcon } from '@heroicons/react/20/solid' import { useTranslation } from 'react-i18next' import { PortalToFollowElem, @@ -184,11 +184,24 @@ const SimpleSelect: FC = ({
{selectedItem?.name ?? localPlaceholder} - - {!disabled && (