System plugin adapt reference type in plugin input (#2965)

* perf: plugin input support reference

* perf: system plugin adapt plugin input reference
This commit is contained in:
Archer
2024-10-22 14:51:15 +08:00
committed by GitHub
parent 618729a254
commit 87b4061302
16 changed files with 145 additions and 235 deletions

View File

@@ -20,15 +20,13 @@
"flowNodeType": "pluginInput", "flowNodeType": "pluginInput",
"showStatus": false, "showStatus": false,
"position": { "position": {
"x": 335.8310044079668, "x": 334.24111198705634,
"y": -260.8285440670886 "y": -260.8285440670886
}, },
"version": "481", "version": "481",
"inputs": [ "inputs": [
{ {
"renderTypeList": [ "renderTypeList": ["select", "reference"],
"select"
],
"selectedTypeIndex": 0, "selectedTypeIndex": 0,
"valueType": "string", "valueType": "string",
"canEdit": true, "canEdit": true,
@@ -49,9 +47,7 @@
"required": true "required": true
}, },
{ {
"renderTypeList": [ "renderTypeList": ["input", "reference"],
"input"
],
"selectedTypeIndex": 0, "selectedTypeIndex": 0,
"valueType": "string", "valueType": "string",
"canEdit": true, "canEdit": true,
@@ -68,11 +64,9 @@
] ]
}, },
{ {
"renderTypeList": [ "renderTypeList": ["numberInput", "reference"],
"input"
],
"selectedTypeIndex": 0, "selectedTypeIndex": 0,
"valueType": "string", "valueType": "number",
"canEdit": true, "canEdit": true,
"key": "port", "key": "port",
"label": "port", "label": "port",
@@ -87,9 +81,7 @@
] ]
}, },
{ {
"renderTypeList": [ "renderTypeList": ["input", "reference"],
"input"
],
"selectedTypeIndex": 0, "selectedTypeIndex": 0,
"valueType": "string", "valueType": "string",
"canEdit": true, "canEdit": true,
@@ -106,9 +98,7 @@
] ]
}, },
{ {
"renderTypeList": [ "renderTypeList": ["input", "reference"],
"input"
],
"selectedTypeIndex": 0, "selectedTypeIndex": 0,
"valueType": "string", "valueType": "string",
"canEdit": true, "canEdit": true,
@@ -125,9 +115,7 @@
"required": true "required": true
}, },
{ {
"renderTypeList": [ "renderTypeList": ["input", "reference"],
"input"
],
"selectedTypeIndex": 0, "selectedTypeIndex": 0,
"valueType": "string", "valueType": "string",
"canEdit": true, "canEdit": true,
@@ -144,9 +132,7 @@
"required": true "required": true
}, },
{ {
"renderTypeList": [ "renderTypeList": ["input", "reference"],
"reference"
],
"selectedTypeIndex": 0, "selectedTypeIndex": 0,
"valueType": "string", "valueType": "string",
"canEdit": true, "canEdit": true,
@@ -181,7 +167,7 @@
}, },
{ {
"id": "port", "id": "port",
"valueType": "string", "valueType": "number",
"key": "port", "key": "port",
"label": "port", "label": "port",
"type": "hidden" "type": "hidden"
@@ -230,19 +216,14 @@
"version": "481", "version": "481",
"inputs": [ "inputs": [
{ {
"renderTypeList": [ "renderTypeList": ["reference"],
"reference"
],
"valueType": "string", "valueType": "string",
"canEdit": true, "canEdit": true,
"key": "result", "key": "result",
"label": "result", "label": "result",
"isToolOutput": true, "isToolOutput": true,
"description": "数据库连接结果", "description": "数据库连接结果",
"value": [ "value": ["zBeXy7YZEiXe", "httpRawResponse"]
"zBeXy7YZEiXe",
"httpRawResponse"
]
} }
], ],
"outputs": [] "outputs": []
@@ -276,9 +257,7 @@
"inputs": [ "inputs": [
{ {
"key": "system_addInputParam", "key": "system_addInputParam",
"renderTypeList": [ "renderTypeList": ["addInputParam"],
"addInputParam"
],
"valueType": "dynamic", "valueType": "dynamic",
"label": "", "label": "",
"required": false, "required": false,
@@ -310,9 +289,7 @@
}, },
{ {
"key": "system_httpMethod", "key": "system_httpMethod",
"renderTypeList": [ "renderTypeList": ["custom"],
"custom"
],
"valueType": "string", "valueType": "string",
"label": "", "label": "",
"value": "POST", "value": "POST",
@@ -324,9 +301,7 @@
}, },
{ {
"key": "system_httpTimeout", "key": "system_httpTimeout",
"renderTypeList": [ "renderTypeList": ["custom"],
"custom"
],
"valueType": "number", "valueType": "number",
"label": "", "label": "",
"value": 30, "value": 30,
@@ -340,9 +315,7 @@
}, },
{ {
"key": "system_httpReqUrl", "key": "system_httpReqUrl",
"renderTypeList": [ "renderTypeList": ["hidden"],
"hidden"
],
"valueType": "string", "valueType": "string",
"label": "", "label": "",
"description": "common:core.module.input.description.Http Request Url", "description": "common:core.module.input.description.Http Request Url",
@@ -355,9 +328,7 @@
}, },
{ {
"key": "system_httpHeader", "key": "system_httpHeader",
"renderTypeList": [ "renderTypeList": ["custom"],
"custom"
],
"valueType": "any", "valueType": "any",
"value": [], "value": [],
"label": "", "label": "",
@@ -370,9 +341,7 @@
}, },
{ {
"key": "system_httpParams", "key": "system_httpParams",
"renderTypeList": [ "renderTypeList": ["hidden"],
"hidden"
],
"valueType": "any", "valueType": "any",
"value": [], "value": [],
"label": "", "label": "",
@@ -384,9 +353,7 @@
}, },
{ {
"key": "system_httpJsonBody", "key": "system_httpJsonBody",
"renderTypeList": [ "renderTypeList": ["hidden"],
"hidden"
],
"valueType": "any", "valueType": "any",
"value": "{\r\n \"databaseType\":\"{{databaseType-H}}\",\r\n \"host\":\"{{host-H}}\",\r\n \"port\":\"{{port-H}}\",\r\n \"databaseName\":\"{{databaseName-H}}\",\r\n \"user\":\"{{databaseUser-H}}\",\r\n \"password\":\"{{databasePwd-H}}\",\r\n \"sql\":\"{{sql-H}}\"\r\n}", "value": "{\r\n \"databaseType\":\"{{databaseType-H}}\",\r\n \"host\":\"{{host-H}}\",\r\n \"port\":\"{{port-H}}\",\r\n \"databaseName\":\"{{databaseName-H}}\",\r\n \"user\":\"{{databaseUser-H}}\",\r\n \"password\":\"{{databasePwd-H}}\",\r\n \"sql\":\"{{sql-H}}\"\r\n}",
"label": "", "label": "",
@@ -398,9 +365,7 @@
}, },
{ {
"key": "system_httpFormBody", "key": "system_httpFormBody",
"renderTypeList": [ "renderTypeList": ["hidden"],
"hidden"
],
"valueType": "any", "valueType": "any",
"value": [], "value": [],
"label": "", "label": "",
@@ -412,9 +377,7 @@
}, },
{ {
"key": "system_httpContentType", "key": "system_httpContentType",
"renderTypeList": [ "renderTypeList": ["hidden"],
"hidden"
],
"valueType": "string", "valueType": "string",
"value": "json", "value": "json",
"label": "", "label": "",
@@ -425,9 +388,7 @@
"toolDescription": "" "toolDescription": ""
}, },
{ {
"renderTypeList": [ "renderTypeList": ["reference"],
"reference"
],
"valueType": "string", "valueType": "string",
"canEdit": true, "canEdit": true,
"key": "databaseType-H", "key": "databaseType-H",
@@ -454,15 +415,10 @@
"showDefaultValue": true "showDefaultValue": true
}, },
"required": true, "required": true,
"value": [ "value": ["pluginInput", "databaseType"]
"pluginInput",
"databaseType"
]
}, },
{ {
"renderTypeList": [ "renderTypeList": ["reference"],
"reference"
],
"valueType": "string", "valueType": "string",
"canEdit": true, "canEdit": true,
"key": "host-H", "key": "host-H",
@@ -489,16 +445,11 @@
"showDefaultValue": true "showDefaultValue": true
}, },
"required": true, "required": true,
"value": [ "value": ["pluginInput", "host"]
"pluginInput",
"host"
]
}, },
{ {
"renderTypeList": [ "renderTypeList": ["reference"],
"reference" "valueType": "number",
],
"valueType": "string",
"canEdit": true, "canEdit": true,
"key": "port-H", "key": "port-H",
"label": "port-H", "label": "port-H",
@@ -524,15 +475,10 @@
"showDefaultValue": true "showDefaultValue": true
}, },
"required": true, "required": true,
"value": [ "value": ["pluginInput", "port"]
"pluginInput",
"port"
]
}, },
{ {
"renderTypeList": [ "renderTypeList": ["reference"],
"reference"
],
"valueType": "string", "valueType": "string",
"canEdit": true, "canEdit": true,
"key": "databaseName-H", "key": "databaseName-H",
@@ -559,15 +505,10 @@
"showDefaultValue": true "showDefaultValue": true
}, },
"required": true, "required": true,
"value": [ "value": ["pluginInput", "dataBaseName"]
"pluginInput",
"dataBaseName"
]
}, },
{ {
"renderTypeList": [ "renderTypeList": ["reference"],
"reference"
],
"valueType": "string", "valueType": "string",
"canEdit": true, "canEdit": true,
"key": "databasePwd-H", "key": "databasePwd-H",
@@ -594,15 +535,10 @@
"showDefaultValue": true "showDefaultValue": true
}, },
"required": true, "required": true,
"value": [ "value": ["pluginInput", "dataBasePwd"]
"pluginInput",
"dataBasePwd"
]
}, },
{ {
"renderTypeList": [ "renderTypeList": ["reference"],
"reference"
],
"valueType": "string", "valueType": "string",
"canEdit": true, "canEdit": true,
"key": "databaseUser-H", "key": "databaseUser-H",
@@ -629,15 +565,10 @@
"showDefaultValue": true "showDefaultValue": true
}, },
"required": true, "required": true,
"value": [ "value": ["pluginInput", "user"]
"pluginInput",
"user"
]
}, },
{ {
"renderTypeList": [ "renderTypeList": ["reference"],
"reference"
],
"valueType": "string", "valueType": "string",
"canEdit": true, "canEdit": true,
"key": "sql-H", "key": "sql-H",
@@ -664,10 +595,7 @@
"showDefaultValue": true "showDefaultValue": true
}, },
"required": true, "required": true,
"value": [ "value": ["pluginInput", "sql"]
"pluginInput",
"sql"
]
} }
], ],
"outputs": [ "outputs": [

View File

@@ -1,6 +1,6 @@
{ {
"author": "", "author": "",
"version": "486", "version": "4812",
"name": "基础图表", "name": "基础图表",
"avatar": "core/workflow/template/baseChart", "avatar": "core/workflow/template/baseChart",
"intro": "根据数据生成图表可根据chartType生成柱状图折线图饼图", "intro": "根据数据生成图表可根据chartType生成柱状图折线图饼图",
@@ -8,7 +8,7 @@
"weight": 10, "weight": 10,
"isTool": true, "isTool": true,
"templateType": "search", "templateType": "tools",
"workflow": { "workflow": {
"nodes": [ "nodes": [
@@ -21,12 +21,12 @@
"showStatus": false, "showStatus": false,
"position": { "position": {
"x": 613.7921798611637, "x": 613.7921798611637,
"y": -124.66724109717275 "y": -123.07734867626235
}, },
"version": "481", "version": "481",
"inputs": [ "inputs": [
{ {
"renderTypeList": ["reference"], "renderTypeList": ["input", "reference"],
"selectedTypeIndex": 0, "selectedTypeIndex": 0,
"valueType": "string", "valueType": "string",
"canEdit": true, "canEdit": true,
@@ -44,13 +44,13 @@
"toolDescription": "BI图表的标题" "toolDescription": "BI图表的标题"
}, },
{ {
"renderTypeList": ["reference"], "renderTypeList": ["input", "reference"],
"selectedTypeIndex": 0, "selectedTypeIndex": 0,
"valueType": "string", "valueType": "string",
"canEdit": true, "canEdit": true,
"key": "xAxis", "key": "xAxis",
"label": "xAxis", "label": "xAxis",
"description": "x轴数据", "description": "x轴数据,例如:['A', 'B', 'C']",
"defaultValue": "", "defaultValue": "",
"required": true, "required": true,
"toolDescription": "x轴数据例如['A', 'B', 'C']", "toolDescription": "x轴数据例如['A', 'B', 'C']",
@@ -62,13 +62,13 @@
] ]
}, },
{ {
"renderTypeList": ["reference"], "renderTypeList": ["input", "reference"],
"selectedTypeIndex": 0, "selectedTypeIndex": 0,
"valueType": "string", "valueType": "string",
"canEdit": true, "canEdit": true,
"key": "yAxis", "key": "yAxis",
"label": "yAxis", "label": "yAxis",
"description": "y轴数据", "description": "y轴数据,例如:['1', '2', '3']",
"defaultValue": "", "defaultValue": "",
"list": [ "list": [
{ {
@@ -77,10 +77,10 @@
} }
], ],
"required": true, "required": true,
"toolDescription": "y轴数据例如['A', 'B', 'C']" "toolDescription": "y轴数据例如['1', '2', '3']"
}, },
{ {
"renderTypeList": ["select"], "renderTypeList": ["select", "reference"],
"selectedTypeIndex": 0, "selectedTypeIndex": 0,
"valueType": "string", "valueType": "string",
"canEdit": true, "canEdit": true,
@@ -103,7 +103,7 @@
"value": "饼图" "value": "饼图"
} }
], ],
"toolDescription": "图表类型,目前支持三种: 柱状图,折线图,饼图" "toolDescription": "图表类型柱状图,折线图,饼图"
} }
], ],
"outputs": [ "outputs": [
@@ -181,7 +181,7 @@
"valueType": "dynamic", "valueType": "dynamic",
"label": "", "label": "",
"required": false, "required": false,
"description": "接收前方节点的输出值作为变量,这些变量可以被 HTTP 请求参数使用。", "description": "common:core.module.input.description.HTTP Dynamic Input",
"customInputConfig": { "customInputConfig": {
"selectValueTypeList": [ "selectValueTypeList": [
"string", "string",
@@ -192,6 +192,7 @@
"arrayNumber", "arrayNumber",
"arrayBoolean", "arrayBoolean",
"arrayObject", "arrayObject",
"arrayAny",
"any", "any",
"chatHistory", "chatHistory",
"datasetQuote", "datasetQuote",
@@ -237,7 +238,7 @@
"renderTypeList": ["hidden"], "renderTypeList": ["hidden"],
"valueType": "string", "valueType": "string",
"label": "", "label": "",
"description": "新的 HTTP 请求地址。如果出现两个“请求地址”,可以删除该模块重新加入,会拉取最新的模块配置。", "description": "common:core.module.input.description.Http Request Url",
"placeholder": "https://api.ai.com/getInventory", "placeholder": "https://api.ai.com/getInventory",
"required": false, "required": false,
"valueDesc": "", "valueDesc": "",
@@ -251,7 +252,7 @@
"valueType": "any", "valueType": "any",
"value": [], "value": [],
"label": "", "label": "",
"description": "自定义请求头,请严格填入 JSON 字符串。\n1. 确保最后一个属性没有逗号\n2. 确保 key 包含双引号\n例如{\"Authorization\":\"Bearer xxx\"}", "description": "common:core.module.input.description.Http Request Header",
"placeholder": "common:core.module.input.description.Http Request Header", "placeholder": "common:core.module.input.description.Http Request Header",
"required": false, "required": false,
"valueDesc": "", "valueDesc": "",
@@ -322,6 +323,7 @@
"arrayNumber", "arrayNumber",
"arrayBoolean", "arrayBoolean",
"arrayObject", "arrayObject",
"arrayAny",
"any", "any",
"chatHistory", "chatHistory",
"datasetQuote", "datasetQuote",
@@ -351,6 +353,7 @@
"arrayNumber", "arrayNumber",
"arrayBoolean", "arrayBoolean",
"arrayObject", "arrayObject",
"arrayAny",
"any", "any",
"chatHistory", "chatHistory",
"datasetQuote", "datasetQuote",
@@ -380,6 +383,7 @@
"arrayNumber", "arrayNumber",
"arrayBoolean", "arrayBoolean",
"arrayObject", "arrayObject",
"arrayAny",
"any", "any",
"chatHistory", "chatHistory",
"datasetQuote", "datasetQuote",
@@ -409,6 +413,7 @@
"arrayNumber", "arrayNumber",
"arrayBoolean", "arrayBoolean",
"arrayObject", "arrayObject",
"arrayAny",
"any", "any",
"chatHistory", "chatHistory",
"datasetQuote", "datasetQuote",
@@ -424,6 +429,23 @@
} }
], ],
"outputs": [ "outputs": [
{
"id": "error",
"key": "error",
"label": "workflow:request_error",
"description": "HTTP请求错误信息成功时返回空",
"valueType": "object",
"type": "static"
},
{
"id": "httpRawResponse",
"key": "httpRawResponse",
"required": true,
"label": "workflow:raw_response",
"description": "HTTP请求的原始响应。只能接受字符串或JSON类型响应数据。",
"valueType": "any",
"type": "static"
},
{ {
"id": "system_addOutputParam", "id": "system_addOutputParam",
"key": "system_addOutputParam", "key": "system_addOutputParam",
@@ -453,25 +475,6 @@
"valueDesc": "", "valueDesc": "",
"description": "" "description": ""
}, },
{
"id": "error",
"key": "error",
"label": "请求错误",
"description": "HTTP请求错误信息成功时返回空",
"valueType": "object",
"type": "static",
"valueDesc": ""
},
{
"id": "httpRawResponse",
"key": "httpRawResponse",
"required": true,
"label": "原始响应",
"description": "HTTP请求的原始响应。只能接受字符串或JSON类型响应数据。",
"valueType": "any",
"type": "static",
"valueDesc": ""
},
{ {
"id": "bzaYjKyQFOw2", "id": "bzaYjKyQFOw2",
"valueType": "string", "valueType": "string",
@@ -495,6 +498,26 @@
"sourceHandle": "ws0DFKJnCPhk-source-right", "sourceHandle": "ws0DFKJnCPhk-source-right",
"targetHandle": "pluginOutput-target-left" "targetHandle": "pluginOutput-target-left"
} }
] ],
"chatConfig": {
"welcomeText": "",
"variables": [],
"questionGuide": false,
"ttsConfig": {
"type": "web"
},
"whisperConfig": {
"open": false,
"autoSend": false,
"autoTTSResponse": false
},
"chatInputGuide": {
"open": false,
"textList": [],
"customUrl": ""
},
"instruction": "数据源配置,支持主流数据库配置",
"_id": "670a23b31957c5b9899b4a4d"
}
} }
} }

View File

@@ -26,7 +26,7 @@
"version": "481", "version": "481",
"inputs": [ "inputs": [
{ {
"renderTypeList": ["reference"], "renderTypeList": ["input", "reference"],
"selectedTypeIndex": 0, "selectedTypeIndex": 0,
"valueType": "string", "valueType": "string",
"canEdit": true, "canEdit": true,

View File

@@ -26,7 +26,7 @@
"version": "481", "version": "481",
"inputs": [ "inputs": [
{ {
"renderTypeList": ["reference"], "renderTypeList": ["input", "reference"],
"selectedTypeIndex": 0, "selectedTypeIndex": 0,
"valueType": "string", "valueType": "string",
"canEdit": true, "canEdit": true,

View File

@@ -26,7 +26,7 @@
"version": "481", "version": "481",
"inputs": [ "inputs": [
{ {
"renderTypeList": ["reference"], "renderTypeList": ["input", "reference"],
"selectedTypeIndex": 0, "selectedTypeIndex": 0,
"valueType": "string", "valueType": "string",
"canEdit": true, "canEdit": true,

View File

@@ -26,7 +26,7 @@
"version": "481", "version": "481",
"inputs": [ "inputs": [
{ {
"renderTypeList": ["reference"], "renderTypeList": ["input", "reference"],
"selectedTypeIndex": 0, "selectedTypeIndex": 0,
"valueType": "string", "valueType": "string",
"canEdit": true, "canEdit": true,

View File

@@ -5,10 +5,10 @@
"avatar": "core/workflow/template/duckduckgo", "avatar": "core/workflow/template/duckduckgo",
"intro": "DuckDuckGo 服务,包含网络搜索、图片搜索、新闻搜索等。", "intro": "DuckDuckGo 服务,包含网络搜索、图片搜索、新闻搜索等。",
"showStatus": false, "showStatus": false,
"weight": 100, "weight": 11,
"isTool": true, "isTool": true,
"templateType": "tools", "templateType": "search",
"workflow": { "workflow": {
"nodes": [], "nodes": [],

View File

@@ -8,7 +8,7 @@
"weight": 10, "weight": 10,
"isTool": true, "isTool": true,
"templateType": "tools", "templateType": "search",
"workflow": { "workflow": {
"nodes": [ "nodes": [
@@ -26,7 +26,7 @@
"version": "481", "version": "481",
"inputs": [ "inputs": [
{ {
"renderTypeList": ["input"], "renderTypeList": ["input", "reference"],
"selectedTypeIndex": 0, "selectedTypeIndex": 0,
"valueType": "string", "valueType": "string",
"canEdit": true, "canEdit": true,
@@ -43,7 +43,7 @@
"required": true "required": true
}, },
{ {
"renderTypeList": ["input"], "renderTypeList": ["input", "reference"],
"selectedTypeIndex": 0, "selectedTypeIndex": 0,
"valueType": "string", "valueType": "string",
"canEdit": true, "canEdit": true,
@@ -51,10 +51,11 @@
"label": "key", "label": "key",
"description": "Google搜索key", "description": "Google搜索key",
"defaultValue": "", "defaultValue": "",
"required": true "required": true,
"list": []
}, },
{ {
"renderTypeList": ["reference"], "renderTypeList": ["input", "reference"],
"selectedTypeIndex": 0, "selectedTypeIndex": 0,
"valueType": "string", "valueType": "string",
"canEdit": true, "canEdit": true,

View File

@@ -8,7 +8,7 @@
"weight": 10, "weight": 10,
"isTool": true, "isTool": true,
"templateType": "tools", "templateType": "search",
"workflow": { "workflow": {
"nodes": [ "nodes": [
@@ -26,7 +26,7 @@
"version": "481", "version": "481",
"inputs": [ "inputs": [
{ {
"renderTypeList": ["reference"], "renderTypeList": ["input", "reference"],
"selectedTypeIndex": 0, "selectedTypeIndex": 0,
"valueType": "string", "valueType": "string",
"canEdit": true, "canEdit": true,
@@ -34,7 +34,8 @@
"label": "query", "label": "query",
"description": "检索词", "description": "检索词",
"required": true, "required": true,
"toolDescription": "检索词" "toolDescription": "检索词",
"list": []
} }
], ],
"outputs": [ "outputs": [

View File

@@ -43,7 +43,6 @@ export default function Editor({
onBlur, onBlur,
value, value,
placeholder = '', placeholder = '',
isFlow,
bg = 'white' bg = 'white'
}: { }: {
minH?: number; minH?: number;
@@ -57,7 +56,6 @@ export default function Editor({
onBlur?: (editor: LexicalEditor) => void; onBlur?: (editor: LexicalEditor) => void;
value?: string; value?: string;
placeholder?: string; placeholder?: string;
isFlow?: boolean;
bg?: string; bg?: string;
}) { }) {
const [key, setKey] = useState(getNanoid(6)); const [key, setKey] = useState(getNanoid(6));
@@ -92,7 +90,7 @@ export default function Editor({
<PlainTextPlugin <PlainTextPlugin
contentEditable={ contentEditable={
<ContentEditable <ContentEditable
className={isFlow ? styles.contentEditable_isFlow : styles.contentEditable} className={styles.contentEditable}
style={{ style={{
minHeight: `${minH}px`, minHeight: `${minH}px`,
maxHeight: `${maxH}px` maxHeight: `${maxH}px`

View File

@@ -11,18 +11,6 @@
overflow-y: auto; overflow-y: auto;
} }
.contentEditable_isFlow {
position: relative;
height: 100%;
width: 100%;
border: 1px solid var(--chakra-colors-myGray-200);
border-radius: var(--chakra-radii-sm);
padding: 6px 8px;
// background: #fff;
font-size: var(--chakra-fontSizes-sm);
overflow-y: auto;
}
.contentEditable:focus { .contentEditable:focus {
outline: none; outline: none;
border: 1px solid; border: 1px solid;
@@ -30,13 +18,6 @@
box-shadow: 0px 0px 0px 2.4px rgba(51, 112, 255, 0.15); box-shadow: 0px 0px 0px 2.4px rgba(51, 112, 255, 0.15);
} }
.contentEditable_isFlow:focus {
outline: none;
border: 1px solid;
border-color: var(--chakra-colors-primary-600);
box-shadow: 0px 0px 0px 2.4px rgba(51, 112, 255, 0.15);
}
.variable { .variable {
color: var(--chakra-colors-primary-600); color: var(--chakra-colors-primary-600);
padding: 0 2px; padding: 0 2px;

View File

@@ -20,7 +20,6 @@ const PromptEditor = ({
maxLength, maxLength,
placeholder, placeholder,
title, title,
isFlow,
bg = 'white' bg = 'white'
}: { }: {
showOpenModal?: boolean; showOpenModal?: boolean;
@@ -34,7 +33,6 @@ const PromptEditor = ({
maxLength?: number; maxLength?: number;
placeholder?: string; placeholder?: string;
title?: string; title?: string;
isFlow?: boolean;
bg?: string; bg?: string;
}) => { }) => {
const { isOpen, onOpen, onClose } = useDisclosure(); const { isOpen, onOpen, onClose } = useDisclosure();
@@ -69,7 +67,6 @@ const PromptEditor = ({
onChange={onChangeInput} onChange={onChangeInput}
onBlur={onBlurInput} onBlur={onBlurInput}
placeholder={placeholder} placeholder={placeholder}
isFlow={isFlow}
bg={bg} bg={bg}
/> />
<MyModal isOpen={isOpen} onClose={onClose} iconSrc="modal/edit" title={title} w={'full'}> <MyModal isOpen={isOpen} onClose={onClose} iconSrc="modal/edit" title={title} w={'full'}>

View File

@@ -49,37 +49,37 @@ const FieldEditModal = ({
{ {
icon: 'core/workflow/inputType/reference', icon: 'core/workflow/inputType/reference',
label: t('common:core.workflow.inputType.Reference'), label: t('common:core.workflow.inputType.Reference'),
value: FlowNodeInputTypeEnum.reference, value: [FlowNodeInputTypeEnum.reference],
defaultValueType: WorkflowIOValueTypeEnum.string defaultValueType: WorkflowIOValueTypeEnum.string
}, },
{ {
icon: 'core/workflow/inputType/input', icon: 'core/workflow/inputType/input',
label: t('common:core.workflow.inputType.textInput'), label: t('common:core.workflow.inputType.textInput'),
value: FlowNodeInputTypeEnum.input, value: [FlowNodeInputTypeEnum.input, FlowNodeInputTypeEnum.reference],
defaultValueType: WorkflowIOValueTypeEnum.string defaultValueType: WorkflowIOValueTypeEnum.string
}, },
{ {
icon: 'core/workflow/inputType/jsonEditor', icon: 'core/workflow/inputType/jsonEditor',
label: t('common:core.workflow.inputType.JSON Editor'), label: t('common:core.workflow.inputType.JSON Editor'),
value: FlowNodeInputTypeEnum.JSONEditor, value: [FlowNodeInputTypeEnum.JSONEditor, FlowNodeInputTypeEnum.reference],
defaultValueType: WorkflowIOValueTypeEnum.string defaultValueType: WorkflowIOValueTypeEnum.string
}, },
{ {
icon: 'core/workflow/inputType/numberInput', icon: 'core/workflow/inputType/numberInput',
label: t('common:core.workflow.inputType.number input'), label: t('common:core.workflow.inputType.number input'),
value: FlowNodeInputTypeEnum.numberInput, value: [FlowNodeInputTypeEnum.numberInput, FlowNodeInputTypeEnum.reference],
defaultValueType: WorkflowIOValueTypeEnum.number defaultValueType: WorkflowIOValueTypeEnum.number
}, },
{ {
icon: 'core/workflow/inputType/option', icon: 'core/workflow/inputType/option',
label: t('common:core.workflow.inputType.select'), label: t('common:core.workflow.inputType.select'),
value: FlowNodeInputTypeEnum.select, value: [FlowNodeInputTypeEnum.select, FlowNodeInputTypeEnum.reference],
defaultValueType: WorkflowIOValueTypeEnum.string defaultValueType: WorkflowIOValueTypeEnum.string
}, },
{ {
icon: 'core/workflow/inputType/switch', icon: 'core/workflow/inputType/switch',
label: t('common:core.workflow.inputType.switch'), label: t('common:core.workflow.inputType.switch'),
value: FlowNodeInputTypeEnum.switch, value: [FlowNodeInputTypeEnum.switch, FlowNodeInputTypeEnum.reference],
defaultValueType: WorkflowIOValueTypeEnum.boolean defaultValueType: WorkflowIOValueTypeEnum.boolean
} }
], ],
@@ -87,13 +87,13 @@ const FieldEditModal = ({
{ {
icon: 'core/workflow/inputType/selectLLM', icon: 'core/workflow/inputType/selectLLM',
label: t('common:core.workflow.inputType.selectLLMModel'), label: t('common:core.workflow.inputType.selectLLMModel'),
value: FlowNodeInputTypeEnum.selectLLMModel, value: [FlowNodeInputTypeEnum.selectLLMModel],
defaultValueType: WorkflowIOValueTypeEnum.string defaultValueType: WorkflowIOValueTypeEnum.string
}, },
{ {
icon: 'core/workflow/inputType/selectDataset', icon: 'core/workflow/inputType/selectDataset',
label: t('common:core.workflow.inputType.selectDataset'), label: t('common:core.workflow.inputType.selectDataset'),
value: FlowNodeInputTypeEnum.selectDataset, value: [FlowNodeInputTypeEnum.selectDataset],
defaultValueType: WorkflowIOValueTypeEnum.selectDataset defaultValueType: WorkflowIOValueTypeEnum.selectDataset
}, },
...(hasDynamicInput ...(hasDynamicInput
@@ -102,7 +102,7 @@ const FieldEditModal = ({
{ {
icon: 'core/workflow/inputType/dynamic', icon: 'core/workflow/inputType/dynamic',
label: t('common:core.workflow.inputType.dynamicTargetInput'), label: t('common:core.workflow.inputType.dynamicTargetInput'),
value: FlowNodeInputTypeEnum.addInputParam, value: [FlowNodeInputTypeEnum.addInputParam],
defaultValueType: WorkflowIOValueTypeEnum.dynamic defaultValueType: WorkflowIOValueTypeEnum.dynamic
} }
]) ])
@@ -111,7 +111,7 @@ const FieldEditModal = ({
{ {
icon: 'core/workflow/inputType/customVariable', icon: 'core/workflow/inputType/customVariable',
label: t('common:core.workflow.inputType.custom'), label: t('common:core.workflow.inputType.custom'),
value: FlowNodeInputTypeEnum.customVariable, value: [FlowNodeInputTypeEnum.customVariable],
defaultValueType: WorkflowIOValueTypeEnum.string, defaultValueType: WorkflowIOValueTypeEnum.string,
description: t('app:variable.select type_desc') description: t('app:variable.select type_desc')
} }
@@ -119,7 +119,7 @@ const FieldEditModal = ({
] as { ] as {
icon: string; icon: string;
label: string; label: string;
value: FlowNodeInputTypeEnum; value: FlowNodeInputTypeEnum[];
defaultValueType: WorkflowIOValueTypeEnum; defaultValueType: WorkflowIOValueTypeEnum;
description?: string; description?: string;
}[][], }[][],
@@ -138,27 +138,18 @@ const FieldEditModal = ({
const [isToolInput, { toggle: setIsToolInput }] = useBoolean(!!getValues('toolDescription')); const [isToolInput, { toggle: setIsToolInput }] = useBoolean(!!getValues('toolDescription'));
const isRefrence = renderTypeList.includes(FlowNodeInputTypeEnum.reference);
const setIsRefrence = () => {
if (isRefrence) {
setValue(
'renderTypeList',
renderTypeList.filter((item) => item !== FlowNodeInputTypeEnum.reference)
);
} else {
setValue('renderTypeList', [...getValues('renderTypeList'), FlowNodeInputTypeEnum.reference]);
}
};
const maxLength = watch('maxLength'); const maxLength = watch('maxLength');
const max = watch('max'); const max = watch('max');
const min = watch('min'); const min = watch('min');
const selectValueTypeList = watch('customInputConfig.selectValueTypeList'); const selectValueTypeList = watch('customInputConfig.selectValueTypeList');
const defaultInputValue = watch('defaultValue'); const defaultInputValue = watch('defaultValue');
const defaultValueType = const defaultValueType = useMemo(
inputTypeList.flat().find((item) => item.value === inputType)?.defaultValueType || () =>
WorkflowIOValueTypeEnum.string; inputTypeList.flat().find((item) => item.value[0] === inputType)?.defaultValueType ||
WorkflowIOValueTypeEnum.string,
[inputType, inputTypeList]
);
const onSubmitSuccess = useCallback( const onSubmitSuccess = useCallback(
(data: FlowNodeInputItemType, action: 'confirm' | 'continue') => { (data: FlowNodeInputItemType, action: 'confirm' | 'continue') => {
@@ -171,6 +162,7 @@ const FieldEditModal = ({
}); });
} }
// Auto set valueType
if ( if (
data.renderTypeList[0] !== FlowNodeInputTypeEnum.reference && data.renderTypeList[0] !== FlowNodeInputTypeEnum.reference &&
data.renderTypeList[0] !== FlowNodeInputTypeEnum.customVariable data.renderTypeList[0] !== FlowNodeInputTypeEnum.customVariable
@@ -178,6 +170,7 @@ const FieldEditModal = ({
data.valueType = defaultValueType; data.valueType = defaultValueType;
} }
// Remove required
if ( if (
data.renderTypeList[0] === FlowNodeInputTypeEnum.addInputParam || data.renderTypeList[0] === FlowNodeInputTypeEnum.addInputParam ||
data.renderTypeList[0] === FlowNodeInputTypeEnum.customVariable data.renderTypeList[0] === FlowNodeInputTypeEnum.customVariable
@@ -273,7 +266,7 @@ const FieldEditModal = ({
mt={5} mt={5}
> >
{list.map((item) => { {list.map((item) => {
const isSelected = inputType === item.value; const isSelected = inputType === item.value[0];
return ( return (
<Box <Box
display={'flex'} display={'flex'}
@@ -299,7 +292,7 @@ const FieldEditModal = ({
boxShadow: '0px 0px 0px 2.4px rgba(51, 112, 255, 0.15)' boxShadow: '0px 0px 0px 2.4px rgba(51, 112, 255, 0.15)'
}} }}
onClick={() => { onClick={() => {
setValue('renderTypeList.0', item.value); setValue('renderTypeList', item.value);
}} }}
> >
<MyIcon <MyIcon
@@ -335,8 +328,6 @@ const FieldEditModal = ({
defaultValue={defaultInputValue} defaultValue={defaultInputValue}
isToolInput={isToolInput} isToolInput={isToolInput}
setIsToolInput={setIsToolInput} setIsToolInput={setIsToolInput}
isRefrence={isRefrence}
setIsRefrence={setIsRefrence}
valueType={valueType} valueType={valueType}
defaultValueType={defaultValueType} defaultValueType={defaultValueType}
onSubmitSuccess={onSubmitSuccess} onSubmitSuccess={onSubmitSuccess}

View File

@@ -51,8 +51,6 @@ const InputTypeConfig = ({
defaultValue, defaultValue,
isToolInput, isToolInput,
setIsToolInput, setIsToolInput,
isRefrence,
setIsRefrence,
valueType, valueType,
defaultValueType, defaultValueType,
onSubmitSuccess, onSubmitSuccess,
@@ -75,8 +73,6 @@ const InputTypeConfig = ({
// Plugin-specific fields // Plugin-specific fields
isToolInput?: boolean; isToolInput?: boolean;
setIsToolInput?: () => void; setIsToolInput?: () => void;
isRefrence?: boolean;
setIsRefrence?: () => void;
valueType?: WorkflowIOValueTypeEnum; valueType?: WorkflowIOValueTypeEnum;
defaultValueType?: WorkflowIOValueTypeEnum; defaultValueType?: WorkflowIOValueTypeEnum;
@@ -158,6 +154,18 @@ const InputTypeConfig = ({
return list.includes(inputType as FlowNodeInputTypeEnum); return list.includes(inputType as FlowNodeInputTypeEnum);
}, [inputType]); }, [inputType]);
const showIsToolInput = useMemo(() => {
const list = [
FlowNodeInputTypeEnum.reference,
FlowNodeInputTypeEnum.JSONEditor,
FlowNodeInputTypeEnum.input,
FlowNodeInputTypeEnum.numberInput,
FlowNodeInputTypeEnum.switch,
FlowNodeInputTypeEnum.select
];
return type === 'plugin' && list.includes(inputType as FlowNodeInputTypeEnum);
}, [inputType, type]);
return ( return (
<Stack flex={1} borderLeft={'1px solid #F0F1F6'} justifyContent={'space-between'}> <Stack flex={1} borderLeft={'1px solid #F0F1F6'} justifyContent={'space-between'}>
<Flex flexDirection={'column'} p={8} pb={2} gap={4} flex={'1 0 0'} overflow={'auto'}> <Flex flexDirection={'column'} p={8} pb={2} gap={4} flex={'1 0 0'} overflow={'auto'}>
@@ -218,24 +226,8 @@ const InputTypeConfig = ({
<Switch {...register('required')} /> <Switch {...register('required')} />
</Flex> </Flex>
)} )}
{inputType !== FlowNodeInputTypeEnum.reference && setIsRefrence && (
<>
<Flex alignItems={'center'} minH={'40px'}>
<FormLabel flex={'0 0 132px'} fontWeight={'medium'}>
{t('workflow:field_used_as_reference')}
</FormLabel>
<Switch
isChecked={isRefrence}
onChange={(e) => {
setIsRefrence();
}}
/>
</Flex>
</>
)}
{/* reference */} {/* reference */}
{(inputType === FlowNodeInputTypeEnum.reference || isRefrence) && ( {showIsToolInput && (
<> <>
<Flex alignItems={'center'} minH={'40px'}> <Flex alignItems={'center'} minH={'40px'}>
<FormLabel flex={'0 0 132px'} fontWeight={'medium'}> <FormLabel flex={'0 0 132px'} fontWeight={'medium'}>

View File

@@ -47,12 +47,11 @@ const TextInputRender = ({ inputs = [], item, nodeId }: RenderInputProps) => {
variables={variables} variables={variables}
title={t(item.label as any)} title={t(item.label as any)}
maxLength={item.maxLength} maxLength={item.maxLength}
minH={40} minH={30}
maxH={120} maxH={120}
placeholder={t(item.placeholder as any)} placeholder={t(item.placeholder as any)}
value={item.value} value={item.value}
onChange={onChange} onChange={onChange}
isFlow={true}
/> />
); );
}, [item.label, item.maxLength, item.placeholder, item.value, onChange, t, variables]); }, [item.label, item.maxLength, item.placeholder, item.value, onChange, t, variables]);

View File

@@ -54,7 +54,6 @@ const TextareaRender = ({ inputs = [], item, nodeId }: RenderInputProps) => {
placeholder={t((item.placeholder as any) || '')} placeholder={t((item.placeholder as any) || '')}
value={item.value} value={item.value}
onChange={onChange} onChange={onChange}
isFlow={true}
/> />
); );
}, [item.label, item.maxLength, item.placeholder, item.value, onChange, t, variables]); }, [item.label, item.maxLength, item.placeholder, item.value, onChange, t, variables]);