From 78da4ca024c19ac98f98bd153eb66a952b62dadb Mon Sep 17 00:00:00 2001 From: KVOJJJin Date: Fri, 11 Apr 2025 14:40:57 +0800 Subject: [PATCH 01/20] fix: do not submit value when file input is optional (#17861) --- .../share/text-generation/run-once/index.tsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/web/app/components/share/text-generation/run-once/index.tsx b/web/app/components/share/text-generation/run-once/index.tsx index e413bd53ac..721dbb42c3 100644 --- a/web/app/components/share/text-generation/run-once/index.tsx +++ b/web/app/components/share/text-generation/run-once/index.tsx @@ -45,7 +45,10 @@ const RunOnce: FC = ({ const onClear = () => { const newInputs: Record = {} promptConfig.prompt_variables.forEach((item) => { - newInputs[item.key] = '' + if (item.type === 'text-input' || item.type === 'paragraph') + newInputs[item.key] = '' + else + newInputs[item.key] = undefined }) onInputsChange(newInputs) } @@ -63,7 +66,10 @@ const RunOnce: FC = ({ useEffect(() => { const newInputs: Record = {} promptConfig.prompt_variables.forEach((item) => { - newInputs[item.key] = '' + if (item.type === 'text-input' || item.type === 'paragraph') + newInputs[item.key] = '' + else + newInputs[item.key] = undefined }) onInputsChange(newInputs) }, [promptConfig.prompt_variables, onInputsChange]) From b2f5ca356a90985f35ae538e608064e2c7afc957 Mon Sep 17 00:00:00 2001 From: Yeuoly <45712896+Yeuoly@users.noreply.github.com> Date: Fri, 11 Apr 2025 15:20:03 +0800 Subject: [PATCH 02/20] enhance(plugin): replace json.loads with Pydantic model_validate_json (#17867) --- api/core/plugin/manager/base.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/api/core/plugin/manager/base.py b/api/core/plugin/manager/base.py index 7985aa68da..ea6b338725 100644 --- a/api/core/plugin/manager/base.py +++ b/api/core/plugin/manager/base.py @@ -168,15 +168,14 @@ class BasePluginManager: Make a stream request to the plugin daemon inner API and yield the response as a model. """ for line in self._stream_request(method, path, params, headers, data, files): - line_data = None try: - line_data = json.loads(line) - rep = PluginDaemonBasicResponse[type](**line_data) # type: ignore + rep = PluginDaemonBasicResponse[type].model_validate_json(line) # type: ignore except Exception: # TODO modify this when line_data has code and message - if line_data and "error" in line_data: + try: + line_data = json.loads(line) raise ValueError(line_data["error"]) - else: + except Exception: raise ValueError(line) if rep.code != 0: From fe19cc75688b64fe835b9f327f81da68777cc4e9 Mon Sep 17 00:00:00 2001 From: Good Wood Date: Fri, 11 Apr 2025 15:24:16 +0800 Subject: [PATCH 03/20] fix: in variable settings, use Textarea to replace Input. (#17864) --- .../components/variable-modal.tsx | 6 ++++-- .../panel/env-panel/variable-modal.tsx | 20 +++++++++++++------ 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/web/app/components/workflow/panel/chat-variable-panel/components/variable-modal.tsx b/web/app/components/workflow/panel/chat-variable-panel/components/variable-modal.tsx index 739d252791..ebd755eae5 100644 --- a/web/app/components/workflow/panel/chat-variable-panel/components/variable-modal.tsx +++ b/web/app/components/workflow/panel/chat-variable-panel/components/variable-modal.tsx @@ -322,9 +322,11 @@ const ChatVariableModal = ({
{type === ChatVarType.String && ( - setValue(e.target.value)} /> )} diff --git a/web/app/components/workflow/panel/env-panel/variable-modal.tsx b/web/app/components/workflow/panel/env-panel/variable-modal.tsx index 7692053c61..41a735e9a9 100644 --- a/web/app/components/workflow/panel/env-panel/variable-modal.tsx +++ b/web/app/components/workflow/panel/env-panel/variable-modal.tsx @@ -131,12 +131,20 @@ const VariableModal = ({
{t('workflow.env.modal.value')}
- setValue(e.target.value)} - type={type !== 'number' ? 'text' : 'number'} - /> + { + type !== 'number' ?