From 09bdc639778b4c4a8712b76792dcbd1edaf1af6e Mon Sep 17 00:00:00 2001 From: shilin66 <15151873958@163.com> Date: Mon, 13 Jan 2025 15:36:25 +0800 Subject: [PATCH] =?UTF-8?q?feat(core):=20=E6=B7=BB=E5=8A=A0=20sleep=20?= =?UTF-8?q?=E6=8F=92=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/plugins/register.ts | 3 +- packages/plugins/src/sleep/index.ts | 17 + packages/plugins/src/sleep/template.json | 369 ++++++++++++++++++ .../web/components/common/Icon/constants.ts | 1 + .../icons/core/workflow/template/sleep.svg | 7 + 5 files changed, 396 insertions(+), 1 deletion(-) create mode 100644 packages/plugins/src/sleep/index.ts create mode 100644 packages/plugins/src/sleep/template.json create mode 100644 packages/web/components/common/Icon/icons/core/workflow/template/sleep.svg diff --git a/packages/plugins/register.ts b/packages/plugins/register.ts index 9989fbc78761..832d39628be4 100644 --- a/packages/plugins/register.ts +++ b/packages/plugins/register.ts @@ -28,7 +28,8 @@ const packagePluginList = [ 'databaseConnection', 'Doc2X', 'Doc2X/PDF2text', - 'searchXNG' + 'searchXNG', + 'sleep' ]; export const list = [...staticPluginList, ...packagePluginList]; diff --git a/packages/plugins/src/sleep/index.ts b/packages/plugins/src/sleep/index.ts new file mode 100644 index 000000000000..8f5e9de7eb13 --- /dev/null +++ b/packages/plugins/src/sleep/index.ts @@ -0,0 +1,17 @@ +type Props = { + ms: number; +}; +type Response = Promise<{ + result: any; +}>; + +const main = async ({ ms }: Props): Response => { + await new Promise((resolve) => { + setTimeout(resolve, ms); + }); + return { + result: ms + }; +}; + +export default main; diff --git a/packages/plugins/src/sleep/template.json b/packages/plugins/src/sleep/template.json new file mode 100644 index 000000000000..45579f06c08e --- /dev/null +++ b/packages/plugins/src/sleep/template.json @@ -0,0 +1,369 @@ +{ + "author": "collin", + "version": "4817", + "name": "流程暂停", + "avatar": "core/workflow/template/sleep", + "intro": "让工作流暂停指定时间后运行", + "showStatus": true, + "weight": 10, + + "isTool": true, + "templateType": "tools", + + "workflow": { + "nodes": [ + { + "nodeId": "pluginInput", + "name": "workflow:template.plugin_start", + "intro": "workflow:intro_plugin_input", + "avatar": "core/workflow/template/workflowStart", + "flowNodeType": "pluginInput", + "showStatus": false, + "position": { + "x": 616.4226348688949, + "y": -165.05298493910115 + }, + "version": "481", + "inputs": [ + { + "renderTypeList": [ + "numberInput", + "reference" + ], + "selectedTypeIndex": 0, + "valueType": "number", + "canEdit": true, + "key": "ms", + "label": "ms", + "description": "需要暂停的时间,毫秒", + "defaultValue": 1000, + "list": [ + { + "label": "", + "value": "" + } + ], + "maxFiles": 5, + "canSelectFile": true, + "canSelectImg": true, + "required": true, + "toolDescription": "需要暂停的时间,毫秒", + "max": 999999999999, + "min": 1 + } + ], + "outputs": [ + { + "id": "ms", + "valueType": "number", + "key": "ms", + "label": "ms", + "type": "hidden" + } + ] + }, + { + "nodeId": "pluginOutput", + "name": "common:core.module.template.self_output", + "intro": "workflow:intro_custom_plugin_output", + "avatar": "core/workflow/template/pluginOutput", + "flowNodeType": "pluginOutput", + "showStatus": false, + "position": { + "x": 1925.5772573010433, + "y": -131.55298493910115 + }, + "version": "481", + "inputs": [ + { + "renderTypeList": [ + "reference" + ], + "valueType": "any", + "canEdit": true, + "key": "result", + "label": "result", + "isToolOutput": true, + "description": "", + "required": true, + "value": [ + "zCJC6zw7c14i", + "httpRawResponse" + ] + } + ], + "outputs": [] + }, + { + "nodeId": "pluginConfig", + "name": "common:core.module.template.system_config", + "intro": "", + "avatar": "core/workflow/template/systemConfig", + "flowNodeType": "pluginConfig", + "position": { + "x": 184.66337662472682, + "y": -216.05298493910115 + }, + "version": "4811", + "inputs": [], + "outputs": [] + }, + { + "nodeId": "zCJC6zw7c14i", + "name": "HTTP 请求", + "intro": "可以发出一个 HTTP 请求,实现更为复杂的操作(联网搜索、数据库查询等)", + "avatar": "core/workflow/template/httpRequest", + "flowNodeType": "httpRequest468", + "showStatus": true, + "position": { + "x": 1152.535395637613, + "y": -433.21496011686054 + }, + "version": "481", + "inputs": [ + { + "key": "system_addInputParam", + "renderTypeList": [ + "addInputParam" + ], + "valueType": "dynamic", + "label": "", + "required": false, + "description": "common:core.module.input.description.HTTP Dynamic Input", + "customInputConfig": { + "selectValueTypeList": [ + "string", + "number", + "boolean", + "object", + "arrayString", + "arrayNumber", + "arrayBoolean", + "arrayObject", + "arrayAny", + "any", + "chatHistory", + "datasetQuote", + "dynamic", + "selectApp", + "selectDataset" + ], + "showDescription": false, + "showDefaultValue": true + }, + "valueDesc": "", + "debugLabel": "", + "toolDescription": "" + }, + { + "key": "system_httpMethod", + "renderTypeList": [ + "custom" + ], + "valueType": "string", + "label": "", + "value": "POST", + "required": true, + "valueDesc": "", + "description": "", + "debugLabel": "", + "toolDescription": "" + }, + { + "key": "system_httpTimeout", + "renderTypeList": [ + "custom" + ], + "valueType": "number", + "label": "", + "value": 30, + "min": 5, + "max": 600, + "required": true, + "valueDesc": "", + "description": "", + "debugLabel": "", + "toolDescription": "" + }, + { + "key": "system_httpReqUrl", + "renderTypeList": [ + "hidden" + ], + "valueType": "string", + "label": "", + "description": "common:core.module.input.description.Http Request Url", + "placeholder": "https://api.ai.com/getInventory", + "required": false, + "value": "sleep", + "valueDesc": "", + "debugLabel": "", + "toolDescription": "" + }, + { + "key": "system_httpHeader", + "renderTypeList": [ + "custom" + ], + "valueType": "any", + "value": [], + "label": "", + "description": "common:core.module.input.description.Http Request Header", + "placeholder": "common:core.module.input.description.Http Request Header", + "required": false, + "valueDesc": "", + "debugLabel": "", + "toolDescription": "" + }, + { + "key": "system_httpParams", + "renderTypeList": [ + "hidden" + ], + "valueType": "any", + "value": [], + "label": "", + "required": false, + "valueDesc": "", + "description": "", + "debugLabel": "", + "toolDescription": "" + }, + { + "key": "system_httpJsonBody", + "renderTypeList": [ + "hidden" + ], + "valueType": "any", + "value": "{\n\"ms\": {{$pluginInput.ms$}}\n}", + "label": "", + "required": false, + "valueDesc": "", + "description": "", + "debugLabel": "", + "toolDescription": "" + }, + { + "key": "system_httpFormBody", + "renderTypeList": [ + "hidden" + ], + "valueType": "any", + "value": [], + "label": "", + "required": false, + "valueDesc": "", + "description": "", + "debugLabel": "", + "toolDescription": "" + }, + { + "key": "system_httpContentType", + "renderTypeList": [ + "hidden" + ], + "valueType": "string", + "value": "json", + "label": "", + "required": false, + "valueDesc": "", + "description": "", + "debugLabel": "", + "toolDescription": "" + } + ], + "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", + "key": "system_addOutputParam", + "type": "dynamic", + "valueType": "dynamic", + "label": "输出字段提取", + "customFieldConfig": { + "selectValueTypeList": [ + "string", + "number", + "boolean", + "object", + "arrayString", + "arrayNumber", + "arrayBoolean", + "arrayObject", + "arrayAny", + "any", + "chatHistory", + "datasetQuote", + "dynamic", + "selectApp", + "selectDataset" + ], + "showDescription": false, + "showDefaultValue": false + }, + "description": "可以通过 JSONPath 语法来提取响应值中的指定字段", + "valueDesc": "" + } + ] + } + ], + "edges": [ + { + "source": "pluginInput", + "target": "zCJC6zw7c14i", + "sourceHandle": "pluginInput-source-right", + "targetHandle": "zCJC6zw7c14i-target-left" + }, + { + "source": "zCJC6zw7c14i", + "target": "pluginOutput", + "sourceHandle": "zCJC6zw7c14i-source-right", + "targetHandle": "pluginOutput-target-left" + } + ], + "chatConfig": { + "welcomeText": "", + "variables": [], + "questionGuide": { + "open": false, + "model": "gpt-4o-mini", + "customPrompt": "You are an AI assistant tasked with predicting the user's next question based on the conversation history. Your goal is to generate 3 potential questions that will guide the user to continue the conversation. When generating these questions, adhere to the following rules:\n\n1. Use the same language as the user's last question in the conversation history.\n2. Keep each question under 20 characters in length.\n\nAnalyze the conversation history provided to you and use it as context to generate relevant and engaging follow-up questions. Your predictions should be logical extensions of the current topic or related areas that the user might be interested in exploring further.\n\nRemember to maintain consistency in tone and style with the existing conversation while providing diverse options for the user to choose from. Your goal is to keep the conversation flowing naturally and help the user delve deeper into the subject matter or explore related topics." + }, + "ttsConfig": { + "type": "web" + }, + "whisperConfig": { + "open": false, + "autoSend": false, + "autoTTSResponse": false + }, + "chatInputGuide": { + "open": false, + "textList": [], + "customUrl": "" + }, + "instruction": "", + "autoExecute": { + "open": false, + "defaultPrompt": "" + }, + "_id": "6784ba2c227f92f6c723ead0" + } + } +} \ No newline at end of file diff --git a/packages/web/components/common/Icon/constants.ts b/packages/web/components/common/Icon/constants.ts index d8e4edc89034..7632a0b3ea3e 100644 --- a/packages/web/components/common/Icon/constants.ts +++ b/packages/web/components/common/Icon/constants.ts @@ -270,6 +270,7 @@ export const iconPaths = { import('./icons/core/workflow/template/datasource.svg'), 'core/workflow/template/duckduckgo': () => import('./icons/core/workflow/template/duckduckgo.svg'), + 'core/workflow/template/sleep': () => import('./icons/core/workflow/template/sleep.svg'), 'core/workflow/template/extractJson': () => import('./icons/core/workflow/template/extractJson.svg'), 'core/workflow/template/fetchUrl': () => import('./icons/core/workflow/template/fetchUrl.svg'), diff --git a/packages/web/components/common/Icon/icons/core/workflow/template/sleep.svg b/packages/web/components/common/Icon/icons/core/workflow/template/sleep.svg new file mode 100644 index 000000000000..070923902a35 --- /dev/null +++ b/packages/web/components/common/Icon/icons/core/workflow/template/sleep.svg @@ -0,0 +1,7 @@ + + + + \ No newline at end of file