From c8bc9838e3dd324f301a4ddfa6511477fae1bd9a Mon Sep 17 00:00:00 2001 From: Archer <545436317@qq.com> Date: Tue, 25 Jun 2024 13:47:25 +0800 Subject: [PATCH] feat: app template;fix: chat test reset (#1838) * feat: app template;fix: chat test reset * template output * template output --- .../zh-cn/docs/development/upgrading/485.md | 20 +- .../zh-cn/docs/workflow/examples/dalle3.md | 2 +- .../docs/workflow/examples/feishu_webhook.md | 780 +++---- .../core/workflow/dispatch/code/run.ts | 1 + .../app/public/imgs/app/templates/dalle.svg | 1 + .../app/public/imgs/app/templates/feishu.svg | 1 + .../app/public/imgs/app/templates/google.svg | 1 + .../public/imgs/app/templates/translate.svg | 1 + .../ChatBox/components/WholeResponseModal.tsx | 2 +- .../WorkflowComponents/Flow/ChatTest.tsx | 13 +- projects/app/src/web/core/app/templates.ts | 1952 ++++++++++++++++- 11 files changed, 2211 insertions(+), 563 deletions(-) create mode 100644 projects/app/public/imgs/app/templates/dalle.svg create mode 100644 projects/app/public/imgs/app/templates/feishu.svg create mode 100644 projects/app/public/imgs/app/templates/google.svg create mode 100644 projects/app/public/imgs/app/templates/translate.svg diff --git a/docSite/content/zh-cn/docs/development/upgrading/485.md b/docSite/content/zh-cn/docs/development/upgrading/485.md index 29984f24850..6525465a7d2 100644 --- a/docSite/content/zh-cn/docs/development/upgrading/485.md +++ b/docSite/content/zh-cn/docs/development/upgrading/485.md @@ -46,12 +46,14 @@ curl --location --request POST 'https://{{host}}/api/admin/init/485' \ 1. 新增 - 合并插件和应用,统一成工作台 2. 新增 - 应用创建副本功能 -3. 优化 - 原文件编码存取 -4. 优化 - 文件夹读取,支持单个文件夹超出 100 个文件 -5. 优化 - 问答拆分/手动录入,当有`a`字段时,自动将`q`作为补充索引。 -6. 优化 - 对话框页面代码 -7. 修复 - SSR渲染 -8. 修复 - 定时任务无法实际关闭 -9. 修复 - 输入引导特殊字符导致正则报错 -10. 修复 - 文件包含特殊字符`%`,且为转义时会导致页面崩溃 -11. 修复 - 自定义输入选择知识库引用时页面崩溃 \ No newline at end of file +3. 新增 - 应用创建模板 +4. 新增 - 支持代码运行结果作为工具输出。 +5. 优化 - 原文件编码存取 +6. 优化 - 文件夹读取,支持单个文件夹超出 100 个文件 +7. 优化 - 问答拆分/手动录入,当有`a`字段时,自动将`q`作为补充索引。 +8. 优化 - 对话框页面代码 +9. 修复 - SSR渲染 +10. 修复 - 定时任务无法实际关闭 +11. 修复 - 输入引导特殊字符导致正则报错 +12. 修复 - 文件包含特殊字符`%`,且为转义时会导致页面崩溃 +13. 修复 - 自定义输入选择知识库引用时页面崩溃 \ No newline at end of file diff --git a/docSite/content/zh-cn/docs/workflow/examples/dalle3.md b/docSite/content/zh-cn/docs/workflow/examples/dalle3.md index bd7415a9c33..cb1e1b79171 100644 --- a/docSite/content/zh-cn/docs/workflow/examples/dalle3.md +++ b/docSite/content/zh-cn/docs/workflow/examples/dalle3.md @@ -272,7 +272,7 @@ Response: { "key": "Authorization", "type": "string", - "value": "Bearer sk-zsfBsxEU3ApSFGYxF4CdB97e9556412588421823371b9f7b" + "value": "Bearer " } ], "label": "", diff --git a/docSite/content/zh-cn/docs/workflow/examples/feishu_webhook.md b/docSite/content/zh-cn/docs/workflow/examples/feishu_webhook.md index 78573eb52f8..c4e9baf26b6 100644 --- a/docSite/content/zh-cn/docs/workflow/examples/feishu_webhook.md +++ b/docSite/content/zh-cn/docs/workflow/examples/feishu_webhook.md @@ -26,456 +26,378 @@ weight: 404 {{% details title="编排配置" closed="true" %}} ```json -[ - { - "nodeId": "userGuide", - "name": "core.module.template.App system setting", - "intro": "core.app.tip.userGuideTip", - "avatar": "/imgs/workflow/userGuide.png", - "flowNodeType": "userGuide", - "position": { - "x": -92.26884681344463, - "y": 710.9354029649536 - }, - "inputs": [ - { - "key": "welcomeText", - "type": "hidden", - "valueType": "string", - "label": "core.app.Welcome Text", - "showTargetInApp": false, - "showTargetInPlugin": false, - "value": "", - "connected": false +{ + "nodes": [ + { + "nodeId": "userGuide", + "name": "系统配置", + "intro": "可以配置应用的系统参数", + "avatar": "/imgs/workflow/userGuide.png", + "flowNodeType": "userGuide", + "position": { + "x": 303.41163758039283, + "y": -552.297639861266 }, - { - "key": "variables", - "type": "hidden", - "valueType": "any", - "label": "core.module.Variable", - "value": [], - "showTargetInApp": false, - "showTargetInPlugin": false, - "connected": false + "version": "481", + "inputs": [], + "outputs": [] + }, + { + "nodeId": "workflowStartNodeId", + "name": "流程开始", + "intro": "", + "avatar": "/imgs/workflow/userChatInput.svg", + "flowNodeType": "workflowStart", + "position": { + "x": 529.3935295017156, + "y": 197.114018410347 }, - { - "key": "questionGuide", - "valueType": "boolean", - "type": "switch", - "label": "", - "showTargetInApp": false, - "showTargetInPlugin": false, - "value": false, - "connected": false + "version": "481", + "inputs": [ + { + "key": "userChatInput", + "renderTypeList": [ + "reference", + "textarea" + ], + "valueType": "string", + "label": "用户问题", + "required": true, + "toolDescription": "用户问题" + } + ], + "outputs": [ + { + "id": "userChatInput", + "key": "userChatInput", + "label": "core.module.input.label.user question", + "valueType": "string", + "type": "static" + } + ] + }, + { + "nodeId": "u6IAOEssxoZT", + "name": "工具调用(实验)", + "intro": "通过AI模型自动选择一个或多个功能块进行调用,也可以对插件进行调用。", + "avatar": "/imgs/workflow/tool.svg", + "flowNodeType": "tools", + "showStatus": true, + "position": { + "x": 1003.146243538873, + "y": 48.52327869406625 }, - { - "key": "tts", - "type": "hidden", - "valueType": "any", - "label": "", - "showTargetInApp": false, - "showTargetInPlugin": false, - "value": { - "type": "web" + "version": "481", + "inputs": [ + { + "key": "model", + "renderTypeList": [ + "settingLLMModel", + "reference" + ], + "label": "core.module.input.label.aiModel", + "valueType": "string", + "llmModelType": "all", + "value": "gpt-3.5-turbo" }, - "connected": false - } - ], - "outputs": [] - }, - { - "nodeId": "userChatInput", - "name": "core.module.template.Chat entrance", - "intro": "当用户发送一个内容后,流程将会从这个模块开始执行。", - "avatar": "/imgs/workflow/userChatInput.svg", - "flowNodeType": "questionInput", - "position": { - "x": 241.60980819261408, - "y": 1330.9528898009685 - }, - "inputs": [ - { - "key": "userChatInput", - "type": "systemInput", - "valueType": "string", - "label": "core.module.input.label.user question", - "showTargetInApp": false, - "showTargetInPlugin": false, - "connected": false - } - ], - "outputs": [ - { - "key": "userChatInput", - "label": "core.module.input.label.user question", - "type": "source", - "valueType": "string", - "targets": [ - { - "nodeId": "n84rvg", - "key": "userChatInput" - } - ] - } - ] - }, - { - "nodeId": "n84rvg", - "name": "工具调用(实验)", - "intro": "通过AI模型自动选择一个或多个功能块进行调用,也可以对插件进行调用。", - "avatar": "/imgs/workflow/tool.svg", - "flowNodeType": "tools", - "showStatus": true, - "position": { - "x": 809.4264785615641, - "y": 873.3971746859133 + { + "key": "temperature", + "renderTypeList": [ + "hidden" + ], + "label": "", + "value": 0, + "valueType": "number", + "min": 0, + "max": 10, + "step": 1 + }, + { + "key": "maxToken", + "renderTypeList": [ + "hidden" + ], + "label": "", + "value": 2000, + "valueType": "number", + "min": 100, + "max": 4000, + "step": 50 + }, + { + "key": "systemPrompt", + "renderTypeList": [ + "textarea", + "reference" + ], + "max": 3000, + "valueType": "string", + "label": "core.ai.Prompt", + "description": "core.app.tip.chatNodeSystemPromptTip", + "placeholder": "core.app.tip.chatNodeSystemPromptTip" + }, + { + "key": "history", + "renderTypeList": [ + "numberInput", + "reference" + ], + "valueType": "chatHistory", + "label": "core.module.input.label.chat history", + "description": "最多携带多少轮对话记录", + "required": true, + "min": 0, + "max": 50, + "value": 6 + }, + { + "key": "userChatInput", + "renderTypeList": [ + "reference", + "textarea" + ], + "valueType": "string", + "label": "用户问题", + "required": true, + "value": [ + "workflowStartNodeId", + "userChatInput" + ] + } + ], + "outputs": [ + { + "id": "answerText", + "key": "answerText", + "label": "core.module.output.label.Ai response content", + "description": "core.module.output.description.Ai response content", + "valueType": "string", + "type": "static" + } + ] }, - "inputs": [ - { - "key": "model", - "type": "settingLLMModel", - "label": "core.module.input.label.aiModel", - "required": true, - "valueType": "string", - "showTargetInApp": false, - "showTargetInPlugin": false, - "llmModelType": "all", - "value": "gpt-3.5-turbo", - "connected": false - }, - { - "key": "temperature", - "type": "hidden", - "label": "", - "value": 0, - "valueType": "number", - "min": 0, - "max": 10, - "step": 1, - "showTargetInApp": false, - "showTargetInPlugin": false, - "connected": false - }, - { - "key": "maxToken", - "type": "hidden", - "label": "", - "value": 2000, - "valueType": "number", - "min": 100, - "max": 4000, - "step": 50, - "showTargetInApp": false, - "showTargetInPlugin": false, - "connected": false - }, - { - "key": "systemPrompt", - "type": "textarea", - "max": 3000, - "valueType": "string", - "label": "core.ai.Prompt", - "description": "core.app.tip.chatNodeSystemPromptTip", - "placeholder": "core.app.tip.chatNodeSystemPromptTip", - "showTargetInApp": true, - "showTargetInPlugin": true, - "connected": false - }, - { - "key": "history", - "type": "numberInput", - "label": "core.module.input.label.chat history", - "required": true, - "min": 0, - "max": 30, - "valueType": "chatHistory", - "value": 6, - "showTargetInApp": true, - "showTargetInPlugin": true, - "connected": false - }, - { - "key": "userChatInput", - "type": "custom", - "label": "", - "required": true, - "valueType": "string", - "showTargetInApp": true, - "showTargetInPlugin": true, - "connected": true - } - ], - "outputs": [ - { - "key": "userChatInput", - "label": "core.module.input.label.user question", - "type": "hidden", - "valueType": "string", - "targets": [] - }, - { - "key": "selectedTools", - "valueType": "tools", - "type": "hidden", - "targets": [ - { - "nodeId": "3mbu91", - "key": "selectedTools" - } - ] + { + "nodeId": "fvY5hb0K646V", + "name": "工具调用终止", + "intro": "该模块需配置工具调用使用。当该模块被执行时,本次工具调用将会强制结束,并且不再调用AI针对工具调用结果回答问题。", + "avatar": "/imgs/workflow/toolStop.svg", + "flowNodeType": "stopTool", + "position": { + "x": 2367.838362362707, + "y": 732.355988936165 }, - { - "key": "finish", - "label": "", - "description": "", - "valueType": "boolean", - "type": "hidden", - "targets": [] - } - ] - }, - { - "nodeId": "3mbu91", - "name": "HTTP 请求", - "intro": "调用飞书webhook,发送一个通知", - "avatar": "/imgs/workflow/http.png", - "flowNodeType": "httpRequest468", - "showStatus": true, - "position": { - "x": 1483.6437630977423, - "y": 798.9716928475544 + "version": "481", + "inputs": [], + "outputs": [] }, - "inputs": [ - - { - "key": "system_httpMethod", - "type": "custom", - "valueType": "string", - "label": "", - "value": "POST", - "required": true, - "showTargetInApp": false, - "showTargetInPlugin": false, - "connected": false + { + "nodeId": "x9rN2a4WnZmt", + "name": "HTTP 请求", + "intro": "向飞书发送一个webhooks通知信息。", + "avatar": "/imgs/workflow/http.png", + "flowNodeType": "httpRequest468", + "showStatus": true, + "position": { + "x": 1623.9214305901633, + "y": 22.777089001645862 }, - { - "key": "system_httpReqUrl", - "type": "hidden", - "valueType": "string", - "label": "", - "description": "core.module.input.description.Http Request Url", - "placeholder": "https://api.ai.com/getInventory", - "required": false, - "showTargetInApp": false, - "showTargetInPlugin": false, - "value": "这里填写你的飞书机器人地址", - "connected": false - }, - { - "key": "system_httpHeader", - "type": "custom", - "valueType": "any", - "value": [], - "label": "", - "description": "core.module.input.description.Http Request Header", - "placeholder": "core.module.input.description.Http Request Header", - "required": false, - "showTargetInApp": false, - "showTargetInPlugin": false, - "connected": false - }, - { - "key": "system_httpParams", - "type": "hidden", - "valueType": "any", - "value": [], - "label": "", - "required": false, - "showTargetInApp": false, - "showTargetInPlugin": false, - "connected": false - }, - { - "key": "system_httpJsonBody", - "type": "hidden", - "valueType": "any", - "value": "{\r\n \"msg_type\": \"text\",\r\n \"content\": {\r\n \"text\": \"{{text}}\"\r\n }\r\n}", - "label": "", - "required": false, - "showTargetInApp": false, - "showTargetInPlugin": false, - "connected": false - }, - { - "key": "DYNAMIC_INPUT_KEY", - "type": "target", - "valueType": "any", - "label": "core.workflow.inputType.dynamicTargetInput", - "description": "core.module.input.description.dynamic input", - "required": false, - "showTargetInApp": false, - "showTargetInPlugin": true, - "hideInApp": true, - "connected": false - }, - { - "key": "system_addInputParam", - "type": "addInputParam", - "valueType": "any", - "label": "", - "required": false, - "showTargetInApp": false, - "showTargetInPlugin": false, - "editField": { - "key": true, - "description": true, - "dataType": true - }, - "defaultEditField": { + "version": "481", + "inputs": [ + { + "key": "system_addInputParam", + "renderTypeList": [ + "addInputParam" + ], + "valueType": "dynamic", "label": "", - "key": "", - "description": "", - "inputType": "target", - "valueType": "string" + "required": false, + "description": "core.module.input.description.HTTP Dynamic Input", + "editField": { + "key": true, + "valueType": true + } }, - "connected": false - }, - { - "valueType": "string", - "type": "hidden", - "key": "text", - "label": "text", - "toolDescription": "需要发送的通知内容", - "required": true, - "connected": false - } - ], - "outputs": [ - { - "key": "httpRawResponse", - "label": "原始响应", - "description": "HTTP请求的原始响应。只能接受字符串或JSON类型响应数据。", - "valueType": "any", - "type": "source", - "targets": [ - { - "nodeId": "rzx4mj", - "key": "switch" - }, - { - "nodeId": "psdhs1", - "key": "switch" + { + "valueType": "string", + "renderTypeList": [ + "reference" + ], + "key": "text", + "label": "text", + "toolDescription": "发送的消息", + "required": true, + "canEdit": true, + "editField": { + "key": true, + "description": true } - ] - }, - { - "key": "system_addOutputParam", - "type": "addOutputParam", - "valueType": "any", - "label": "", - "targets": [], - "editField": { - "key": true, - "description": true, - "dataType": true, - "defaultValue": true }, - "defaultEditField": { + { + "key": "system_httpMethod", + "renderTypeList": [ + "custom" + ], + "valueType": "string", + "label": "", + "value": "POST", + "required": true + }, + { + "key": "system_httpReqUrl", + "renderTypeList": [ + "hidden" + ], + "valueType": "string", + "label": "", + "description": "core.module.input.description.Http Request Url", + "placeholder": "https://api.ai.com/getInventory", + "required": false, + "value": "" + }, + { + "key": "system_httpHeader", + "renderTypeList": [ + "custom" + ], + "valueType": "any", + "value": [], "label": "", - "key": "", - "description": "", - "outputType": "source", - "valueType": "string" + "description": "core.module.input.description.Http Request Header", + "placeholder": "core.module.input.description.Http Request Header", + "required": false + }, + { + "key": "system_httpParams", + "renderTypeList": [ + "hidden" + ], + "valueType": "any", + "value": [], + "label": "", + "required": false + }, + { + "key": "system_httpJsonBody", + "renderTypeList": [ + "hidden" + ], + "valueType": "any", + "value": "{\r\n \"msg_type\": \"text\",\r\n \"content\": {\r\n \"text\": \"{{text}}\"\r\n }\r\n}", + "label": "", + "required": false } - }, - { - "type": "source", - "valueType": "string", - "key": "prompt", - "label": "prompt", - "description": "", - "required": false, - "edit": true, - "editField": { - "key": true, - "description": true, - "dataType": true, - "defaultValue": true + ], + "outputs": [ + { + "id": "system_addOutputParam", + "key": "system_addOutputParam", + "type": "dynamic", + "valueType": "dynamic", + "label": "", + "editField": { + "key": true, + "valueType": true + } }, - "targets": [] - } - ] - }, - { - "nodeId": "rzx4mj", - "name": "工具调用终止", - "intro": "该模块需配置工具调用使用。当该模块被执行时,本次工具调用将会强制结束,并且不再调用AI针对工具调用结果回答问题。", - "avatar": "/imgs/workflow/toolStop.svg", - "flowNodeType": "stopTool", - "position": { - "x": 2145.5070710160267, - "y": 1306.3581817783079 - }, - "inputs": [ - { - "key": "switch", - "type": "triggerAndFinish", - "label": "", - "description": "core.module.input.description.Trigger", - "valueType": "any", - "showTargetInApp": true, - "showTargetInPlugin": true, - "connected": true - } - ], - "outputs": [] - }, - { - "nodeId": "psdhs1", - "name": "指定回复", - "intro": "该模块可以直接回复一段指定的内容。常用于引导、提示。非字符串内容传入时,会转成字符串进行输出。", - "avatar": "/imgs/workflow/reply.png", - "flowNodeType": "answerNode", - "position": { - "x": 2117.0429459850598, - "y": 1658.4125434513746 + { + "id": "error", + "key": "error", + "label": "请求错误", + "description": "HTTP请求错误信息,成功时返回空", + "valueType": "object", + "type": "static" + }, + { + "id": "httpRawResponse", + "key": "httpRawResponse", + "label": "原始响应", + "required": true, + "description": "HTTP请求的原始响应。只能接受字符串或JSON类型响应数据。", + "valueType": "any", + "type": "static" + } + ] }, - "inputs": [ - { - "key": "switch", - "type": "triggerAndFinish", - "label": "", - "description": "core.module.input.description.Trigger", - "valueType": "any", - "showTargetInApp": true, - "showTargetInPlugin": true, - "connected": true + { + "nodeId": "aGHGqH2oUupj", + "name": "指定回复", + "intro": "该模块可以直接回复一段指定的内容。常用于引导、提示。非字符串内容传入时,会转成字符串进行输出。", + "avatar": "/imgs/workflow/reply.png", + "flowNodeType": "answerNode", + "position": { + "x": 2350.7077940158674, + "y": 107.32448732713493 }, + "version": "481", + "inputs": [ + { + "key": "text", + "renderTypeList": [ + "textarea", + "reference" + ], + "valueType": "any", + "required": true, + "label": "core.module.input.label.Response content", + "description": "core.module.input.description.Response content", + "placeholder": "core.module.input.description.Response content", + "value": "嘻嘻,发送成功" + } + ], + "outputs": [] + } + ], + "edges": [ + { + "source": "workflowStartNodeId", + "target": "u6IAOEssxoZT", + "sourceHandle": "workflowStartNodeId-source-right", + "targetHandle": "u6IAOEssxoZT-target-left" + }, + { + "source": "u6IAOEssxoZT", + "target": "x9rN2a4WnZmt", + "sourceHandle": "selectedTools", + "targetHandle": "selectedTools" + }, + { + "source": "x9rN2a4WnZmt", + "target": "fvY5hb0K646V", + "sourceHandle": "x9rN2a4WnZmt-source-right", + "targetHandle": "fvY5hb0K646V-target-left" + }, + { + "source": "x9rN2a4WnZmt", + "target": "aGHGqH2oUupj", + "sourceHandle": "x9rN2a4WnZmt-source-right", + "targetHandle": "aGHGqH2oUupj-target-left" + } + ], + "chatConfig": { + "variables": [ { - "key": "text", - "type": "textarea", - "valueType": "any", - "label": "core.module.input.label.Response content", - "description": "core.module.input.description.Response content", - "placeholder": "core.module.input.description.Response content", - "showTargetInApp": true, - "showTargetInPlugin": true, - "value": "笑死发送成功啦", - "connected": false + "id": "txq1ca", + "key": "test", + "label": "测试", + "type": "custom", + "required": true, + "maxLen": 50, + "enums": [ + { + "value": "" + } + ] } ], - "outputs": [ - { - "key": "finish", - "label": "", - "description": "", - "valueType": "boolean", - "type": "hidden", - "targets": [] - } - ] + "questionGuide": false, + "scheduledTriggerConfig": { + "cronString": "", + "timezone": "Asia/Shanghai", + "defaultPrompt": "" + }, + "_id": "66715d4bf577287d39e35ecf" } -] +} ``` {{% /details %}} diff --git a/packages/service/core/workflow/dispatch/code/run.ts b/packages/service/core/workflow/dispatch/code/run.ts index bf985a7897e..1d6173b3ff0 100644 --- a/packages/service/core/workflow/dispatch/code/run.ts +++ b/packages/service/core/workflow/dispatch/code/run.ts @@ -42,6 +42,7 @@ export const dispatchRunCode = async (props: RunCodeType): Promise \ No newline at end of file diff --git a/projects/app/public/imgs/app/templates/feishu.svg b/projects/app/public/imgs/app/templates/feishu.svg new file mode 100644 index 00000000000..7c7b43b5961 --- /dev/null +++ b/projects/app/public/imgs/app/templates/feishu.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/projects/app/public/imgs/app/templates/google.svg b/projects/app/public/imgs/app/templates/google.svg new file mode 100644 index 00000000000..f29dfa728c3 --- /dev/null +++ b/projects/app/public/imgs/app/templates/google.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/projects/app/public/imgs/app/templates/translate.svg b/projects/app/public/imgs/app/templates/translate.svg new file mode 100644 index 00000000000..8d02841e69d --- /dev/null +++ b/projects/app/public/imgs/app/templates/translate.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/projects/app/src/components/ChatBox/components/WholeResponseModal.tsx b/projects/app/src/components/ChatBox/components/WholeResponseModal.tsx index 7a8fc39de7c..e5422f2e501 100644 --- a/projects/app/src/components/ChatBox/components/WholeResponseModal.tsx +++ b/projects/app/src/components/ChatBox/components/WholeResponseModal.tsx @@ -316,8 +316,8 @@ export const ResponseBox = React.memo(function ResponseBox({ )} {/* code */} - + diff --git a/projects/app/src/pages/app/detail/components/WorkflowComponents/Flow/ChatTest.tsx b/projects/app/src/pages/app/detail/components/WorkflowComponents/Flow/ChatTest.tsx index 8c9c8082444..cb6a9252d3c 100644 --- a/projects/app/src/pages/app/detail/components/WorkflowComponents/Flow/ChatTest.tsx +++ b/projects/app/src/pages/app/detail/components/WorkflowComponents/Flow/ChatTest.tsx @@ -1,11 +1,9 @@ import type { StoreNodeItemType } from '@fastgpt/global/core/workflow/type/index.d'; -import React, { useRef, forwardRef, ForwardedRef, useImperativeHandle } from 'react'; +import React, { forwardRef, ForwardedRef } from 'react'; import { SmallCloseIcon } from '@chakra-ui/icons'; import { Box, Flex, IconButton } from '@chakra-ui/react'; import MyIcon from '@fastgpt/web/components/common/Icon'; import MyTooltip from '@fastgpt/web/components/common/MyTooltip'; -import { useUserStore } from '@/web/support/user/useUserStore'; -import type { ComponentRef } from '@/components/ChatBox/type.d'; import { useTranslation } from 'next-i18next'; import { StoreEdgeItemType } from '@fastgpt/global/core/workflow/type/edge'; @@ -32,7 +30,6 @@ const ChatTest = ( ref: ForwardedRef ) => { const { t } = useTranslation(); - const ChatBoxRef = useRef(null); const { appDetail } = useContextSelector(AppContext, (v) => v); const { resetChatBox, ChatBox } = useChatTest({ @@ -41,10 +38,6 @@ const ChatTest = ( chatConfig: appDetail.chatConfig }); - useImperativeHandle(ref, () => ({ - resetChatTest: resetChatBox - })); - return ( <> { - e.stopPropagation(); - ChatBoxRef.current?.resetHistory([]); - ChatBoxRef.current?.resetVariables(); + resetChatBox(); }} /> diff --git a/projects/app/src/web/core/app/templates.ts b/projects/app/src/web/core/app/templates.ts index e1da5a50c23..bcaf81f7b53 100644 --- a/projects/app/src/web/core/app/templates.ts +++ b/projects/app/src/web/core/app/templates.ts @@ -1,6 +1,11 @@ +// @ts-nocheck + import { AppItemType } from '@/types/app'; import { AppTypeEnum } from '@fastgpt/global/core/app/constants'; -import { WorkflowIOValueTypeEnum } from '@fastgpt/global/core/workflow/constants'; +import { + NodeOutputKeyEnum, + WorkflowIOValueTypeEnum +} from '@fastgpt/global/core/workflow/constants'; import { FlowNodeInputTypeEnum, FlowNodeOutputTypeEnum, @@ -819,15 +824,197 @@ export const simpleBotTemplates: TemplateType = [ targetHandle: '7BdojPlukIQw-target-left' } ] + }, + { + id: 'toolChat', + avatar: '/imgs/workflow/history.png', + name: '知道时间的机器人', + intro: '通过挂载时间插件,让模型获取当前最新时间', + type: AppTypeEnum.simple, + modules: [ + { + nodeId: 'userGuide', + name: '系统配置', + intro: '可以配置应用的系统参数', + avatar: '/imgs/workflow/userGuide.png', + flowNodeType: FlowNodeTypeEnum.systemConfig, + position: { + x: 531.2422736065552, + y: -486.7611729549753 + }, + version: '481', + inputs: [], + outputs: [] + }, + { + nodeId: 'workflowStartNodeId', + name: '流程开始', + intro: '', + avatar: '/imgs/workflow/userChatInput.svg', + flowNodeType: FlowNodeTypeEnum.workflowStart, + position: { + x: 558.4082376415505, + y: 123.72387429194112 + }, + version: '481', + inputs: [ + { + key: 'userChatInput', + renderTypeList: ['reference', 'textarea'], + valueType: 'string', + label: '用户问题', + required: true, + toolDescription: '用户问题' + } + ], + outputs: [ + { + id: 'userChatInput', + key: 'userChatInput', + label: 'core.module.input.label.user question', + valueType: 'string', + type: 'static' + } + ] + }, + { + nodeId: 'jrWPV9', + name: '工具调用(实验)', + intro: '通过AI模型自动选择一个或多个功能块进行调用,也可以对插件进行调用。', + avatar: '/imgs/workflow/tool.svg', + flowNodeType: FlowNodeTypeEnum.tools, + showStatus: true, + position: { + x: 1062.1738942532802, + y: -223.65033022650476 + }, + version: '481', + inputs: [ + { + key: 'model', + renderTypeList: ['settingLLMModel', 'reference'], + label: 'core.module.input.label.aiModel', + valueType: 'string', + llmModelType: 'all', + value: 'gpt-3.5-turbo' + }, + { + key: 'temperature', + renderTypeList: ['hidden'], + label: '', + value: 0, + valueType: 'number', + min: 0, + max: 10, + step: 1 + }, + { + key: 'maxToken', + renderTypeList: ['hidden'], + label: '', + value: 2000, + valueType: 'number', + min: 100, + max: 4000, + step: 50 + }, + { + key: 'systemPrompt', + renderTypeList: ['textarea', 'reference'], + max: 3000, + valueType: 'string', + label: 'core.ai.Prompt', + description: 'core.app.tip.chatNodeSystemPromptTip', + placeholder: 'core.app.tip.chatNodeSystemPromptTip', + value: '' + }, + { + key: 'history', + renderTypeList: ['numberInput', 'reference'], + valueType: 'chatHistory', + label: 'core.module.input.label.chat history', + description: '最多携带多少轮对话记录', + required: true, + min: 0, + max: 30, + value: 6 + }, + { + key: 'userChatInput', + renderTypeList: ['reference', 'textarea'], + valueType: 'string', + label: '用户问题', + required: true, + value: ['workflowStartNodeId', 'userChatInput'] + } + ], + outputs: [ + { + id: 'answerText', + key: 'answerText', + label: 'core.module.output.label.Ai response content', + description: 'core.module.output.description.Ai response content', + valueType: 'string', + type: 'static' + } + ] + }, + { + nodeId: 'zBxjo5', + name: '获取当前时间', + intro: '获取用户当前时区的时间。', + avatar: '/imgs/workflow/getCurrentTime.svg', + flowNodeType: 'pluginModule', + showStatus: false, + position: { + x: 1000, + y: 545 + }, + version: '481', + inputs: [], + outputs: [ + { + id: 'time', + type: 'static', + key: 'time', + valueType: 'string', + label: 'time', + description: '' + } + ], + pluginId: 'community-getCurrentTime' + } + ], + edges: [ + { + source: 'workflowStartNodeId', + target: 'jrWPV9', + sourceHandle: 'workflowStartNodeId-source-right', + targetHandle: 'jrWPV9-target-left' + }, + { + source: 'jrWPV9', + target: 'zBxjo5', + sourceHandle: 'selectedTools', + targetHandle: 'selectedTools' + } + ], + chatConfig: { + scheduledTriggerConfig: { + cronString: '', + timezone: 'Asia/Shanghai', + defaultPrompt: '' + } + } } ]; export const workflowTemplates: TemplateType = [ { - id: 'CQ', - avatar: '/imgs/workflow/cq.png', - name: '问题分类 + 知识库', - intro: '先对用户的问题进行分类,再根据不同类型问题,执行不同的操作', + id: 'TranslateRobot', + avatar: '/imgs/app/templates/translate.svg', + name: '多轮翻译机器人', + intro: '通过4轮翻译,提高翻译英文的质量', type: AppTypeEnum.workflow, modules: [ { @@ -835,7 +1022,7 @@ export const workflowTemplates: TemplateType = [ name: '系统配置', intro: '可以配置应用的系统参数', avatar: '/imgs/workflow/userGuide.png', - flowNodeType: FlowNodeTypeEnum.systemConfig, + flowNodeType: 'userGuide', position: { x: 531.2422736065552, y: -486.7611729549753 @@ -844,29 +1031,29 @@ export const workflowTemplates: TemplateType = [ inputs: [ { key: 'welcomeText', - renderTypeList: [FlowNodeInputTypeEnum.hidden], - valueType: WorkflowIOValueTypeEnum.string, + renderTypeList: ['hidden'], + valueType: 'string', label: 'core.app.Welcome Text', - value: '你好,我是知识库助手,请不要忘记选择知识库噢~\n[你是谁]\n[如何使用]' + value: '' }, { key: 'variables', - renderTypeList: [FlowNodeInputTypeEnum.hidden], - valueType: WorkflowIOValueTypeEnum.any, + renderTypeList: ['hidden'], + valueType: 'any', label: 'core.app.Chat Variable', value: [] }, { key: 'questionGuide', - valueType: WorkflowIOValueTypeEnum.boolean, - renderTypeList: [FlowNodeInputTypeEnum.hidden], + valueType: 'boolean', + renderTypeList: ['hidden'], label: 'core.app.Question Guide', - value: true + value: false }, { key: 'tts', - renderTypeList: [FlowNodeInputTypeEnum.hidden], - valueType: WorkflowIOValueTypeEnum.any, + renderTypeList: ['hidden'], + valueType: 'any', label: '', value: { type: 'web' @@ -874,8 +1061,8 @@ export const workflowTemplates: TemplateType = [ }, { key: 'whisper', - renderTypeList: [FlowNodeInputTypeEnum.hidden], - valueType: WorkflowIOValueTypeEnum.any, + renderTypeList: ['hidden'], + valueType: 'any', label: '', value: { open: false, @@ -885,8 +1072,8 @@ export const workflowTemplates: TemplateType = [ }, { key: 'scheduleTrigger', - renderTypeList: [FlowNodeInputTypeEnum.hidden], - valueType: WorkflowIOValueTypeEnum.any, + renderTypeList: ['hidden'], + valueType: 'any', label: '', value: null } @@ -894,11 +1081,11 @@ export const workflowTemplates: TemplateType = [ outputs: [] }, { - nodeId: 'workflowStartNodeId', + nodeId: '448745', name: '流程开始', intro: '', avatar: '/imgs/workflow/userChatInput.svg', - flowNodeType: FlowNodeTypeEnum.workflowStart, + flowNodeType: 'workflowStart', position: { x: 558.4082376415505, y: 123.72387429194112 @@ -907,8 +1094,8 @@ export const workflowTemplates: TemplateType = [ inputs: [ { key: 'userChatInput', - renderTypeList: [FlowNodeInputTypeEnum.reference, FlowNodeInputTypeEnum.textarea], - valueType: WorkflowIOValueTypeEnum.string, + renderTypeList: ['reference', 'textarea'], + valueType: 'string', label: '用户问题', required: true, toolDescription: '用户问题' @@ -919,88 +1106,87 @@ export const workflowTemplates: TemplateType = [ id: 'userChatInput', key: 'userChatInput', label: 'core.module.input.label.user question', - valueType: WorkflowIOValueTypeEnum.string, - type: FlowNodeOutputTypeEnum.static + valueType: 'string', + type: 'static' } ] }, { - nodeId: '7BdojPlukIQw', - name: 'AI 对话', + nodeId: 'loOvhld2ZTKa', + name: '第一轮翻译', intro: 'AI 大模型对话', avatar: '/imgs/workflow/AI.png', - flowNodeType: FlowNodeTypeEnum.chatNode, + flowNodeType: 'chatNode', showStatus: true, position: { - x: 2701.1267277679685, - y: -767.8956312653042 + x: 1748.8252410306534, + y: -245.08260685989214 }, version: '481', inputs: [ { key: 'model', - renderTypeList: [ - FlowNodeInputTypeEnum.settingLLMModel, - FlowNodeInputTypeEnum.reference - ], + renderTypeList: ['settingLLMModel', 'reference'], label: 'core.module.input.label.aiModel', - valueType: WorkflowIOValueTypeEnum.string, - value: 'gpt-3.5-turbo' + valueType: 'string', + value: 'gpt-4o' }, { key: 'temperature', - renderTypeList: [FlowNodeInputTypeEnum.hidden], + renderTypeList: ['hidden'], label: '', - value: 3, - valueType: WorkflowIOValueTypeEnum.number, + value: 0, + valueType: 'number', min: 0, max: 10, step: 1 }, { key: 'maxToken', - renderTypeList: [FlowNodeInputTypeEnum.hidden], + renderTypeList: ['hidden'], label: '', - value: 1950, - valueType: WorkflowIOValueTypeEnum.number, + value: 2000, + valueType: 'number', min: 100, max: 4000, step: 50 }, { key: 'isResponseAnswerText', - renderTypeList: [FlowNodeInputTypeEnum.hidden], + renderTypeList: ['hidden'], label: '', value: true, - valueType: WorkflowIOValueTypeEnum.boolean + valueType: 'boolean' }, { key: 'quoteTemplate', - renderTypeList: [FlowNodeInputTypeEnum.hidden], + renderTypeList: ['hidden'], label: '', - valueType: WorkflowIOValueTypeEnum.string + valueType: 'string' }, { key: 'quotePrompt', - renderTypeList: [FlowNodeInputTypeEnum.hidden], + renderTypeList: ['hidden'], label: '', - valueType: WorkflowIOValueTypeEnum.string + valueType: 'string' }, { key: 'systemPrompt', - renderTypeList: [FlowNodeInputTypeEnum.textarea, FlowNodeInputTypeEnum.reference], + renderTypeList: ['textarea', 'reference'], max: 3000, - valueType: WorkflowIOValueTypeEnum.string, + valueType: 'string', label: 'core.ai.Prompt', description: 'core.app.tip.chatNodeSystemPromptTip', placeholder: 'core.app.tip.chatNodeSystemPromptTip', - value: '' + value: + '# Role: 资深英汉翻译专家\n\n## Background:\n你是一位经验丰富的英汉翻译专家,精通英汉互译,尤其擅长将英文文章译成流畅易懂的现代汉语。你曾多次带领团队完成大型翻译项目,译文广受好评。\n\n## Attention:\n- 翻译过程中要始终坚持"信、达、雅"的原则,但"达"尤为重要\n- 译文要符合现代汉语的表达习惯,通俗易懂,连贯流畅 \n- 避免使用过于文绉绉的表达和晦涩难懂的典故引用\n\n## Profile: \n- Author: 米开朗基杨 \n- Version: 0.2\n- Language: 中文\n- Description: 你是一位资深英汉翻译专家,精通英汉互译。你擅长将英文文章译成地道流畅的现代汉语,表达准确易懂,符合当代中文语言习惯。\n\n## Constraints:\n- 必须严格遵循四轮翻译流程:直译、意译、校审、定稿 \n- 译文要忠实原文,准确无误,不能遗漏或曲解原意\n- 译文应以现代白话文为主,避免过多使用文言文和古典诗词\n- 每一轮翻译前后必须添加【思考】和【翻译】标记\n- 最终译文使用Markdown的代码块呈现\n\n## Goals:\n- 通过四轮翻译流程,将英文原文译成高质量的现代汉语译文 \n- 译文要准确传达原文意思,语言表达力求浅显易懂,朗朗上口\n- 适度使用一些熟语俗语、流行网络用语等,增强译文的亲和力\n- 在直译的基础上,提供至少2个不同风格的意译版本供选择\n\n## Skills:\n- 精通英汉双语,具有扎实的语言功底和丰富的翻译经验\n- 擅长将英语表达习惯转换为地道自然的现代汉语\n- 对当代中文语言的发展变化有敏锐洞察,善于把握语言流行趋势\n\n## Workflow:\n1. 第一轮直译:逐字逐句忠实原文,不遗漏任何信息\n2. 第二轮意译:在直译的基础上用通俗流畅的现代汉语意译原文,至少提供2个不同风格的版本\n3. 第三轮校审:仔细审视译文,消除偏差和欠缺,使译文更加地道易懂 \n4. 第四轮定稿:择优选取,反复修改润色,最终定稿出一个简洁畅达、符合大众阅读习惯的译文\n\n## OutputFormat: \n- 每一轮翻译前用【思考】说明该轮要点\n- 每一轮翻译后用【翻译】呈现译文\n- 在\\`\\`\\`代码块中展示最终定稿译文\n\n## Suggestions:\n- 直译时力求忠实原文,但不要过于拘泥逐字逐句\n- 意译时在准确表达原意的基础上,用最朴实无华的现代汉语来表达 \n- 校审环节重点关注译文是否符合当代汉语表达习惯,是否通俗易懂\n- 定稿时适度采用一些熟语谚语、网络流行语等,使译文更接地气\n- 善于利用中文的灵活性,用不同的表述方式展现同一内容,提高译文的可读性\n\n## Initialization\n作为一名资深英汉翻译专家,你必须严格遵循翻译流程的各项要求。首先请向用户问好,介绍你将带领团队完成翻译任务,力求将英文原文译成通俗易懂的现代汉语。然后简要说明四轮翻译流程,请用户提供英文原文,开始进行翻译工作。' }, { key: 'history', - renderTypeList: [FlowNodeInputTypeEnum.numberInput, FlowNodeInputTypeEnum.reference], - valueType: WorkflowIOValueTypeEnum.chatHistory, + renderTypeList: ['numberInput', 'reference'], + valueType: 'chatHistory', label: 'core.module.input.label.chat history', + description: '最多携带多少轮对话记录', required: true, min: 0, max: 30, @@ -1008,21 +1194,20 @@ export const workflowTemplates: TemplateType = [ }, { key: 'userChatInput', - renderTypeList: [FlowNodeInputTypeEnum.reference, FlowNodeInputTypeEnum.textarea], - valueType: WorkflowIOValueTypeEnum.string, + renderTypeList: ['reference', 'textarea'], + valueType: 'string', label: '用户问题', required: true, toolDescription: '用户问题', - value: ['workflowStartNodeId', 'userChatInput'] + value: ['k2QsBOBmH9Xu', 'text'] }, { key: 'quoteQA', - renderTypeList: [FlowNodeInputTypeEnum.settingDatasetQuotePrompt], + renderTypeList: ['settingDatasetQuotePrompt'], label: '', debugLabel: '知识库引用', description: '', - valueType: WorkflowIOValueTypeEnum.datasetQuote, - value: ['MNMMMIjjWyMU', 'quoteQA'] + valueType: 'datasetQuote' } ], outputs: [ @@ -1031,80 +1216,1387 @@ export const workflowTemplates: TemplateType = [ key: 'history', label: 'core.module.output.label.New context', description: 'core.module.output.description.New context', - valueType: WorkflowIOValueTypeEnum.chatHistory, - type: FlowNodeOutputTypeEnum.static + valueType: 'chatHistory', + type: 'static', + required: true }, { id: 'answerText', key: 'answerText', label: 'core.module.output.label.Ai response content', description: 'core.module.output.description.Ai response content', - valueType: WorkflowIOValueTypeEnum.string, - type: FlowNodeOutputTypeEnum.static + valueType: 'string', + type: 'static', + required: true } ] }, { - nodeId: 'rvbo634w3AYj', - name: '问题分类', - intro: - '根据用户的历史记录和当前问题判断该次提问的类型。可以添加多组问题类型,下面是一个模板例子:\n类型1: 打招呼\n类型2: 关于商品“使用”问题\n类型3: 关于商品“购买”问题\n类型4: 其他问题', - avatar: '/imgs/workflow/cq.png', - flowNodeType: FlowNodeTypeEnum.classifyQuestion, - showStatus: true, + nodeId: 'k2QsBOBmH9Xu', + name: '原文声明', + intro: '可对固定或传入的文本进行加工后输出,非字符串类型数据最终会转成字符串类型。', + avatar: '/imgs/workflow/textEditor.svg', + flowNodeType: 'pluginModule', + showStatus: false, position: { - x: 1020.9667229609946, - y: -385.0060974413916 + x: 1000.9259923224292, + y: 3.3737410194846404 }, version: '481', inputs: [ { - key: 'model', - renderTypeList: [FlowNodeInputTypeEnum.selectLLMModel, FlowNodeInputTypeEnum.reference], - label: 'core.module.input.label.aiModel', - required: true, - valueType: WorkflowIOValueTypeEnum.string, - llmModelType: 'classify', - value: 'gpt-3.5-turbo' - }, - { - key: 'systemPrompt', - renderTypeList: [FlowNodeInputTypeEnum.textarea, FlowNodeInputTypeEnum.reference], - max: 3000, - valueType: WorkflowIOValueTypeEnum.string, - label: 'core.module.input.label.Background', - description: 'core.module.input.description.Background', - placeholder: 'core.module.input.placeholder.Classify background', - value: '' + key: 'system_addInputParam', + valueType: 'dynamic', + label: '动态外部数据', + renderTypeList: ['addInputParam'], + required: false, + description: '', + canEdit: false, + value: '', + editField: { + key: true + }, + dynamicParamDefaultValue: { + inputType: 'reference', + valueType: 'string', + required: true + } }, { - key: 'history', - renderTypeList: [FlowNodeInputTypeEnum.numberInput, FlowNodeInputTypeEnum.reference], - valueType: WorkflowIOValueTypeEnum.chatHistory, - label: 'core.module.input.label.chat history', + key: 'q', + valueType: 'string', + label: 'q', + renderTypeList: ['reference'], required: true, - min: 0, - max: 30, - value: 6 + description: '', + canEdit: true, + editField: { + key: true + }, + value: ['448745', 'userChatInput'] }, { - key: 'userChatInput', - renderTypeList: [FlowNodeInputTypeEnum.reference, FlowNodeInputTypeEnum.textarea], - valueType: WorkflowIOValueTypeEnum.string, - label: '用户问题', + key: '文本', + valueType: 'string', + label: '文本', + renderTypeList: ['textarea'], required: true, - value: ['workflowStartNodeId', 'userChatInput'] - }, + description: '', + canEdit: false, + value: '原文:\n"""\n{{q}}\n"""', + editField: { + key: true + }, + maxLength: '', + dynamicParamDefaultValue: { + inputType: 'reference', + valueType: 'string', + required: true + } + } + ], + outputs: [ { - key: 'agents', - renderTypeList: [FlowNodeInputTypeEnum.custom], - valueType: WorkflowIOValueTypeEnum.any, - label: '', - value: [ - { - value: '关于电影《星际穿越》的问题', - key: 'wqre' - }, + id: 'text', + type: 'static', + key: 'text', + valueType: 'string', + label: 'text', + description: '' + } + ], + pluginId: 'community-textEditor' + }, + { + nodeId: 'w0oBbQ3YJHye', + name: '代码运行', + intro: '执行一段简单的脚本代码,通常用于进行复杂的数据处理。', + avatar: '/imgs/workflow/code.svg', + flowNodeType: 'code', + showStatus: true, + position: { + x: 2522.61682940854, + y: -79.74569750380468 + }, + version: '482', + inputs: [ + { + key: 'system_addInputParam', + renderTypeList: ['addInputParam'], + valueType: 'dynamic', + label: '', + required: false, + description: '这些变量会作为代码的运行的输入参数', + editField: { + key: true, + valueType: true + } + }, + { + key: 'data1', + valueType: 'string', + label: 'data1', + renderTypeList: ['reference'], + description: '', + canEdit: true, + editField: { + key: true, + valueType: true + }, + value: ['loOvhld2ZTKa', 'answerText'] + }, + { + key: 'codeType', + renderTypeList: ['hidden'], + label: '', + value: 'js' + }, + { + key: 'code', + renderTypeList: ['custom'], + label: '', + value: + 'function main({data1}){\n const result = data1.split("```").filter(item => !!item.trim())\n\n if(result[result.length-1]) {\n return {\n result: result[result.length-1]\n }\n }\n\n return {\n result: \'未截取到翻译内容\'\n }\n}' + } + ], + outputs: [ + { + id: 'system_addOutputParam', + key: 'system_addOutputParam', + type: 'dynamic', + valueType: 'dynamic', + label: '', + editField: { + key: true, + valueType: true + }, + description: '将代码中 return 的对象作为输出,传递给后续的节点' + }, + { + id: 'system_rawResponse', + key: 'system_rawResponse', + label: '完整响应数据', + valueType: 'object', + type: 'static' + }, + { + id: 'error', + key: 'error', + label: '运行错误', + description: '代码运行错误信息,成功时返回空', + valueType: 'object', + type: 'static' + }, + { + id: 'qLUQfhG0ILRX', + type: 'dynamic', + key: 'result', + valueType: 'string', + label: 'result' + } + ] + }, + { + nodeId: 'foO69L5FOmDQ', + name: '指定回复', + intro: + '该模块可以直接回复一段指定的内容。常用于引导、提示。非字符串内容传入时,会转成字符串进行输出。', + avatar: '/imgs/workflow/reply.png', + flowNodeType: 'answerNode', + position: { + x: 3798.4479531204515, + y: 116.03040242110023 + }, + version: '481', + inputs: [ + { + key: 'text', + renderTypeList: ['textarea', 'reference'], + valueType: 'any', + required: true, + label: 'core.module.input.label.Response content', + description: 'core.module.input.description.Response content', + placeholder: 'core.module.input.description.Response content', + selectedTypeIndex: 1, + value: ['v9ijHqeA2NY2', 'text'] + } + ], + outputs: [] + }, + { + nodeId: 'v9ijHqeA2NY2', + name: '合并输出结果', + intro: '可对固定或传入的文本进行加工后输出,非字符串类型数据最终会转成字符串类型。', + avatar: '/imgs/workflow/textEditor.svg', + flowNodeType: 'pluginModule', + showStatus: false, + position: { + x: 3083.567683275386, + y: 60.05513835086097 + }, + version: '481', + inputs: [ + { + key: 'system_addInputParam', + valueType: 'dynamic', + label: '动态外部数据', + renderTypeList: ['addInputParam'], + required: false, + description: '', + canEdit: false, + value: '', + editField: { + key: true + }, + dynamicParamDefaultValue: { + inputType: 'reference', + valueType: 'string', + required: true + } + }, + { + key: 'result', + valueType: 'string', + label: 'result', + renderTypeList: ['reference'], + required: true, + description: '', + canEdit: true, + editField: { + key: true + }, + value: ['w0oBbQ3YJHye', 'qLUQfhG0ILRX'] + }, + { + key: '文本', + valueType: 'string', + label: '文本', + renderTypeList: ['textarea'], + required: true, + description: '', + canEdit: false, + value: '------\n\n最终翻译结果如下: \n\n```\n{{result}}\n```', + editField: { + key: true + }, + maxLength: '', + dynamicParamDefaultValue: { + inputType: 'reference', + valueType: 'string', + required: true + } + } + ], + outputs: [ + { + id: 'text', + type: 'static', + key: 'text', + valueType: 'string', + label: 'text', + description: '' + } + ], + pluginId: 'community-textEditor' + } + ], + edges: [ + { + source: '448745', + target: 'k2QsBOBmH9Xu', + sourceHandle: '448745-source-right', + targetHandle: 'k2QsBOBmH9Xu-target-left' + }, + { + source: 'k2QsBOBmH9Xu', + target: 'loOvhld2ZTKa', + sourceHandle: 'k2QsBOBmH9Xu-source-right', + targetHandle: 'loOvhld2ZTKa-target-left' + }, + { + source: 'loOvhld2ZTKa', + target: 'w0oBbQ3YJHye', + sourceHandle: 'loOvhld2ZTKa-source-right', + targetHandle: 'w0oBbQ3YJHye-target-left' + }, + { + source: 'w0oBbQ3YJHye', + target: 'v9ijHqeA2NY2', + sourceHandle: 'w0oBbQ3YJHye-source-right', + targetHandle: 'v9ijHqeA2NY2-target-left' + }, + { + source: 'v9ijHqeA2NY2', + target: 'foO69L5FOmDQ', + sourceHandle: 'v9ijHqeA2NY2-source-right', + targetHandle: 'foO69L5FOmDQ-target-left' + } + ] + }, + { + id: 'google', + avatar: '/imgs/app/templates/google.svg', + name: '谷歌搜索', + intro: '通过请求谷歌搜索,查询相关内容作为模型的参考。', + type: AppTypeEnum.workflow, + modules: [ + { + nodeId: 'userGuide', + name: '系统配置', + intro: '可以配置应用的系统参数', + avatar: '/imgs/workflow/userGuide.png', + flowNodeType: 'userGuide', + position: { + x: 262.2732338817093, + y: -476.00241136598146 + }, + version: '481', + inputs: [ + { + key: 'welcomeText', + renderTypeList: ['hidden'], + valueType: 'string', + label: 'core.app.Welcome Text', + value: '' + }, + { + key: 'variables', + renderTypeList: ['hidden'], + valueType: 'any', + label: 'core.app.Chat Variable', + value: [] + }, + { + key: 'questionGuide', + valueType: 'boolean', + renderTypeList: ['hidden'], + label: 'core.app.Question Guide', + value: false + }, + { + key: 'tts', + renderTypeList: ['hidden'], + valueType: 'any', + label: '', + value: { + type: 'web' + } + }, + { + key: 'whisper', + renderTypeList: ['hidden'], + valueType: 'any', + label: '', + value: { + open: false, + autoSend: false, + autoTTSResponse: false + } + }, + { + key: 'scheduleTrigger', + renderTypeList: ['hidden'], + valueType: 'any', + label: '', + value: null + } + ], + outputs: [] + }, + { + nodeId: '448745', + name: '流程开始', + intro: '', + avatar: '/imgs/workflow/userChatInput.svg', + flowNodeType: 'workflowStart', + position: { + x: 295.8944548701009, + y: 110.81336038514848 + }, + version: '481', + inputs: [ + { + key: 'userChatInput', + renderTypeList: ['reference', 'textarea'], + valueType: 'string', + label: '用户问题', + required: true, + toolDescription: '用户问题' + } + ], + outputs: [ + { + id: 'userChatInput', + key: 'userChatInput', + label: 'core.module.input.label.user question', + valueType: 'string', + type: 'static' + } + ] + }, + { + nodeId: 'NOgbnBzUwDgT', + name: '工具调用(实验)', + intro: '通过AI模型自动选择一个或多个功能块进行调用,也可以对插件进行调用。', + avatar: '/imgs/workflow/tool.svg', + flowNodeType: 'tools', + showStatus: true, + position: { + x: 1028.8358722416106, + y: -500.8755882990822 + }, + version: '481', + inputs: [ + { + key: 'model', + renderTypeList: ['settingLLMModel', 'reference'], + label: 'core.module.input.label.aiModel', + valueType: 'string', + llmModelType: 'all', + value: 'FastAI-plus' + }, + { + key: 'temperature', + renderTypeList: ['hidden'], + label: '', + value: 0, + valueType: 'number', + min: 0, + max: 10, + step: 1 + }, + { + key: 'maxToken', + renderTypeList: ['hidden'], + label: '', + value: 2000, + valueType: 'number', + min: 100, + max: 4000, + step: 50 + }, + { + key: 'systemPrompt', + renderTypeList: ['textarea', 'reference'], + max: 3000, + valueType: 'string', + label: 'core.ai.Prompt', + description: 'core.app.tip.chatNodeSystemPromptTip', + placeholder: 'core.app.tip.chatNodeSystemPromptTip', + value: '' + }, + { + key: 'history', + renderTypeList: ['numberInput', 'reference'], + valueType: 'chatHistory', + label: 'core.module.input.label.chat history', + description: '最多携带多少轮对话记录', + required: true, + min: 0, + max: 30, + value: 6 + }, + { + key: 'userChatInput', + renderTypeList: ['reference', 'textarea'], + valueType: 'string', + label: '用户问题', + required: true, + value: ['448745', 'userChatInput'] + } + ], + outputs: [ + { + id: NodeOutputKeyEnum.answerText, + key: NodeOutputKeyEnum.answerText, + label: 'core.module.output.label.Ai response content', + description: 'core.module.output.description.Ai response content', + valueType: WorkflowIOValueTypeEnum.string, + type: FlowNodeOutputTypeEnum.static + } + ] + }, + { + nodeId: 'GMELVPxHfpg5', + name: 'HTTP 请求', + intro: '调用谷歌搜索,查询相关内容', + avatar: '/imgs/workflow/http.png', + flowNodeType: 'httpRequest468', + showStatus: true, + position: { + x: 1005.4777753640342, + y: 319.4905539380939 + }, + version: '481', + inputs: [ + { + key: 'system_addInputParam', + renderTypeList: ['addInputParam'], + valueType: 'dynamic', + label: '', + required: false, + description: 'core.module.input.description.HTTP Dynamic Input', + editField: { + key: true, + valueType: true + } + }, + { + valueType: 'string', + renderTypeList: ['reference'], + key: 'query', + label: 'query', + toolDescription: '谷歌搜索检索词', + required: true, + canEdit: true, + editField: { + key: true, + description: true + } + }, + { + key: 'system_httpMethod', + renderTypeList: ['custom'], + valueType: 'string', + label: '', + value: 'GET', + required: true + }, + { + key: 'system_httpReqUrl', + renderTypeList: ['hidden'], + valueType: 'string', + label: '', + description: 'core.module.input.description.Http Request Url', + placeholder: 'https://api.ai.com/getInventory', + required: false, + value: 'https://www.googleapis.com/customsearch/v1' + }, + { + key: 'system_httpHeader', + renderTypeList: ['custom'], + valueType: 'any', + value: [], + label: '', + description: 'core.module.input.description.Http Request Header', + placeholder: 'core.module.input.description.Http Request Header', + required: false + }, + { + key: 'system_httpParams', + renderTypeList: ['hidden'], + valueType: 'any', + value: [ + { + key: 'q', + type: 'string', + value: '{{query}}' + }, + { + key: 'cx', + type: 'string', + value: '谷歌搜索cxID' + }, + { + key: 'key', + type: 'string', + value: '谷歌搜索key' + }, + { + key: 'c2coff', + type: 'string', + value: '1' + }, + { + key: 'start', + type: 'string', + value: '1' + }, + { + key: 'end', + type: 'string', + value: '20' + }, + { + key: 'dateRestrict', + type: 'string', + value: 'm[1]' + } + ], + label: '', + required: false + }, + { + key: 'system_httpJsonBody', + renderTypeList: ['hidden'], + valueType: 'any', + value: '', + label: '', + required: false + } + ], + outputs: [ + { + id: 'system_addOutputParam', + key: 'system_addOutputParam', + type: 'dynamic', + valueType: 'dynamic', + label: '', + editField: { + key: true, + valueType: true + } + }, + { + id: 'httpRawResponse', + key: 'httpRawResponse', + label: '原始响应', + description: 'HTTP请求的原始响应。只能接受字符串或JSON类型响应数据。', + valueType: 'any', + type: 'static', + required: true + }, + { + id: 'M5YmxaYe8em1', + type: 'dynamic', + key: 'prompt', + valueType: 'string', + label: 'prompt' + } + ] + }, + { + nodeId: 'poIbrrA8aiR0', + name: '代码运行', + intro: '执行一段简单的脚本代码,通常用于进行复杂的数据处理。', + avatar: '/imgs/workflow/code.svg', + flowNodeType: 'code', + showStatus: true, + position: { + x: 1711.805344753384, + y: 650.1023414708576 + }, + version: '482', + inputs: [ + { + key: 'system_addInputParam', + renderTypeList: ['addInputParam'], + valueType: 'dynamic', + label: '', + required: false, + description: '这些变量会作为代码的运行的输入参数', + editField: { + key: true, + valueType: true + } + }, + { + key: 'data', + valueType: 'object', + label: 'data', + renderTypeList: ['reference'], + description: '', + canEdit: true, + editField: { + key: true, + valueType: true + }, + value: ['GMELVPxHfpg5', 'httpRawResponse'] + }, + { + key: 'codeType', + renderTypeList: ['hidden'], + label: '', + value: 'js' + }, + { + key: 'code', + renderTypeList: ['custom'], + label: '', + value: + 'function main({data}){\n const result = data.items.map((item) => ({\n title: item.title,\n link: item.link,\n snippet: item.snippet\n }))\n return { prompt: JSON.stringify(result) }\n}' + } + ], + outputs: [ + { + id: 'system_addOutputParam', + key: 'system_addOutputParam', + type: 'dynamic', + valueType: 'dynamic', + label: '', + editField: { + key: true, + valueType: true + }, + description: '将代码中 return 的对象作为输出,传递给后续的节点' + }, + { + id: 'system_rawResponse', + key: 'system_rawResponse', + label: '完整响应数据', + valueType: 'object', + type: 'static' + }, + { + id: 'error', + key: 'error', + label: '运行错误', + description: '代码运行错误信息,成功时返回空', + valueType: 'object', + type: 'static' + }, + { + id: 'qLUQfhG0ILRX', + type: 'dynamic', + key: 'prompt', + valueType: 'string', + label: 'prompt' + } + ] + } + ], + edges: [ + { + source: '448745', + target: 'NOgbnBzUwDgT', + sourceHandle: '448745-source-right', + targetHandle: 'NOgbnBzUwDgT-target-left' + }, + { + source: 'NOgbnBzUwDgT', + target: 'GMELVPxHfpg5', + sourceHandle: 'selectedTools', + targetHandle: 'selectedTools' + }, + { + source: 'GMELVPxHfpg5', + target: 'poIbrrA8aiR0', + sourceHandle: 'GMELVPxHfpg5-source-right', + targetHandle: 'poIbrrA8aiR0-target-left' + } + ] + }, + { + id: 'dalle', + avatar: '/imgs/app/templates/dalle.svg', + name: 'Dalle3绘图', + intro: '通过请求Dalle3接口绘图,需要有 api key', + type: AppTypeEnum.workflow, + modules: [ + { + nodeId: 'userGuide', + name: '系统配置', + intro: '可以配置应用的系统参数', + avatar: '/imgs/workflow/userGuide.png', + flowNodeType: 'userGuide', + position: { + x: 531.2422736065552, + y: -486.7611729549753 + }, + inputs: [ + { + key: 'welcomeText', + renderTypeList: ['hidden'], + valueType: 'string', + label: 'core.app.Welcome Text', + value: '' + }, + { + key: 'variables', + renderTypeList: ['hidden'], + valueType: 'any', + label: 'core.app.Chat Variable', + value: [] + }, + { + key: 'questionGuide', + valueType: 'boolean', + renderTypeList: ['hidden'], + label: 'core.app.Question Guide', + value: false + }, + { + key: 'tts', + renderTypeList: ['hidden'], + valueType: 'any', + label: '', + value: { + type: 'web' + } + }, + { + key: 'whisper', + renderTypeList: ['hidden'], + valueType: 'any', + label: '', + value: { + open: false, + autoSend: false, + autoTTSResponse: false + } + }, + { + key: 'scheduleTrigger', + renderTypeList: ['hidden'], + valueType: 'any', + label: '', + value: null + } + ], + outputs: [] + }, + { + nodeId: '448745', + name: '流程开始', + intro: '', + avatar: '/imgs/workflow/userChatInput.svg', + flowNodeType: 'workflowStart', + position: { + x: 532.1275542407774, + y: 46.03775600322817 + }, + inputs: [ + { + key: 'userChatInput', + renderTypeList: ['reference', 'textarea'], + valueType: 'string', + label: '用户问题', + required: true, + toolDescription: '用户问题' + } + ], + outputs: [ + { + id: 'userChatInput', + key: 'userChatInput', + label: 'core.module.input.label.user question', + valueType: 'string', + type: 'static' + } + ] + }, + { + nodeId: 'tMyUnRL5jIrC', + name: 'HTTP 请求', + intro: '可以发出一个 HTTP 请求,实现更为复杂的操作(联网搜索、数据库查询等)', + avatar: '/imgs/workflow/http.png', + flowNodeType: 'httpRequest468', + showStatus: true, + position: { + x: 921.2377506442713, + y: -483.94114977914256 + }, + inputs: [ + { + key: 'system_addInputParam', + renderTypeList: ['addInputParam'], + valueType: 'dynamic', + label: '', + required: false, + description: 'core.module.input.description.HTTP Dynamic Input', + editField: { + key: true, + valueType: true + } + }, + { + key: 'prompt', + valueType: 'string', + label: 'prompt', + renderTypeList: ['reference'], + description: '', + canEdit: true, + editField: { + key: true, + valueType: true + }, + value: ['448745', 'userChatInput'] + }, + { + key: 'system_httpMethod', + renderTypeList: ['custom'], + valueType: 'string', + label: '', + value: 'POST', + required: true + }, + { + key: 'system_httpReqUrl', + renderTypeList: ['hidden'], + valueType: 'string', + label: '', + description: 'core.module.input.description.Http Request Url', + placeholder: 'https://api.ai.com/getInventory', + required: false, + value: 'https://api.openai.com/v1/images/generations' + }, + { + key: 'system_httpHeader', + renderTypeList: ['custom'], + valueType: 'any', + value: [ + { + key: 'Authorization', + type: 'string', + value: 'Bearer ' + } + ], + label: '', + description: 'core.module.input.description.Http Request Header', + placeholder: 'core.module.input.description.Http Request Header', + required: false + }, + { + key: 'system_httpParams', + renderTypeList: ['hidden'], + valueType: 'any', + value: [], + label: '', + required: false + }, + { + key: 'system_httpJsonBody', + renderTypeList: ['hidden'], + valueType: 'any', + value: + '{\n "model": "dall-e-3",\n "prompt": "{{prompt}}",\n "n": 1,\n "size": "1024x1024"\n}', + label: '', + required: false + } + ], + outputs: [ + { + id: 'system_addOutputParam', + key: 'system_addOutputParam', + type: 'dynamic', + valueType: 'dynamic', + label: '', + editField: { + key: true, + valueType: true + } + }, + { + id: 'httpRawResponse', + key: 'httpRawResponse', + label: '原始响应', + description: 'HTTP请求的原始响应。只能接受字符串或JSON类型响应数据。', + valueType: 'any', + type: 'static' + }, + { + id: 'DeKGGioBwaMf', + type: 'dynamic', + key: 'data[0].url', + valueType: 'string', + label: 'data[0].url' + } + ] + }, + { + nodeId: 'CO3POL8svbbi', + name: '文本加工', + intro: '可对固定或传入的文本进行加工后输出,非字符串类型数据最终会转成字符串类型。', + avatar: '/imgs/workflow/textEditor.svg', + flowNodeType: 'pluginModule', + showStatus: false, + position: { + x: 1417.5940290051137, + y: -478.81889618104356 + }, + inputs: [ + { + key: 'system_addInputParam', + valueType: 'dynamic', + label: '动态外部数据', + renderTypeList: ['addInputParam'], + required: false, + description: '', + canEdit: false, + value: '', + editField: { + key: true + }, + dynamicParamDefaultValue: { + inputType: 'reference', + valueType: 'string', + required: true + } + }, + { + key: 'url', + valueType: 'string', + label: 'url', + renderTypeList: ['reference'], + required: true, + description: '', + canEdit: true, + editField: { + key: true + }, + value: ['tMyUnRL5jIrC', 'DeKGGioBwaMf'] + }, + { + key: '文本', + valueType: 'string', + label: '文本', + renderTypeList: ['textarea'], + required: true, + description: '', + canEdit: false, + value: '![]({{url}})', + editField: { + key: true + }, + maxLength: '', + dynamicParamDefaultValue: { + inputType: 'reference', + valueType: 'string', + required: true + } + } + ], + outputs: [ + { + id: 'text', + type: 'static', + key: 'text', + valueType: 'string', + label: 'text', + description: '' + } + ], + pluginId: 'community-textEditor' + }, + { + nodeId: '7mapnCgHfKW6', + name: '指定回复', + intro: + '该模块可以直接回复一段指定的内容。常用于引导、提示。非字符串内容传入时,会转成字符串进行输出。', + avatar: '/imgs/workflow/reply.png', + flowNodeType: 'answerNode', + position: { + x: 1922.5628399315042, + y: -471.67391598231796 + }, + inputs: [ + { + key: 'text', + renderTypeList: ['textarea', 'reference'], + valueType: 'string', + label: 'core.module.input.label.Response content', + description: 'core.module.input.description.Response content', + placeholder: 'core.module.input.description.Response content', + selectedTypeIndex: 1, + value: ['CO3POL8svbbi', 'text'] + } + ], + outputs: [] + } + ], + edges: [ + { + source: '448745', + target: 'tMyUnRL5jIrC', + sourceHandle: '448745-source-right', + targetHandle: 'tMyUnRL5jIrC-target-left' + }, + { + source: 'tMyUnRL5jIrC', + target: 'CO3POL8svbbi', + sourceHandle: 'tMyUnRL5jIrC-source-right', + targetHandle: 'CO3POL8svbbi-target-left' + }, + { + source: 'CO3POL8svbbi', + target: '7mapnCgHfKW6', + sourceHandle: 'CO3POL8svbbi-source-right', + targetHandle: '7mapnCgHfKW6-target-left' + } + ] + }, + { + id: 'CQ', + avatar: '/imgs/workflow/cq.png', + name: '问题分类 + 知识库', + intro: '先对用户的问题进行分类,再根据不同类型问题,执行不同的操作', + type: AppTypeEnum.workflow, + modules: [ + { + nodeId: 'userGuide', + name: '系统配置', + intro: '可以配置应用的系统参数', + avatar: '/imgs/workflow/userGuide.png', + flowNodeType: FlowNodeTypeEnum.systemConfig, + position: { + x: 531.2422736065552, + y: -486.7611729549753 + }, + version: '481', + inputs: [ + { + key: 'welcomeText', + renderTypeList: [FlowNodeInputTypeEnum.hidden], + valueType: WorkflowIOValueTypeEnum.string, + label: 'core.app.Welcome Text', + value: '你好,我是知识库助手,请不要忘记选择知识库噢~\n[你是谁]\n[如何使用]' + }, + { + key: 'variables', + renderTypeList: [FlowNodeInputTypeEnum.hidden], + valueType: WorkflowIOValueTypeEnum.any, + label: 'core.app.Chat Variable', + value: [] + }, + { + key: 'questionGuide', + valueType: WorkflowIOValueTypeEnum.boolean, + renderTypeList: [FlowNodeInputTypeEnum.hidden], + label: 'core.app.Question Guide', + value: true + }, + { + key: 'tts', + renderTypeList: [FlowNodeInputTypeEnum.hidden], + valueType: WorkflowIOValueTypeEnum.any, + label: '', + value: { + type: 'web' + } + }, + { + key: 'whisper', + renderTypeList: [FlowNodeInputTypeEnum.hidden], + valueType: WorkflowIOValueTypeEnum.any, + label: '', + value: { + open: false, + autoSend: false, + autoTTSResponse: false + } + }, + { + key: 'scheduleTrigger', + renderTypeList: [FlowNodeInputTypeEnum.hidden], + valueType: WorkflowIOValueTypeEnum.any, + label: '', + value: null + } + ], + outputs: [] + }, + { + nodeId: 'workflowStartNodeId', + name: '流程开始', + intro: '', + avatar: '/imgs/workflow/userChatInput.svg', + flowNodeType: FlowNodeTypeEnum.workflowStart, + position: { + x: 558.4082376415505, + y: 123.72387429194112 + }, + version: '481', + inputs: [ + { + key: 'userChatInput', + renderTypeList: [FlowNodeInputTypeEnum.reference, FlowNodeInputTypeEnum.textarea], + valueType: WorkflowIOValueTypeEnum.string, + label: '用户问题', + required: true, + toolDescription: '用户问题' + } + ], + outputs: [ + { + id: 'userChatInput', + key: 'userChatInput', + label: 'core.module.input.label.user question', + valueType: WorkflowIOValueTypeEnum.string, + type: FlowNodeOutputTypeEnum.static + } + ] + }, + { + nodeId: '7BdojPlukIQw', + name: 'AI 对话', + intro: 'AI 大模型对话', + avatar: '/imgs/workflow/AI.png', + flowNodeType: FlowNodeTypeEnum.chatNode, + showStatus: true, + position: { + x: 2701.1267277679685, + y: -767.8956312653042 + }, + version: '481', + inputs: [ + { + key: 'model', + renderTypeList: [ + FlowNodeInputTypeEnum.settingLLMModel, + FlowNodeInputTypeEnum.reference + ], + label: 'core.module.input.label.aiModel', + valueType: WorkflowIOValueTypeEnum.string, + value: 'gpt-3.5-turbo' + }, + { + key: 'temperature', + renderTypeList: [FlowNodeInputTypeEnum.hidden], + label: '', + value: 3, + valueType: WorkflowIOValueTypeEnum.number, + min: 0, + max: 10, + step: 1 + }, + { + key: 'maxToken', + renderTypeList: [FlowNodeInputTypeEnum.hidden], + label: '', + value: 1950, + valueType: WorkflowIOValueTypeEnum.number, + min: 100, + max: 4000, + step: 50 + }, + { + key: 'isResponseAnswerText', + renderTypeList: [FlowNodeInputTypeEnum.hidden], + label: '', + value: true, + valueType: WorkflowIOValueTypeEnum.boolean + }, + { + key: 'quoteTemplate', + renderTypeList: [FlowNodeInputTypeEnum.hidden], + label: '', + valueType: WorkflowIOValueTypeEnum.string + }, + { + key: 'quotePrompt', + renderTypeList: [FlowNodeInputTypeEnum.hidden], + label: '', + valueType: WorkflowIOValueTypeEnum.string + }, + { + key: 'systemPrompt', + renderTypeList: [FlowNodeInputTypeEnum.textarea, FlowNodeInputTypeEnum.reference], + max: 3000, + valueType: WorkflowIOValueTypeEnum.string, + label: 'core.ai.Prompt', + description: 'core.app.tip.chatNodeSystemPromptTip', + placeholder: 'core.app.tip.chatNodeSystemPromptTip', + value: '' + }, + { + key: 'history', + renderTypeList: [FlowNodeInputTypeEnum.numberInput, FlowNodeInputTypeEnum.reference], + valueType: WorkflowIOValueTypeEnum.chatHistory, + label: 'core.module.input.label.chat history', + required: true, + min: 0, + max: 30, + value: 6 + }, + { + key: 'userChatInput', + renderTypeList: [FlowNodeInputTypeEnum.reference, FlowNodeInputTypeEnum.textarea], + valueType: WorkflowIOValueTypeEnum.string, + label: '用户问题', + required: true, + toolDescription: '用户问题', + value: ['workflowStartNodeId', 'userChatInput'] + }, + { + key: 'quoteQA', + renderTypeList: [FlowNodeInputTypeEnum.settingDatasetQuotePrompt], + label: '', + debugLabel: '知识库引用', + description: '', + valueType: WorkflowIOValueTypeEnum.datasetQuote, + value: ['MNMMMIjjWyMU', 'quoteQA'] + } + ], + outputs: [ + { + id: 'history', + key: 'history', + label: 'core.module.output.label.New context', + description: 'core.module.output.description.New context', + valueType: WorkflowIOValueTypeEnum.chatHistory, + type: FlowNodeOutputTypeEnum.static + }, + { + id: 'answerText', + key: 'answerText', + label: 'core.module.output.label.Ai response content', + description: 'core.module.output.description.Ai response content', + valueType: WorkflowIOValueTypeEnum.string, + type: FlowNodeOutputTypeEnum.static + } + ] + }, + { + nodeId: 'rvbo634w3AYj', + name: '问题分类', + intro: + '根据用户的历史记录和当前问题判断该次提问的类型。可以添加多组问题类型,下面是一个模板例子:\n类型1: 打招呼\n类型2: 关于商品“使用”问题\n类型3: 关于商品“购买”问题\n类型4: 其他问题', + avatar: '/imgs/workflow/cq.png', + flowNodeType: FlowNodeTypeEnum.classifyQuestion, + showStatus: true, + position: { + x: 1020.9667229609946, + y: -385.0060974413916 + }, + version: '481', + inputs: [ + { + key: 'model', + renderTypeList: [FlowNodeInputTypeEnum.selectLLMModel, FlowNodeInputTypeEnum.reference], + label: 'core.module.input.label.aiModel', + required: true, + valueType: WorkflowIOValueTypeEnum.string, + llmModelType: 'classify', + value: 'gpt-3.5-turbo' + }, + { + key: 'systemPrompt', + renderTypeList: [FlowNodeInputTypeEnum.textarea, FlowNodeInputTypeEnum.reference], + max: 3000, + valueType: WorkflowIOValueTypeEnum.string, + label: 'core.module.input.label.Background', + description: 'core.module.input.description.Background', + placeholder: 'core.module.input.placeholder.Classify background', + value: '' + }, + { + key: 'history', + renderTypeList: [FlowNodeInputTypeEnum.numberInput, FlowNodeInputTypeEnum.reference], + valueType: WorkflowIOValueTypeEnum.chatHistory, + label: 'core.module.input.label.chat history', + required: true, + min: 0, + max: 30, + value: 6 + }, + { + key: 'userChatInput', + renderTypeList: [FlowNodeInputTypeEnum.reference, FlowNodeInputTypeEnum.textarea], + valueType: WorkflowIOValueTypeEnum.string, + label: '用户问题', + required: true, + value: ['workflowStartNodeId', 'userChatInput'] + }, + { + key: 'agents', + renderTypeList: [FlowNodeInputTypeEnum.custom], + valueType: WorkflowIOValueTypeEnum.any, + label: '', + value: [ + { + value: '关于电影《星际穿越》的问题', + key: 'wqre' + }, { value: '打招呼、问候等问题', key: 'sdfa' @@ -1317,6 +2809,242 @@ export const pluginTemplates: TemplateType = [ } ], edges: [] + }, + { + id: 'plugin-feishu', + avatar: '/imgs/app/templates/feishu.svg', + name: '飞书webhook插件', + intro: '通过 webhook 给飞书机器人发送一条消息', + type: AppTypeEnum.plugin, + modules: [ + { + nodeId: 'pluginInput', + name: '自定义插件输入', + intro: '自定义配置外部输入,使用插件时,仅暴露自定义配置的输入', + avatar: '/imgs/workflow/input.png', + flowNodeType: 'pluginInput', + showStatus: false, + position: { + x: 517.5620777851774, + y: -173.55711888178655 + }, + version: '481', + inputs: [ + { + inputType: 'input', + valueType: 'string', + key: '飞书机器人地址', + label: '飞书机器人地址', + description: '', + isToolInput: false, + defaultValue: '', + editField: { + key: true + }, + dynamicParamDefaultValue: { + inputType: 'reference', + valueType: 'string', + required: true + }, + renderTypeList: ['input'], + required: true, + canEdit: true, + value: '' + }, + { + key: '发送的消息', + valueType: 'string', + label: '发送的消息', + renderTypeList: ['reference'], + required: true, + description: '', + canEdit: true, + value: '', + editField: { + key: true + }, + dynamicParamDefaultValue: { + inputType: 'reference', + valueType: 'string', + required: true + } + } + ], + outputs: [ + { + id: 'mv52BrPVE6bm', + key: '飞书机器人地址', + valueType: 'string', + label: '飞书机器人地址', + type: 'static' + }, + { + id: 'p0m68Dv5KaIp', + key: '发送的消息', + valueType: 'string', + label: '发送的消息', + type: 'static' + } + ] + }, + { + nodeId: 'pluginOutput', + name: '自定义插件输出', + intro: '自定义配置外部输出,使用插件时,仅暴露自定义配置的输出', + avatar: '/imgs/workflow/output.png', + flowNodeType: 'pluginOutput', + showStatus: false, + position: { + x: 1668.9410524554828, + y: -153.47815316221283 + }, + version: '481', + inputs: [], + outputs: [] + }, + { + nodeId: 'rKBYGQuYefae', + name: 'HTTP 请求', + intro: '可以发出一个 HTTP 请求,实现更为复杂的操作(联网搜索、数据库查询等)', + avatar: '/imgs/workflow/http.png', + flowNodeType: 'httpRequest468', + showStatus: true, + position: { + x: 1069.7228495148624, + y: -392.26482361861054 + }, + version: '481', + inputs: [ + { + key: 'system_addInputParam', + renderTypeList: ['addInputParam'], + valueType: 'dynamic', + label: '', + required: false, + description: 'core.module.input.description.HTTP Dynamic Input', + editField: { + key: true, + valueType: true + } + }, + { + key: 'text', + valueType: 'string', + label: 'text', + renderTypeList: ['reference'], + description: '', + canEdit: true, + editField: { + key: true, + valueType: true + }, + value: ['pluginInput', 'p0m68Dv5KaIp'] + }, + { + key: 'url', + valueType: 'string', + label: 'url', + renderTypeList: ['reference'], + description: '', + canEdit: true, + editField: { + key: true, + valueType: true + }, + value: ['pluginInput', 'mv52BrPVE6bm'] + }, + { + key: 'system_httpMethod', + renderTypeList: ['custom'], + valueType: 'string', + label: '', + value: 'POST', + required: true + }, + { + key: 'system_httpReqUrl', + renderTypeList: ['hidden'], + valueType: 'string', + label: '', + description: 'core.module.input.description.Http Request Url', + placeholder: 'https://api.ai.com/getInventory', + required: false, + value: '{{url}}' + }, + { + key: 'system_httpHeader', + renderTypeList: ['custom'], + valueType: 'any', + value: [], + label: '', + description: 'core.module.input.description.Http Request Header', + placeholder: 'core.module.input.description.Http Request Header', + required: false + }, + { + key: 'system_httpParams', + renderTypeList: ['hidden'], + valueType: 'any', + value: [], + label: '', + required: false + }, + { + key: 'system_httpJsonBody', + renderTypeList: ['hidden'], + valueType: 'any', + value: + '{\r\n "msg_type": "text",\r\n "content": {\r\n "text": "{{text}}"\r\n }\r\n}', + label: '', + required: false + } + ], + outputs: [ + { + id: 'system_addOutputParam', + key: 'system_addOutputParam', + type: 'dynamic', + valueType: 'dynamic', + label: '', + editField: { + key: true, + valueType: true + } + }, + { + id: 'error', + key: 'error', + label: '请求错误', + description: 'HTTP请求错误信息,成功时返回空', + valueType: 'object', + type: 'static' + }, + { + id: 'httpRawResponse', + key: 'httpRawResponse', + label: '原始响应', + required: true, + description: 'HTTP请求的原始响应。只能接受字符串或JSON类型响应数据。', + valueType: 'any', + type: 'static' + } + ] + } + ], + edges: [ + { + source: 'pluginInput', + target: 'rKBYGQuYefae', + sourceHandle: 'pluginInput-source-right', + targetHandle: 'rKBYGQuYefae-target-left' + }, + { + source: 'rKBYGQuYefae', + target: 'pluginOutput', + sourceHandle: 'rKBYGQuYefae-source-right', + targetHandle: 'pluginOutput-target-left' + } + ] } ];