From 618729a2541e7b82ed3121cb99aa0f9a5eb00865 Mon Sep 17 00:00:00 2001
From: Archer <545436317@qq.com>
Date: Tue, 22 Oct 2024 12:04:16 +0800
Subject: [PATCH] Concat textinput to input type (#2963)
* perf: toast position
* concat textinput to input
---
.../zh-cn/docs/development/upgrading/4812.md | 23 +++++++++++--------
packages/global/core/workflow/constants.ts | 9 +-------
.../global/core/workflow/node/constant.ts | 12 +++-------
packages/global/core/workflow/utils.ts | 4 ----
.../plugins/src/databaseConnection/index.ts | 7 +++---
.../workflow/dispatch/agent/runTool/index.ts | 4 ++--
.../core/workflow/NodeInputSelect.tsx | 5 ----
.../src/components/core/app/VariableEdit.tsx | 7 ++----
.../ChatBox/components/VariableInput.tsx | 22 ++++++------------
.../core/chat/components/AIResponseBox.tsx | 22 +++++-------------
.../Workflow/components/SaveButton.tsx | 2 +-
.../Flow/components/SaveAndPublish.tsx | 2 +-
.../NodeFormInput/InputFormEditModal.tsx | 4 ++--
.../nodes/NodePluginIO/InputEditModal.tsx | 2 +-
.../nodes/NodePluginIO/InputTypeConfig.tsx | 6 ++---
.../Flow/nodes/render/RenderInput/index.tsx | 4 ----
.../RenderInput/templates/TextInput.tsx | 6 ++---
17 files changed, 47 insertions(+), 94 deletions(-)
diff --git a/docSite/content/zh-cn/docs/development/upgrading/4812.md b/docSite/content/zh-cn/docs/development/upgrading/4812.md
index d56ee1229..145100461 100644
--- a/docSite/content/zh-cn/docs/development/upgrading/4812.md
+++ b/docSite/content/zh-cn/docs/development/upgrading/4812.md
@@ -9,13 +9,16 @@ weight: 812
## 更新说明
-1. 新增 - 全局变量支持数字类型,并且支持配置默认值和部分输入框参数。
-2. 新增 - FE_DOMAIN 环境变量,配置该环境变量后,上传文件/图片会补全后缀后得到完整地址。(可解决 docx 文件图片链接,有时会无法被模型识别问题)
-3. 新增 - 工具调用支持交互模式
-4. 新增 - Debug 模式支持输入全局变量
-5. 新增 - chat openapi 文档
-6. 新增 - wiki 搜索插件
-7. 新增 - Cookie 隐私协议提示
-8. 修复 - 文件后缀判断,去除 query 影响。
-9. 修复 - AI 响应为空时,会造成 LLM 历史记录合并。
-10. 修复 - 用户交互节点未阻塞流程。
+1. 新增 - 全局变量支持数字类型,支持配置默认值和部分输入框参数。
+2. 新增 - 插件自定义输入,文本输入框、数字输入框、选择框、开关,默认都支持作为变量引用。
+3. 新增 - FE_DOMAIN 环境变量,配置该环境变量后,上传文件/图片会补全后缀后得到完整地址。(可解决 docx 文件图片链接,有时会无法被模型识别问题)
+4. 新增 - 工具调用支持交互模式
+5. 新增 - Debug 模式支持输入全局变量
+6. 新增 - chat OpenAPI 文档
+7. 新增 - wiki 搜索插件
+8. 新增 - Google 搜索插件
+9. 新增 - 数据库连接和操作插件
+10. 新增 - Cookie 隐私协议提示
+11. 修复 - 文件后缀判断,去除 query 影响。
+12. 修复 - AI 响应为空时,会造成 LLM 历史记录合并。
+13. 修复 - 用户交互节点未阻塞流程。
diff --git a/packages/global/core/workflow/constants.ts b/packages/global/core/workflow/constants.ts
index a7918f7f6..7219f972f 100644
--- a/packages/global/core/workflow/constants.ts
+++ b/packages/global/core/workflow/constants.ts
@@ -267,7 +267,6 @@ export enum NodeOutputKeyEnum {
export enum VariableInputEnum {
input = 'input',
textarea = 'textarea',
- textInput = 'textInput',
numberInput = 'numberInput',
select = 'select',
custom = 'custom'
@@ -284,7 +283,7 @@ export const variableMap: Record<
> = {
[VariableInputEnum.input]: {
icon: 'core/workflow/inputType/input',
- label: i18nT('common:core.workflow.inputType.input'),
+ label: i18nT('common:core.workflow.inputType.textInput'),
value: VariableInputEnum.input,
defaultValueType: WorkflowIOValueTypeEnum.string
},
@@ -295,12 +294,6 @@ export const variableMap: Record<
defaultValueType: WorkflowIOValueTypeEnum.string,
description: i18nT('app:variable.textarea_type_desc')
},
- [VariableInputEnum.textInput]: {
- icon: 'core/workflow/inputType/input',
- label: i18nT('common:core.workflow.inputType.textInput'),
- value: VariableInputEnum.textInput,
- defaultValueType: WorkflowIOValueTypeEnum.string
- },
[VariableInputEnum.numberInput]: {
icon: 'core/workflow/inputType/numberInput',
label: i18nT('common:core.workflow.inputType.number input'),
diff --git a/packages/global/core/workflow/node/constant.ts b/packages/global/core/workflow/node/constant.ts
index 5f05852e8..54dfa55ba 100644
--- a/packages/global/core/workflow/node/constant.ts
+++ b/packages/global/core/workflow/node/constant.ts
@@ -1,8 +1,9 @@
import { WorkflowIOValueTypeEnum } from '../constants';
import { i18nT } from '../../../../web/i18n/utils';
export enum FlowNodeInputTypeEnum { // render ui
- textInput = 'textInput',
reference = 'reference', // reference to other node output
+ input = 'input', // one line input
+ textarea = 'textarea',
numberInput = 'numberInput',
switch = 'switch', // true/false
select = 'select',
@@ -26,11 +27,7 @@ export enum FlowNodeInputTypeEnum { // render ui
settingDatasetQuotePrompt = 'settingDatasetQuotePrompt',
hidden = 'hidden',
- custom = 'custom',
-
- // deprecated
- input = 'input', // one line input
- textarea = 'textarea'
+ custom = 'custom'
}
export const FlowNodeInputMap: Record<
FlowNodeInputTypeEnum,
@@ -38,9 +35,6 @@ export const FlowNodeInputMap: Record<
icon: string;
}
> = {
- [FlowNodeInputTypeEnum.textInput]: {
- icon: 'core/workflow/inputType/input'
- },
[FlowNodeInputTypeEnum.reference]: {
icon: 'core/workflow/inputType/reference'
},
diff --git a/packages/global/core/workflow/utils.ts b/packages/global/core/workflow/utils.ts
index af2c7cc6a..6fbb98138 100644
--- a/packages/global/core/workflow/utils.ts
+++ b/packages/global/core/workflow/utils.ts
@@ -230,10 +230,6 @@ export const appData2FlowNodeIO = ({
FlowNodeInputTypeEnum.textarea,
FlowNodeInputTypeEnum.reference
],
- [VariableInputEnum.textInput]: [
- FlowNodeInputTypeEnum.textInput,
- FlowNodeInputTypeEnum.reference
- ],
[VariableInputEnum.numberInput]: [FlowNodeInputTypeEnum.numberInput],
[VariableInputEnum.select]: [FlowNodeInputTypeEnum.select],
[VariableInputEnum.custom]: [
diff --git a/packages/plugins/src/databaseConnection/index.ts b/packages/plugins/src/databaseConnection/index.ts
index 1735e44bd..a4df10fe2 100644
--- a/packages/plugins/src/databaseConnection/index.ts
+++ b/packages/plugins/src/databaseConnection/index.ts
@@ -60,11 +60,10 @@ const main = async ({
// 使用类型断言来处理错误
if (error instanceof Error) {
console.error('Database query error:', error.message);
- throw new Error(error.message);
- } else {
- console.error('Database query error:', error);
- throw new Error('An unknown error occurred');
+ return Promise.reject(error.message);
}
+ console.error('Database query error:', error);
+ return Promise.reject('An unknown error occurred');
}
};
diff --git a/packages/service/core/workflow/dispatch/agent/runTool/index.ts b/packages/service/core/workflow/dispatch/agent/runTool/index.ts
index 587f04d13..325f1260b 100644
--- a/packages/service/core/workflow/dispatch/agent/runTool/index.ts
+++ b/packages/service/core/workflow/dispatch/agent/runTool/index.ts
@@ -152,8 +152,8 @@ export const dispatchRunTools = async (props: DispatchToolModuleProps): Promise<
} = await (async () => {
const adaptMessages = chats2GPTMessages({
messages,
- reserveId: false,
- reserveTool: !!toolModel.toolChoice
+ reserveId: false
+ // reserveTool: !!toolModel.toolChoice
});
if (toolModel.toolChoice) {
diff --git a/packages/web/components/core/workflow/NodeInputSelect.tsx b/packages/web/components/core/workflow/NodeInputSelect.tsx
index 223556d62..044754a67 100644
--- a/packages/web/components/core/workflow/NodeInputSelect.tsx
+++ b/packages/web/components/core/workflow/NodeInputSelect.tsx
@@ -36,11 +36,6 @@ const NodeInputSelect = ({
icon: FlowNodeInputMap[FlowNodeInputTypeEnum.input].icon,
title: t('common:core.workflow.inputType.Manual input')
},
- {
- type: FlowNodeInputTypeEnum.textInput,
- icon: FlowNodeInputMap[FlowNodeInputTypeEnum.input].icon,
- title: t('common:core.workflow.inputType.Manual input')
- },
{
type: FlowNodeInputTypeEnum.numberInput,
icon: FlowNodeInputMap[FlowNodeInputTypeEnum.numberInput].icon,
diff --git a/projects/app/src/components/core/app/VariableEdit.tsx b/projects/app/src/components/core/app/VariableEdit.tsx
index c3c8068b5..13d6e0661 100644
--- a/projects/app/src/components/core/app/VariableEdit.tsx
+++ b/projects/app/src/components/core/app/VariableEdit.tsx
@@ -36,7 +36,7 @@ export const defaultVariable: VariableItemType = {
id: nanoid(),
key: '',
label: '',
- type: VariableInputEnum.textInput,
+ type: VariableInputEnum.input,
description: '',
required: true,
valueType: WorkflowIOValueTypeEnum.string
@@ -73,10 +73,7 @@ const VariableEdit = ({
const inputTypeList = useMemo(
() =>
Object.values(variableMap)
- .filter(
- (item) =>
- item.value !== VariableInputEnum.input && item.value !== VariableInputEnum.textarea
- )
+ .filter((item) => item.value !== VariableInputEnum.textarea)
.map((item) => ({
icon: item.icon,
label: t(item.label as any),
diff --git a/projects/app/src/components/core/chat/ChatContainer/ChatBox/components/VariableInput.tsx b/projects/app/src/components/core/chat/ChatContainer/ChatBox/components/VariableInput.tsx
index 764861b42..2d6cf5b2c 100644
--- a/projects/app/src/components/core/chat/ChatContainer/ChatBox/components/VariableInput.tsx
+++ b/projects/app/src/components/core/chat/ChatContainer/ChatBox/components/VariableInput.tsx
@@ -60,12 +60,13 @@ export const VariableInputItem = ({
{item.description && }
{item.type === VariableInputEnum.input && (
- setValue(item.key, e)}
bg={'myGray.50'}
- {...register(item.key, {
- required: item.required
- })}
+ minH={40}
+ maxH={150}
+ showOpenModal={false}
/>
)}
{item.type === VariableInputEnum.textarea && (
@@ -78,16 +79,7 @@ export const VariableInputItem = ({
maxLength={item.maxLength || 4000}
/>
)}
- {item.type === VariableInputEnum.textInput && (
- setValue(item.key, e)}
- bg={'myGray.50'}
- minH={50}
- maxH={150}
- showOpenModal={false}
- />
- )}
+
{item.type === VariableInputEnum.select && (
}
{input.type === FlowNodeInputTypeEnum.input && (
- setValue(input.label, e)}
+ minH={40}
+ maxH={100}
+ showOpenModal={false}
/>
)}
{input.type === FlowNodeInputTypeEnum.textarea && (
@@ -241,15 +240,6 @@ const RenderUserFormInteractive = React.memo(function RenderFormInput({
maxLength={input.maxLength || 4000}
/>
)}
- {input.type === FlowNodeInputTypeEnum.textInput && (
- setValue(input.label, e)}
- minH={40}
- maxH={100}
- showOpenModal={false}
- />
- )}
{input.type === FlowNodeInputTypeEnum.numberInput && (
{
- const list = [FlowNodeInputTypeEnum.textInput];
+ const list = [FlowNodeInputTypeEnum.input];
return list.includes(inputType as FlowNodeInputTypeEnum);
}, [inputType]);
@@ -148,7 +148,7 @@ const InputTypeConfig = ({
const showDefaultValue = useMemo(() => {
const list = [
- FlowNodeInputTypeEnum.textInput,
+ FlowNodeInputTypeEnum.input,
FlowNodeInputTypeEnum.JSONEditor,
FlowNodeInputTypeEnum.numberInput,
FlowNodeInputTypeEnum.switch,
@@ -323,7 +323,7 @@ const InputTypeConfig = ({
)}
- {inputType === FlowNodeInputTypeEnum.textInput && (
+ {inputType === FlowNodeInputTypeEnum.input && (
{
diff --git a/projects/app/src/pages/app/detail/components/WorkflowComponents/Flow/nodes/render/RenderInput/index.tsx b/projects/app/src/pages/app/detail/components/WorkflowComponents/Flow/nodes/render/RenderInput/index.tsx
index ddaae6898..e6337c74b 100644
--- a/projects/app/src/pages/app/detail/components/WorkflowComponents/Flow/nodes/render/RenderInput/index.tsx
+++ b/projects/app/src/pages/app/detail/components/WorkflowComponents/Flow/nodes/render/RenderInput/index.tsx
@@ -28,10 +28,6 @@ const RenderList: {
types: [FlowNodeInputTypeEnum.switch],
Component: dynamic(() => import('./templates/Switch'))
},
- {
- types: [FlowNodeInputTypeEnum.textInput],
- Component: dynamic(() => import('./templates/TextInput'))
- },
{
types: [FlowNodeInputTypeEnum.selectApp],
Component: dynamic(() => import('./templates/SelectApp'))
diff --git a/projects/app/src/pages/app/detail/components/WorkflowComponents/Flow/nodes/render/RenderInput/templates/TextInput.tsx b/projects/app/src/pages/app/detail/components/WorkflowComponents/Flow/nodes/render/RenderInput/templates/TextInput.tsx
index 3ae369800..66a90a554 100644
--- a/projects/app/src/pages/app/detail/components/WorkflowComponents/Flow/nodes/render/RenderInput/templates/TextInput.tsx
+++ b/projects/app/src/pages/app/detail/components/WorkflowComponents/Flow/nodes/render/RenderInput/templates/TextInput.tsx
@@ -10,9 +10,7 @@ import { getEditorVariables } from '../../../../../utils';
const TextInputRender = ({ inputs = [], item, nodeId }: RenderInputProps) => {
const { t } = useTranslation();
- const nodeList = useContextSelector(WorkflowContext, (v) => v.nodeList);
- const edges = useContextSelector(WorkflowContext, (v) => v.edges);
- const onChangeNode = useContextSelector(WorkflowContext, (v) => v.onChangeNode);
+ const { nodeList, edges, onChangeNode } = useContextSelector(WorkflowContext, (v) => v);
const { appDetail } = useContextSelector(AppContext, (v) => v);
@@ -51,7 +49,7 @@ const TextInputRender = ({ inputs = [], item, nodeId }: RenderInputProps) => {
maxLength={item.maxLength}
minH={40}
maxH={120}
- placeholder={t((item.placeholder as any) || '')}
+ placeholder={t(item.placeholder as any)}
value={item.value}
onChange={onChange}
isFlow={true}