From 219693000532b7687d44a4842726b3aff21668c7 Mon Sep 17 00:00:00 2001 From: Archer <545436317@qq.com> Date: Mon, 12 Aug 2024 16:21:21 +0800 Subject: [PATCH] App template market (#2337) * feat: add app template market (#2012) * feat: add app template market * fix * fix * i18n * fix * perf: template market ux * perf: simple mode app ui * perf: tempalte modal ui * perf: tempalte market ui * perf: template position * feat: create app modal * regiter default app * perf: icon * change templates position (#2331) * change templates position * fix * perf: template market ux --------- Co-authored-by: heheer --- .../global/common/system/types/index.d.ts | 1 + packages/global/core/app/constants.ts | 9 + packages/global/core/workflow/type/index.d.ts | 15 +- packages/service/type.d.ts | 2 + .../web/components/common/Icon/constants.ts | 1 + .../common/Icon/icons/common/searchLight.svg | 9 +- .../Icon/icons/common/upRightArrowLight.svg | 3 + .../common/Input/SearchInput/index.tsx | 14 + .../web/components/common/MyMenu/index.tsx | 4 +- .../web/components/common/MyModal/index.tsx | 1 - .../common/Textarea/PromptEditor/Editor.tsx | 5 +- .../Textarea/PromptEditor/index.module.scss | 4 +- .../common/Textarea/PromptEditor/index.tsx | 7 +- packages/web/i18n/en/app.json | 22 +- packages/web/i18n/en/common.json | 4 +- packages/web/i18n/zh/app.json | 24 +- packages/web/i18n/zh/common.json | 15 +- .../data/pluginTemplates/customFeedback.json | 2 +- .../data/pluginTemplates/getCurrentTime.json | 2 +- .../app/data/pluginTemplates/textEditor.json | 2 +- .../pluginTemplates/v1/customFeedback.json | 2 +- .../pluginTemplates/v1/getCurrentTime.json | 2 +- .../data/pluginTemplates/v1/textEditor.json | 2 +- .../app/data/pluginTemplates/v1/tfSwitch.json | 2 +- .../appMarketTemplates/CQ/template.json | 467 +++ .../TranslateRobot/avatar.svg} | 0 .../TranslateRobot/template.json | 579 ++++ .../chatGuide/template.json | 262 ++ .../flux/avatar.svg} | 0 .../appMarketTemplates/flux/template.json | 270 ++ .../google/avatar.svg} | 0 .../appMarketTemplates/google/template.json | 441 +++ .../plugin-dalle/avatar.svg | 6 + .../plugin-dalle/template.json | 270 ++ .../plugin-feishu/avatar.svg} | 0 .../plugin-feishu/template.json | 234 ++ .../simpleDatasetChat/template.json | 337 ++ .../srt-translate/template.json | 1928 +++++++++++ .../appMarketTemplates/timeBot/template.json | 186 + projects/app/public/imgs/app/templateFill.svg | 41 + .../app/public/imgs/app/templates/dalle.svg | 1 - .../core/ai/SettingLLMModel/index.tsx | 9 +- .../components/core/app/WelcomeTextConfig.tsx | 1 + projects/app/src/pages/api/core/app/create.ts | 10 +- .../src/pages/api/core/app/template/detail.ts | 21 + .../src/pages/api/core/app/template/list.ts | 16 + .../app/detail/components/SimpleApp/Edit.tsx | 1 - .../detail/components/SimpleApp/EditForm.tsx | 4 +- .../detail/components/SimpleApp/Header.tsx | 1 - .../pages/app/list/components/CreateModal.tsx | 233 +- .../list/components/TemplateMarketModal.tsx | 452 +++ .../src/pages/app/list/components/TypeTag.tsx | 2 +- projects/app/src/pages/app/list/index.tsx | 48 +- .../pages/login/components/RegisterForm.tsx | 15 +- .../app/src/service/common/system/index.ts | 2 + projects/app/src/service/core/app/template.ts | 48 + projects/app/src/web/core/app/api/template.ts | 11 + projects/app/src/web/core/app/templates.ts | 3049 +---------------- 58 files changed, 5934 insertions(+), 3165 deletions(-) create mode 100644 packages/web/components/common/Icon/icons/common/upRightArrowLight.svg create mode 100644 packages/web/components/common/Input/SearchInput/index.tsx create mode 100644 projects/app/public/appMarketTemplates/CQ/template.json rename projects/app/public/{imgs/app/templates/translate.svg => appMarketTemplates/TranslateRobot/avatar.svg} (100%) create mode 100644 projects/app/public/appMarketTemplates/TranslateRobot/template.json create mode 100644 projects/app/public/appMarketTemplates/chatGuide/template.json rename projects/app/public/{imgs/app/templates/flux.svg => appMarketTemplates/flux/avatar.svg} (100%) create mode 100644 projects/app/public/appMarketTemplates/flux/template.json rename projects/app/public/{imgs/app/templates/google.svg => appMarketTemplates/google/avatar.svg} (100%) create mode 100644 projects/app/public/appMarketTemplates/google/template.json create mode 100644 projects/app/public/appMarketTemplates/plugin-dalle/avatar.svg create mode 100644 projects/app/public/appMarketTemplates/plugin-dalle/template.json rename projects/app/public/{imgs/app/templates/feishu.svg => appMarketTemplates/plugin-feishu/avatar.svg} (100%) create mode 100644 projects/app/public/appMarketTemplates/plugin-feishu/template.json create mode 100644 projects/app/public/appMarketTemplates/simpleDatasetChat/template.json create mode 100644 projects/app/public/appMarketTemplates/srt-translate/template.json create mode 100644 projects/app/public/appMarketTemplates/timeBot/template.json create mode 100644 projects/app/public/imgs/app/templateFill.svg delete mode 100644 projects/app/public/imgs/app/templates/dalle.svg create mode 100644 projects/app/src/pages/api/core/app/template/detail.ts create mode 100644 projects/app/src/pages/api/core/app/template/list.ts create mode 100644 projects/app/src/pages/app/list/components/TemplateMarketModal.tsx create mode 100644 projects/app/src/service/core/app/template.ts create mode 100644 projects/app/src/web/core/app/api/template.ts diff --git a/packages/global/common/system/types/index.d.ts b/packages/global/common/system/types/index.d.ts index 8a5d7b31a..48ce70ee5 100644 --- a/packages/global/common/system/types/index.d.ts +++ b/packages/global/common/system/types/index.d.ts @@ -37,6 +37,7 @@ export type FastGPTFeConfigsType = { chatbotUrl?: string; openAPIDocUrl?: string; systemPluginCourseUrl?: string; + appTemplateCourse?: string; systemTitle?: string; systemDescription?: string; diff --git a/packages/global/core/app/constants.ts b/packages/global/core/app/constants.ts index 232206a6c..e6600f23c 100644 --- a/packages/global/core/app/constants.ts +++ b/packages/global/core/app/constants.ts @@ -29,3 +29,12 @@ export const defaultAppSelectFileConfig: AppFileSelectConfigType = { canSelectImg: false, maxFiles: 10 }; + +export enum AppTemplateTypeEnum { + recommendation = 'recommendation', + writing = 'writing', + imageGeneration = 'image-generation', + webSearch = 'web-search', + roleplay = 'roleplay', + officeServices = 'office-services' +} diff --git a/packages/global/core/workflow/type/index.d.ts b/packages/global/core/workflow/type/index.d.ts index 66e9bc18c..a90aa4677 100644 --- a/packages/global/core/workflow/type/index.d.ts +++ b/packages/global/core/workflow/type/index.d.ts @@ -24,7 +24,7 @@ import { FlowNodeTemplateType, StoreNodeItemType } from './node'; export type WorkflowTemplateBasicType = { nodes: StoreNodeItemType[]; edges: StoreEdgeItemType[]; - chatConfigs?: AppChatConfigType; + chatConfig?: AppChatConfigType; }; export type WorkflowTemplateType = { id: string; @@ -46,7 +46,18 @@ export type WorkflowTemplateType = { // template market export type TemplateMarketItemType = WorkflowTemplateType & { - tags?: { id: string; label: string }[]; + tags: string[]; + type: AppTypeEnum.simple | AppTypeEnum.workflow | AppTypeEnum.plugin; +}; +// template market list +export type TemplateMarketListItemType = { + id: string; + name: string; + intro?: string; + author?: string; + tags: string[]; + type: AppTypeEnum.simple | AppTypeEnum.workflow | AppTypeEnum.plugin; + avatar: string; }; // system plugin diff --git a/packages/service/type.d.ts b/packages/service/type.d.ts index adfd7b253..e10fb6b58 100644 --- a/packages/service/type.d.ts +++ b/packages/service/type.d.ts @@ -9,6 +9,7 @@ import { import { SubPlanType } from '@fastgpt/global/support/wallet/sub/type'; import { WorkerNameEnum, WorkerPool } from './worker/utils'; import { Worker } from 'worker_threads'; +import { TemplateMarketItemType } from '@fastgpt/global/core/workflow/type'; declare global { var feConfigs: FastGPTFeConfigsType; @@ -25,4 +26,5 @@ declare global { var systemLoadedGlobalConfig: boolean; var workerPoll: Record; + var appMarketTemplates: TemplateMarketItemType[]; } diff --git a/packages/web/components/common/Icon/constants.ts b/packages/web/components/common/Icon/constants.ts index 4587b979b..2cbb4b079 100644 --- a/packages/web/components/common/Icon/constants.ts +++ b/packages/web/components/common/Icon/constants.ts @@ -61,6 +61,7 @@ export const iconPaths = { 'common/text/t': () => import('./icons/common/text/t.svg'), 'common/tickFill': () => import('./icons/common/tickFill.svg'), 'common/trash': () => import('./icons/common/trash.svg'), + 'common/upRightArrowLight': () => import('./icons/common/upRightArrowLight.svg'), 'common/uploadFileFill': () => import('./icons/common/uploadFileFill.svg'), 'common/viewLight': () => import('./icons/common/viewLight.svg'), 'common/voiceLight': () => import('./icons/common/voiceLight.svg'), diff --git a/packages/web/components/common/Icon/icons/common/searchLight.svg b/packages/web/components/common/Icon/icons/common/searchLight.svg index 493230bee..ae3c6158a 100644 --- a/packages/web/components/common/Icon/icons/common/searchLight.svg +++ b/packages/web/components/common/Icon/icons/common/searchLight.svg @@ -1,8 +1,3 @@ - - - + + \ No newline at end of file diff --git a/packages/web/components/common/Icon/icons/common/upRightArrowLight.svg b/packages/web/components/common/Icon/icons/common/upRightArrowLight.svg new file mode 100644 index 000000000..48e92f2f0 --- /dev/null +++ b/packages/web/components/common/Icon/icons/common/upRightArrowLight.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/packages/web/components/common/Input/SearchInput/index.tsx b/packages/web/components/common/Input/SearchInput/index.tsx new file mode 100644 index 000000000..af7502476 --- /dev/null +++ b/packages/web/components/common/Input/SearchInput/index.tsx @@ -0,0 +1,14 @@ +import React from 'react'; +import { InputGroup, Input, InputProps, Flex } from '@chakra-ui/react'; +import MyIcon from '../../Icon'; + +const SearchInput = (props: InputProps) => { + return ( + + + + + ); +}; + +export default SearchInput; diff --git a/packages/web/components/common/MyMenu/index.tsx b/packages/web/components/common/MyMenu/index.tsx index c8b743327..924612b7d 100644 --- a/packages/web/components/common/MyMenu/index.tsx +++ b/packages/web/components/common/MyMenu/index.tsx @@ -8,10 +8,10 @@ import { MenuButton, MenuItemProps } from '@chakra-ui/react'; -import MyIcon from '../Icon'; import MyDivider from '../MyDivider'; import type { IconNameType } from '../Icon/type'; import { useSystem } from '../../../hooks/useSystem'; +import Avatar from '../Avatar'; export type MenuItemType = 'primary' | 'danger'; @@ -172,7 +172,7 @@ const MyMenu = ({ _notLast={{ mb: 0.5 }} {...typeMapStyle[child.type || 'primary']} > - {!!child.icon && } + {!!child.icon && } {child.label} diff --git a/packages/web/components/common/MyModal/index.tsx b/packages/web/components/common/MyModal/index.tsx index c01253a66..120e4eeae 100644 --- a/packages/web/components/common/MyModal/index.tsx +++ b/packages/web/components/common/MyModal/index.tsx @@ -9,7 +9,6 @@ import { Box, Image } from '@chakra-ui/react'; -import MyIcon from '../Icon'; import MyBox from '../MyBox'; import { useSystem } from '../../../hooks/useSystem'; import Avatar from '../Avatar'; diff --git a/packages/web/components/common/Textarea/PromptEditor/Editor.tsx b/packages/web/components/common/Textarea/PromptEditor/Editor.tsx index 589a257fb..67e527128 100644 --- a/packages/web/components/common/Textarea/PromptEditor/Editor.tsx +++ b/packages/web/components/common/Textarea/PromptEditor/Editor.tsx @@ -35,7 +35,8 @@ export default function Editor({ onBlur, value, placeholder = '', - isFlow + isFlow, + bg = 'white' }: { h?: number; maxLength?: number; @@ -49,6 +50,7 @@ export default function Editor({ value?: string; placeholder?: string; isFlow?: boolean; + bg?: string; }) { const [key, setKey] = useState(getNanoid(6)); const [_, startSts] = useTransition(); @@ -95,6 +97,7 @@ export default function Editor({ h={`${height}px`} cursor={'text'} color={'myGray.700'} + bg={focus ? 'white' : bg} > { const { isOpen, onOpen, onClose } = useDisclosure(); const { t } = useTranslation(); @@ -62,6 +64,7 @@ const PromptEditor = ({ onBlur={onBlurInput} placeholder={placeholder} isFlow={isFlow} + bg={bg} /> diff --git a/packages/web/i18n/en/app.json b/packages/web/i18n/en/app.json index 9b846b8c7..2ac9a8e5d 100644 --- a/packages/web/i18n/en/app.json +++ b/packages/web/i18n/en/app.json @@ -18,6 +18,9 @@ "confirm_delete_folder_tip": "Are you sure to delete this folder? All the following applications and corresponding chat records will be deleted, please confirm!", "copy_one_app": "Copy", "create_copy_success": "Create copy success", + "create_empty_app": "Create default app", + "create_empty_plugin": "Create default plugin", + "create_empty_workflow": "Create default workflow", "cron": { "every_day": "Executed every day", "every_month": "Executed monthly", @@ -84,6 +87,22 @@ "template": { "simple_robot": "Simple Robot" }, + "templateMarket": { + "Search_template": "Search template", + "Template_market": "Template market", + "Use": "Use", + "no_intro": "No intro~", + "templateTags": { + "Image_generation": "Image generation", + "Office_services": "Office searvices", + "Roleplay": "Roleplay", + "Web_search": "Web search", + "Writing": "Writing" + } + }, + "template_market": "Templates", + "template_market_description": "Explore more ways to play in the template market, configuration tutorials and usage guides will help you understand and get started with various applications.", + "template_market_empty_data": "No suitable template found", "time_zone": "Time zone", "tool_input_param_tip": "Configure related information before the plugin runs properly", "transition_to_workflow": "Transition to workflow", @@ -91,7 +110,7 @@ "transition_to_workflow_create_new_tip": "After converting to workflow, it will not be able to convert back to simple mode, please confirm!", "type": { "All": "All", - "Create http plugin tip": "Create plug-ins in batches using OpenAPI schema, compatible with GPTs format.", + "Create http plugin tip": "Create plug-ins in batches using OpenAPI schema, compatible with GPTs format", "Create one plugin tip": "The input and output workflows can be customized", "Create plugin bot": "Create plugin bot", "Create simple bot": "Create simple bot", @@ -101,6 +120,7 @@ "Http plugin": "Http plugin", "Plugin": "Plugin", "Simple bot": "Simple bot", + "Template": "Create by template", "Workflow bot": "Workflow" }, "upload_file_max_amount": "Max files", diff --git a/packages/web/i18n/en/common.json b/packages/web/i18n/en/common.json index ffde9008d..5a237556e 100644 --- a/packages/web/i18n/en/common.json +++ b/packages/web/i18n/en/common.json @@ -271,6 +271,7 @@ } }, "confirm_choice": "Confirm selection", + "contribute_app_template": "Contribution template", "core": { "Chat": "Chat", "Max Token": "Max token per data", @@ -1431,5 +1432,6 @@ }, "type": "type" }, - "verification": "verify" + "verification": "verify", + "xx_search_result": "{{key}} Search results" } diff --git a/packages/web/i18n/zh/app.json b/packages/web/i18n/zh/app.json index e43f1d358..8a1b8d498 100644 --- a/packages/web/i18n/zh/app.json +++ b/packages/web/i18n/zh/app.json @@ -18,6 +18,9 @@ "confirm_delete_folder_tip": "确认删除该文件夹?将会删除它下面所有应用及对应的聊天记录,请确认!", "copy_one_app": "创建副本", "create_copy_success": "创建副本成功", + "create_empty_app": "创建空白应用", + "create_empty_plugin": "创建空白插件", + "create_empty_workflow": "创建空白工作流", "cron": { "every_day": "每天执行", "every_month": "每月执行", @@ -84,6 +87,23 @@ "template": { "simple_robot": "简易机器人" }, + "templateMarket": { + "Search_template": "搜索模板", + "Template_market": "模板市场", + "Use": "使用", + "no_intro": "还没有介绍~", + "templateTags": { + "Image_generation": "图片生成", + "Office_services": "办公服务", + "Recommendation": "推荐", + "Roleplay": "角色扮演", + "Web_search": "联网搜索", + "Writing": "文本创作" + } + }, + "template_market": "模板市场", + "template_market_description": "在模板市场探索更多玩法,配置教程与使用引导,带你理解并上手各种应用", + "template_market_empty_data": "找不到合适的模板", "time_zone": "时区", "tool_input_param_tip": "该插件正常运行需要配置相关信息", "transition_to_workflow": "转成工作流", @@ -91,16 +111,18 @@ "transition_to_workflow_create_new_tip": "转化成工作流后,将无法转化回简易模式,请确认!", "type": { "All": "全部", - "Create http plugin tip": "通过 OpenAPI Schema 批量创建插件,兼容 GPTs 格式。", + "Create http plugin tip": "通过 OpenAPI Schema 批量创建插件,兼容 GPTs 格式", "Create one plugin tip": "可以自定义输入和输出的工作流,通常用于封装重复使用的工作流", "Create plugin bot": "创建插件", "Create simple bot": "创建简易应用", "Create simple bot tip": "通过填表单形式,创建简单的 AI 应用,适合新手", + "Create template tip": "在模板市场探索更多玩法,带你理解并上手各种应用", "Create workflow bot": "创建工作流", "Create workflow tip": "通过低代码的方式,构建逻辑复杂的多轮对话 AI 应用,推荐高级玩家使用", "Http plugin": "HTTP 插件", "Plugin": "插件", "Simple bot": "简易应用", + "Template": "通过模板创建", "Workflow bot": "工作流" }, "upload_file_max_amount": "最大文件数量", diff --git a/packages/web/i18n/zh/common.json b/packages/web/i18n/zh/common.json index 3c2f0256a..7f410bca7 100644 --- a/packages/web/i18n/zh/common.json +++ b/packages/web/i18n/zh/common.json @@ -273,6 +273,7 @@ } }, "confirm_choice": "确认选择", + "contribute_app_template": "贡献模板", "core": { "Chat": "对话", "Max Token": "单条数据上限", @@ -359,6 +360,14 @@ "logs": { "Source And Time": "来源 & 时间" }, + "more": "查看更多", + "navbar": { + "External": "外部使用", + "Flow mode": "高级编排", + "Publish": "发布", + "Publish app": "发布应用", + "Simple mode": "简易配置" + }, "no_app": "还没有应用,快去创建一个吧!", "not_published": "未发布", "outLink": { @@ -598,7 +607,8 @@ "success": "开始同步" } }, - "training": {} + "training": { + } }, "data": { "Auxiliary Data": "辅助数据", @@ -1437,5 +1447,6 @@ }, "type": "类型" }, - "verification": "验证" + "verification": "验证", + "xx_search_result": "{{key}} 的搜索结果" } diff --git a/projects/app/data/pluginTemplates/customFeedback.json b/projects/app/data/pluginTemplates/customFeedback.json index 62c6af9c1..00eed7501 100644 --- a/projects/app/data/pluginTemplates/customFeedback.json +++ b/projects/app/data/pluginTemplates/customFeedback.json @@ -1,5 +1,5 @@ { - "author": "FastGPT Team", + "author": "FastGPT", "version": "481", "templateType": "other", "name": "自定义反馈", diff --git a/projects/app/data/pluginTemplates/getCurrentTime.json b/projects/app/data/pluginTemplates/getCurrentTime.json index 02893c868..eac73b9d8 100644 --- a/projects/app/data/pluginTemplates/getCurrentTime.json +++ b/projects/app/data/pluginTemplates/getCurrentTime.json @@ -1,5 +1,5 @@ { - "author": "FastGPT Team", + "author": "FastGPT", "version": "481", "templateType": "tools", "name": "获取当前时间", diff --git a/projects/app/data/pluginTemplates/textEditor.json b/projects/app/data/pluginTemplates/textEditor.json index 7f0101b22..23fb56564 100644 --- a/projects/app/data/pluginTemplates/textEditor.json +++ b/projects/app/data/pluginTemplates/textEditor.json @@ -1,5 +1,5 @@ { - "author": "FastGPT Team", + "author": "FastGPT", "version": "481", "name": "文本加工", "avatar": "/imgs/workflow/textEditor.svg", diff --git a/projects/app/data/pluginTemplates/v1/customFeedback.json b/projects/app/data/pluginTemplates/v1/customFeedback.json index cea384399..4cfb690b4 100644 --- a/projects/app/data/pluginTemplates/v1/customFeedback.json +++ b/projects/app/data/pluginTemplates/v1/customFeedback.json @@ -1,5 +1,5 @@ { - "author": "FastGPT Team", + "author": "FastGPT", "templateType": "other", "name": "自定义反馈", "avatar": "/imgs/module/customFeedback.svg", diff --git a/projects/app/data/pluginTemplates/v1/getCurrentTime.json b/projects/app/data/pluginTemplates/v1/getCurrentTime.json index 6d040c788..eb76a295f 100644 --- a/projects/app/data/pluginTemplates/v1/getCurrentTime.json +++ b/projects/app/data/pluginTemplates/v1/getCurrentTime.json @@ -1,5 +1,5 @@ { - "author": "FastGPT Team", + "author": "FastGPT", "templateType": "tools", "name": "获取当前时间", "avatar": "/imgs/module/getCurrentTime.svg", diff --git a/projects/app/data/pluginTemplates/v1/textEditor.json b/projects/app/data/pluginTemplates/v1/textEditor.json index 444f45a05..5559672dc 100644 --- a/projects/app/data/pluginTemplates/v1/textEditor.json +++ b/projects/app/data/pluginTemplates/v1/textEditor.json @@ -1,5 +1,5 @@ { - "author": "FastGPT Team", + "author": "FastGPT", "templateType": "tools", "name": "文本加工", "avatar": "/imgs/module/textEditor.svg", diff --git a/projects/app/data/pluginTemplates/v1/tfSwitch.json b/projects/app/data/pluginTemplates/v1/tfSwitch.json index 54cf33bba..610ec8275 100644 --- a/projects/app/data/pluginTemplates/v1/tfSwitch.json +++ b/projects/app/data/pluginTemplates/v1/tfSwitch.json @@ -1,6 +1,6 @@ { "abandon": true, - "author": "FastGPT Team", + "author": "FastGPT", "templateType": "tools", "name": "判断器", "avatar": "/imgs/module/tfSwitch.svg", diff --git a/projects/app/public/appMarketTemplates/CQ/template.json b/projects/app/public/appMarketTemplates/CQ/template.json new file mode 100644 index 000000000..97cf4c76b --- /dev/null +++ b/projects/app/public/appMarketTemplates/CQ/template.json @@ -0,0 +1,467 @@ +{ + "name": "问题分类 + 知识库", + "intro": "先对用户的问题进行分类,再根据不同类型问题,执行不同的操作", + "author": "Fastgpt", + "avatar": "core/workflow/template/questionClassify", + "tags": ["office-services"], + "type": "advanced", + "workflow": { + "nodes": [ + { + "nodeId": "userGuide", + "name": "系统配置", + "intro": "可以配置应用的系统参数", + "avatar": "core/workflow/template/systemConfig", + "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": "core/workflow/template/workflowStart", + "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": "core/workflow/template/aiChat", + "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-4o-mini" + }, + { + "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": "core/workflow/template/questionClassify", + "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-4o-mini" + }, + { + "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" + }, + { + "value": "其他问题", + "key": "agex" + } + ] + } + ], + "outputs": [ + { + "id": "cqResult", + "key": "cqResult", + "label": "分类结果", + "valueType": "WorkflowIOValueTypeEnum.string", + "type": "FlowNodeOutputTypeEnum.static" + } + ] + }, + { + "nodeId": "7kwgL1dVlwG6", + "name": "指定回复", + "intro": "该模块可以直接回复一段指定的内容。常用于引导、提示。非字符串内容传入时,会转成字符串进行输出。", + "avatar": "core/workflow/template/reply", + "flowNodeType": "FlowNodeTypeEnum.answerNode", + "position": { + "x": 1874.9167551056487, + "y": 434.98431875888207 + }, + "version": "481", + "inputs": [ + { + "key": "text", + "renderTypeList": ["FlowNodeInputTypeEnum.textarea", "FlowNodeInputTypeEnum.reference"], + "valueType": "WorkflowIOValueTypeEnum.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": ["rvbo634w3AYj", "cqResult"] + } + ], + "outputs": [] + }, + { + "nodeId": "MNMMMIjjWyMU", + "name": "知识库搜索", + "intro": "调用\"语义检索\"和\"全文检索\"能力,从\"知识库\"中查找可能与问题相关的参考内容", + "avatar": "core/workflow/template/datasetSearch", + "flowNodeType": "FlowNodeTypeEnum.datasetSearchNode", + "showStatus": true, + "position": { + "x": 1851.010152279949, + "y": -613.3555232387284 + }, + "version": "481", + "inputs": [ + { + "key": "datasets", + "renderTypeList": [ + "FlowNodeInputTypeEnum.selectDataset", + "FlowNodeInputTypeEnum.reference" + ], + "label": "core.module.input.label.Select dataset", + "value": [], + "valueType": "WorkflowIOValueTypeEnum.selectDataset", + "list": [], + "required": true + }, + { + "key": "similarity", + "renderTypeList": ["FlowNodeInputTypeEnum.selectDatasetParamsModal"], + "label": "", + "value": 0.4, + "valueType": "WorkflowIOValueTypeEnum.number" + }, + { + "key": "limit", + "renderTypeList": ["FlowNodeInputTypeEnum.hidden"], + "label": "", + "value": 1500, + "valueType": "WorkflowIOValueTypeEnum.number" + }, + { + "key": "searchMode", + "renderTypeList": ["FlowNodeInputTypeEnum.hidden"], + "label": "", + "valueType": "WorkflowIOValueTypeEnum.string", + "value": "embedding" + }, + { + "key": "usingReRank", + "renderTypeList": ["FlowNodeInputTypeEnum.hidden"], + "label": "", + "valueType": "WorkflowIOValueTypeEnum.boolean", + "value": false + }, + { + "key": "datasetSearchUsingExtensionQuery", + "renderTypeList": ["FlowNodeInputTypeEnum.hidden"], + "label": "", + "valueType": "WorkflowIOValueTypeEnum.boolean", + "value": true + }, + { + "key": "datasetSearchExtensionModel", + "renderTypeList": ["FlowNodeInputTypeEnum.hidden"], + "label": "", + "valueType": "WorkflowIOValueTypeEnum.string" + }, + { + "key": "datasetSearchExtensionBg", + "renderTypeList": ["FlowNodeInputTypeEnum.hidden"], + "label": "", + "valueType": "WorkflowIOValueTypeEnum.string", + "value": "" + }, + { + "key": "userChatInput", + "renderTypeList": ["FlowNodeInputTypeEnum.reference", "FlowNodeInputTypeEnum.textarea"], + "valueType": "WorkflowIOValueTypeEnum.string", + "label": "用户问题", + "required": true, + "toolDescription": "需要检索的内容", + "value": ["workflowStartNodeId", "userChatInput"] + } + ], + "outputs": [ + { + "id": "quoteQA", + "key": "quoteQA", + "label": "core.module.Dataset quote.label", + "description": "特殊数组格式,搜索结果为空时,返回空数组。", + "type": "FlowNodeOutputTypeEnum.static", + "valueType": "WorkflowIOValueTypeEnum.datasetQuote" + } + ] + } + ], + "edges": [ + { + "source": "workflowStartNodeId", + "target": "rvbo634w3AYj", + "sourceHandle": "workflowStartNodeId-source-right", + "targetHandle": "rvbo634w3AYj-target-left" + }, + { + "source": "rvbo634w3AYj", + "target": "7kwgL1dVlwG6", + "sourceHandle": "rvbo634w3AYj-source-agex", + "targetHandle": "7kwgL1dVlwG6-target-left" + }, + { + "source": "rvbo634w3AYj", + "target": "MNMMMIjjWyMU", + "sourceHandle": "rvbo634w3AYj-source-wqre", + "targetHandle": "MNMMMIjjWyMU-target-left" + }, + { + "source": "MNMMMIjjWyMU", + "target": "7BdojPlukIQw", + "sourceHandle": "MNMMMIjjWyMU-source-right", + "targetHandle": "7BdojPlukIQw-target-left" + }, + { + "source": "rvbo634w3AYj", + "target": "7kwgL1dVlwG6", + "sourceHandle": "rvbo634w3AYj-source-sdfa", + "targetHandle": "7kwgL1dVlwG6-target-left" + } + ] + } +} diff --git a/projects/app/public/imgs/app/templates/translate.svg b/projects/app/public/appMarketTemplates/TranslateRobot/avatar.svg similarity index 100% rename from projects/app/public/imgs/app/templates/translate.svg rename to projects/app/public/appMarketTemplates/TranslateRobot/avatar.svg diff --git a/projects/app/public/appMarketTemplates/TranslateRobot/template.json b/projects/app/public/appMarketTemplates/TranslateRobot/template.json new file mode 100644 index 000000000..3c3faae0c --- /dev/null +++ b/projects/app/public/appMarketTemplates/TranslateRobot/template.json @@ -0,0 +1,579 @@ +{ + "name": "多轮翻译机器人", + "intro": "通过 4 轮翻译,提高翻译英文的质量", + "author": "Fastgpt", + "avatar": "/appMarketTemplates/TranslateRobot/avatar.svg", + "tags": ["office-services"], + "type": "advanced", + "workflow": { + "nodes": [ + { + "nodeId": "userGuide", + "name": "系统配置", + "intro": "可以配置应用的系统参数", + "avatar": "/imgs/workflow/userGuide.png", + "flowNodeType": "userGuide", + "position": { + "x": 531.2422736065552, + "y": -486.7611729549753 + }, + "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": 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", + "type": "static", + "valueType": "string" + } + ] + }, + { + "nodeId": "loOvhld2ZTKa", + "name": "第一轮翻译", + "intro": "AI 大模型对话", + "avatar": "/imgs/workflow/AI.png", + "flowNodeType": "chatNode", + "showStatus": true, + "position": { + "x": 1748.8252410306534, + "y": -245.08260685989214 + }, + "version": "481", + "inputs": [ + { + "key": "model", + "renderTypeList": ["settingLLMModel", "reference"], + "label": "core.module.input.label.aiModel", + "valueType": "string", + "value": "claude-3-5-sonnet-20240620" + }, + { + "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": "isResponseAnswerText", + "renderTypeList": ["hidden"], + "label": "", + "value": true, + "valueType": "boolean" + }, + { + "key": "quoteTemplate", + "renderTypeList": ["hidden"], + "label": "", + "valueType": "string" + }, + { + "key": "quotePrompt", + "renderTypeList": ["hidden"], + "label": "", + "valueType": "string" + }, + { + "key": "systemPrompt", + "renderTypeList": ["textarea", "reference"], + "max": 3000, + "valueType": "string", + "label": "core.ai.Prompt", + "description": "core.app.tip.chatNodeSystemPromptTip", + "placeholder": "core.app.tip.chatNodeSystemPromptTip", + "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": ["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, + "toolDescription": "用户问题", + "value": ["gBDvemE4FBhp", "system_text"] + }, + { + "key": "quoteQA", + "renderTypeList": ["settingDatasetQuotePrompt"], + "label": "", + "debugLabel": "知识库引用", + "description": "", + "valueType": "datasetQuote" + } + ], + "outputs": [ + { + "id": "history", + "key": "history", + "required": true, + "label": "core.module.output.label.New context", + "description": "core.module.output.description.New context", + "valueType": "chatHistory", + "type": "static" + }, + { + "id": "answerText", + "key": "answerText", + "required": true, + "label": "core.module.output.label.Ai response content", + "description": "core.module.output.description.Ai response content", + "valueType": "string", + "type": "static" + } + ] + }, + { + "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 + }, + "customInputConfig": { + "selectValueTypeList": [ + "string", + "number", + "boolean", + "object", + "arrayString", + "arrayNumber", + "arrayBoolean", + "arrayObject", + "any", + "chatHistory", + "datasetQuote", + "dynamic", + "selectApp", + "selectDataset" + ], + "showDescription": false, + "showDefaultValue": true + } + }, + { + "key": "codeType", + "renderTypeList": ["hidden"], + "label": "", + "value": "js" + }, + { + "key": "code", + "renderTypeList": ["custom"], + "label": "", + "value": "function main({data1}) {\n const codeBlocks = data1.match(/```[\\s\\S]*?```/g);\n\n if (codeBlocks && codeBlocks.length > 0) {\n const lastCodeBlock = codeBlocks[codeBlocks.length - 1];\n const cleanedCodeBlock = lastCodeBlock.replace(/```[a-zA-Z]*|```/g, '').trim();\n \n return {\n result: cleanedCodeBlock\n };\n }\n\n return {\n result: '未截取到代码块内容'\n };\n}\n" + }, + { + "key": "data1", + "valueType": "string", + "label": "data1", + "renderTypeList": ["reference"], + "description": "", + "canEdit": true, + "editField": { + "key": true, + "valueType": true + }, + "value": ["loOvhld2ZTKa", "answerText"] + } + ], + "outputs": [ + { + "id": "system_addOutputParam", + "key": "system_addOutputParam", + "type": "dynamic", + "valueType": "dynamic", + "label": "", + "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" + }, + { + "id": "gR0mkQpJ4Og8", + "type": "dynamic", + "key": "data2", + "valueType": "string", + "label": "data2" + } + ] + }, + { + "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": ["bcqtxqxE2R6o", "system_text"] + } + ], + "outputs": [] + }, + { + "nodeId": "gBDvemE4FBhp", + "name": "文本拼接", + "intro": "可对固定或传入的文本进行加工后输出,非字符串类型数据最终会转成字符串类型。", + "avatar": "/imgs/workflow/textEditor.svg", + "flowNodeType": "textEditor", + "position": { + "x": 1031.371061396644, + "y": 38.65839420088383 + }, + "version": "486", + "inputs": [ + { + "key": "system_addInputParam", + "renderTypeList": ["addInputParam"], + "valueType": "dynamic", + "label": "", + "required": false, + "description": "可以引用其他节点的输出,作为文本拼接的变量,通过 {{字段名}} 来引用变量", + "customInputConfig": { + "selectValueTypeList": [ + "string", + "number", + "boolean", + "object", + "arrayString", + "arrayNumber", + "arrayBoolean", + "arrayObject", + "any", + "chatHistory", + "datasetQuote", + "dynamic", + "selectApp", + "selectDataset" + ], + "showDescription": false, + "showDefaultValue": false + } + }, + { + "key": "system_textareaInput", + "renderTypeList": ["textarea"], + "valueType": "string", + "required": true, + "label": "拼接文本", + "placeholder": "可通过 {{字段名}} 来引用变量", + "value": "原文:\n\"\"\"\n{{q}}\n\"\"\"" + }, + { + "renderTypeList": ["reference"], + "valueType": "string", + "canEdit": true, + "key": "q", + "label": "q", + "customInputConfig": { + "selectValueTypeList": [ + "string", + "number", + "boolean", + "object", + "arrayString", + "arrayNumber", + "arrayBoolean", + "arrayObject", + "any", + "chatHistory", + "datasetQuote", + "dynamic", + "selectApp", + "selectDataset" + ], + "showDescription": false, + "showDefaultValue": false + }, + "required": true, + "value": ["448745", "userChatInput"] + } + ], + "outputs": [ + { + "id": "system_text", + "key": "system_text", + "label": "拼接结果", + "type": "static", + "valueType": "string" + } + ] + }, + { + "nodeId": "bcqtxqxE2R6o", + "name": "合并输出结果", + "intro": "可对固定或传入的文本进行加工后输出,非字符串类型数据最终会转成字符串类型。", + "avatar": "/imgs/workflow/textEditor.svg", + "flowNodeType": "textEditor", + "position": { + "x": 3113.6227559936665, + "y": 12.909197647746709 + }, + "version": "486", + "inputs": [ + { + "key": "system_addInputParam", + "renderTypeList": ["addInputParam"], + "valueType": "dynamic", + "label": "", + "required": false, + "description": "可以引用其他节点的输出,作为文本拼接的变量,通过 {{字段名}} 来引用变量", + "customInputConfig": { + "selectValueTypeList": [ + "string", + "number", + "boolean", + "object", + "arrayString", + "arrayNumber", + "arrayBoolean", + "arrayObject", + "any", + "chatHistory", + "datasetQuote", + "dynamic", + "selectApp", + "selectDataset" + ], + "showDescription": false, + "showDefaultValue": false + } + }, + { + "key": "system_textareaInput", + "renderTypeList": ["textarea"], + "valueType": "string", + "required": true, + "label": "拼接文本", + "placeholder": "可通过 {{字段名}} 来引用变量", + "value": "****** \n\n最终翻译结果如下: \n\n```\n{{result}}\n```" + }, + { + "renderTypeList": ["reference"], + "valueType": "string", + "canEdit": true, + "key": "result", + "label": "result", + "customInputConfig": { + "selectValueTypeList": [ + "string", + "number", + "boolean", + "object", + "arrayString", + "arrayNumber", + "arrayBoolean", + "arrayObject", + "any", + "chatHistory", + "datasetQuote", + "dynamic", + "selectApp", + "selectDataset" + ], + "showDescription": false, + "showDefaultValue": false + }, + "required": true, + "value": ["w0oBbQ3YJHye", "qLUQfhG0ILRX"] + } + ], + "outputs": [ + { + "id": "system_text", + "key": "system_text", + "label": "拼接结果", + "type": "static", + "valueType": "string" + } + ] + } + ], + "edges": [ + { + "source": "loOvhld2ZTKa", + "target": "w0oBbQ3YJHye", + "sourceHandle": "loOvhld2ZTKa-source-right", + "targetHandle": "w0oBbQ3YJHye-target-left" + }, + { + "source": "448745", + "target": "gBDvemE4FBhp", + "sourceHandle": "448745-source-right", + "targetHandle": "gBDvemE4FBhp-target-left" + }, + { + "source": "gBDvemE4FBhp", + "target": "loOvhld2ZTKa", + "sourceHandle": "gBDvemE4FBhp-source-right", + "targetHandle": "loOvhld2ZTKa-target-left" + }, + { + "source": "w0oBbQ3YJHye", + "target": "bcqtxqxE2R6o", + "sourceHandle": "w0oBbQ3YJHye-source-right", + "targetHandle": "bcqtxqxE2R6o-target-left" + }, + { + "source": "bcqtxqxE2R6o", + "target": "foO69L5FOmDQ", + "sourceHandle": "bcqtxqxE2R6o-source-right", + "targetHandle": "foO69L5FOmDQ-target-left" + } + ], + "chatConfig": { + "scheduledTriggerConfig": { + "cronString": "", + "timezone": "Asia/Shanghai", + "defaultPrompt": "" + } + } + } +} diff --git a/projects/app/public/appMarketTemplates/chatGuide/template.json b/projects/app/public/appMarketTemplates/chatGuide/template.json new file mode 100644 index 000000000..c09ce17dc --- /dev/null +++ b/projects/app/public/appMarketTemplates/chatGuide/template.json @@ -0,0 +1,262 @@ +{ + "name": "对话引导 + 变量", + "intro": "可以在对话开始发送一段提示,或者让用户填写一些内容,作为本次对话的变量", + "author": "Fastgpt", + "avatar": "core/workflow/template/systemConfig", + "tags": ["office-services"], + "type": "simple", + "weight": 1, + "workflow": { + "nodes": [ + { + "nodeId": "userGuide", + "name": "系统配置", + "intro": "可以配置应用的系统参数", + "avatar": "/imgs/workflow/userGuide.png", + "flowNodeType": "userGuide", + "position": { + "x": 496.57560693988853, + "y": -490.7611729549753 + }, + "version": "481", + "inputs": [ + { + "key": "welcomeText", + "renderTypeList": ["FlowNodeInputTypeEnum.hidden"], + "valueType": "WorkflowIOValueTypeEnum.string", + "label": "core.app.Welcome Text", + "value": "你好,我可以为你翻译各种语言,请告诉我你需要翻译成什么语言?" + }, + { + "key": "variables", + "renderTypeList": ["FlowNodeInputTypeEnum.hidden"], + "valueType": "WorkflowIOValueTypeEnum.any", + "label": "core.app.Chat Variable", + "value": [ + { + "id": "myb3xk", + "key": "language", + "label": "目标语言", + "type": "select", + "required": true, + "maxLen": 50, + "enums": [ + { + "value": "中文" + }, + { + "value": "英文" + } + ] + } + ] + }, + { + "key": "questionGuide", + "valueType": "WorkflowIOValueTypeEnum.boolean", + "renderTypeList": ["FlowNodeInputTypeEnum.hidden"], + "label": "core.app.Question Guide", + "value": false + }, + { + "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": "448745", + "name": "流程开始", + "intro": "", + "avatar": "/imgs/workflow/userChatInput.svg", + "flowNodeType": "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": "loOvhld2ZTKa", + "name": "AI 对话", + "intro": "AI 大模型对话", + "avatar": "/imgs/workflow/AI.png", + "flowNodeType": "chatNode", + "showStatus": true, + "position": { + "x": 1097.7317280958762, + "y": -244.16014496351386 + }, + "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": 0, + "valueType": "WorkflowIOValueTypeEnum.number", + "min": 0, + "max": 10, + "step": 1 + }, + { + "key": "maxToken", + "renderTypeList": ["FlowNodeInputTypeEnum.hidden"], + "label": "", + "value": 2000, + "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": "请直接将我的问题翻译成{{language}},不需要回答问题。" + }, + { + "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": ["448745", "userChatInput"] + }, + { + "key": "quoteQA", + "renderTypeList": ["FlowNodeInputTypeEnum.settingDatasetQuotePrompt"], + "label": "", + "debugLabel": "知识库引用", + "description": "", + "valueType": "WorkflowIOValueTypeEnum.datasetQuote" + } + ], + "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" + } + ] + } + ], + "edges": [ + { + "source": "448745", + "target": "loOvhld2ZTKa", + "sourceHandle": "448745-source-right", + "targetHandle": "loOvhld2ZTKa-target-left" + } + ], + "chatConfig": { + "welcomeText": "你好,我可以为你翻译各种语言,请告诉我你需要翻译成什么语言?", + "scheduledTriggerConfig": { + "cronString": "", + "timezone": "Asia/Shanghai", + "defaultPrompt": "" + } + } + } +} diff --git a/projects/app/public/imgs/app/templates/flux.svg b/projects/app/public/appMarketTemplates/flux/avatar.svg similarity index 100% rename from projects/app/public/imgs/app/templates/flux.svg rename to projects/app/public/appMarketTemplates/flux/avatar.svg diff --git a/projects/app/public/appMarketTemplates/flux/template.json b/projects/app/public/appMarketTemplates/flux/template.json new file mode 100644 index 000000000..dda48ab9a --- /dev/null +++ b/projects/app/public/appMarketTemplates/flux/template.json @@ -0,0 +1,270 @@ +{ + "name": "Flux 绘图", + "intro": "通过请求 Flux 接口绘图,需要有 api key", + "author": "Fastgpt", + "avatar": "/appMarketTemplates/flux/avatar.svg", + "type": "plugin", + "tags": ["image-generation"], + "workflow": { + "nodes": [ + { + "nodeId": "pluginInput", + "name": "自定义插件输入", + "intro": "可以配置插件需要哪些输入,利用这些输入来运行插件", + "avatar": "core/workflow/template/workflowStart", + "flowNodeType": "pluginInput", + "showStatus": false, + "position": { + "x": 351.2046235980429, + "y": -77.41739975794749 + }, + "version": "481", + "inputs": [ + { + "renderTypeList": ["reference"], + "selectedTypeIndex": 0, + "valueType": "string", + "canEdit": true, + "key": "绘图提示词", + "label": "绘图提示词", + "description": "绘图提示词", + "required": true, + "toolDescription": "绘图提示词" + } + ], + "outputs": [ + { + "id": "绘图提示词", + "valueType": "string", + "key": "绘图提示词", + "label": "绘图提示词", + "type": "hidden" + } + ] + }, + { + "nodeId": "pluginOutput", + "name": "自定义插件输出", + "intro": "自定义配置外部输出,使用插件时,仅暴露自定义配置的输出", + "avatar": "core/workflow/template/pluginOutput", + "flowNodeType": "pluginOutput", + "showStatus": false, + "position": { + "x": 1983.6911708285384, + "y": -95.86447885674228 + }, + "version": "481", + "inputs": [ + { + "renderTypeList": ["reference"], + "valueType": "string", + "canEdit": true, + "key": "图片访问链接", + "label": "图片访问链接", + "description": "", + "value": ["tMvel910bnrJ", "pJXgWoTpPoMy"] + }, + { + "renderTypeList": ["reference"], + "valueType": "object", + "canEdit": true, + "key": "error", + "label": "错误信息", + "description": "", + "value": ["tMvel910bnrJ", "error"] + } + ], + "outputs": [] + }, + { + "nodeId": "tMvel910bnrJ", + "name": "HTTP 请求", + "intro": "可以发出一个 HTTP 请求,实现更为复杂的操作(联网搜索、数据库查询等)", + "avatar": "core/workflow/template/httpRequest", + "flowNodeType": "httpRequest468", + "showStatus": true, + "position": { + "x": 1138.1732435351091, + "y": -416.6443415407282 + }, + "version": "481", + "inputs": [ + { + "key": "system_addInputParam", + "renderTypeList": ["addInputParam"], + "valueType": "dynamic", + "label": "", + "required": false, + "description": "core.module.input.description.HTTP Dynamic Input", + "customInputConfig": { + "selectValueTypeList": [ + "string", + "number", + "boolean", + "object", + "arrayString", + "arrayNumber", + "arrayBoolean", + "arrayObject", + "any", + "chatHistory", + "datasetQuote", + "dynamic", + "selectApp", + "selectDataset" + ], + "showDescription": false, + "showDefaultValue": true + } + }, + { + "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://fal.run/fal-ai/flux-pro" + }, + { + "key": "system_httpHeader", + "renderTypeList": ["custom"], + "valueType": "any", + "value": [ + { + "key": "Authorization", + "type": "string", + "value": "Key {{apikey}}" + } + ], + "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 \"prompt\": \"{{prompt}}\",\n \"image_size\": \"landscape_4_3\",\n \"num_inference_steps\": 28,\n \"guidance_scale\": 3.5\n}", + "label": "", + "required": false + }, + { + "renderTypeList": ["reference"], + "valueType": "string", + "canEdit": true, + "key": "prompt", + "label": "prompt", + "customInputConfig": { + "selectValueTypeList": [ + "string", + "number", + "boolean", + "object", + "arrayString", + "arrayNumber", + "arrayBoolean", + "arrayObject", + "any", + "chatHistory", + "datasetQuote", + "dynamic", + "selectApp", + "selectDataset" + ], + "showDescription": false, + "showDefaultValue": true + }, + "required": true, + "value": ["pluginInput", "绘图提示词"] + } + ], + "outputs": [ + { + "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" + }, + { + "id": "system_addOutputParam", + "key": "system_addOutputParam", + "type": "dynamic", + "valueType": "dynamic", + "label": "", + "customFieldConfig": { + "selectValueTypeList": [ + "string", + "number", + "boolean", + "object", + "arrayString", + "arrayNumber", + "arrayBoolean", + "arrayObject", + "any", + "chatHistory", + "datasetQuote", + "dynamic", + "selectApp", + "selectDataset" + ], + "showDescription": false, + "showDefaultValue": false + } + }, + { + "id": "pJXgWoTpPoMy", + "valueType": "string", + "type": "dynamic", + "key": "images[0].url", + "label": "images[0].url" + } + ] + } + ], + "edges": [ + { + "source": "pluginInput", + "target": "tMvel910bnrJ", + "sourceHandle": "pluginInput-source-right", + "targetHandle": "tMvel910bnrJ-target-left" + }, + { + "source": "tMvel910bnrJ", + "target": "pluginOutput", + "sourceHandle": "tMvel910bnrJ-source-right", + "targetHandle": "pluginOutput-target-left" + } + ] + } +} diff --git a/projects/app/public/imgs/app/templates/google.svg b/projects/app/public/appMarketTemplates/google/avatar.svg similarity index 100% rename from projects/app/public/imgs/app/templates/google.svg rename to projects/app/public/appMarketTemplates/google/avatar.svg diff --git a/projects/app/public/appMarketTemplates/google/template.json b/projects/app/public/appMarketTemplates/google/template.json new file mode 100644 index 000000000..c45216d33 --- /dev/null +++ b/projects/app/public/appMarketTemplates/google/template.json @@ -0,0 +1,441 @@ +{ + "name": "谷歌搜索", + "intro": "通过请求谷歌搜索,查询相关内容作为模型的参考。", + "author": "Fastgpt", + "avatar": "/appMarketTemplates/google/avatar.svg", + "tags": ["recommendation", "web-search"], + "type": "advanced", + "workflow": { + "nodes": [ + { + "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" + }, + { + "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" + } + ] + } +} diff --git a/projects/app/public/appMarketTemplates/plugin-dalle/avatar.svg b/projects/app/public/appMarketTemplates/plugin-dalle/avatar.svg new file mode 100644 index 000000000..eeca4abc2 --- /dev/null +++ b/projects/app/public/appMarketTemplates/plugin-dalle/avatar.svg @@ -0,0 +1,6 @@ + + + \ No newline at end of file diff --git a/projects/app/public/appMarketTemplates/plugin-dalle/template.json b/projects/app/public/appMarketTemplates/plugin-dalle/template.json new file mode 100644 index 000000000..a691bf5bd --- /dev/null +++ b/projects/app/public/appMarketTemplates/plugin-dalle/template.json @@ -0,0 +1,270 @@ +{ + "name": "Dalle3 绘图", + "intro": "通过请求 Dalle3 接口绘图,需要有 api key", + "author": "Fastgpt", + "avatar": "/appMarketTemplates/plugin-dalle/avatar.svg", + "type": "plugin", + "tags": ["recommendation", "image-generation"], + "workflow": { + "nodes": [ + { + "nodeId": "pluginInput", + "name": "自定义插件输入", + "intro": "可以配置插件需要哪些输入,利用这些输入来运行插件", + "avatar": "core/workflow/template/workflowStart", + "flowNodeType": "pluginInput", + "showStatus": false, + "position": { + "x": 412.7756423516722, + "y": -99.80686112290361 + }, + "version": "481", + "inputs": [ + { + "renderTypeList": ["reference"], + "selectedTypeIndex": 0, + "valueType": "string", + "canEdit": true, + "key": "绘图提示词", + "label": "绘图提示词", + "description": "绘图提示词", + "required": true, + "toolDescription": "绘图提示词" + } + ], + "outputs": [ + { + "id": "绘图提示词", + "valueType": "string", + "key": "绘图提示词", + "label": "绘图提示词", + "type": "hidden" + } + ] + }, + { + "nodeId": "pluginOutput", + "name": "自定义插件输出", + "intro": "自定义配置外部输出,使用插件时,仅暴露自定义配置的输出", + "avatar": "core/workflow/template/pluginOutput", + "flowNodeType": "pluginOutput", + "showStatus": false, + "position": { + "x": 1822.7195641525896, + "y": -193.54601587659562 + }, + "version": "481", + "inputs": [ + { + "renderTypeList": ["reference"], + "valueType": "string", + "canEdit": true, + "key": "图片访问链接", + "label": "图片访问链接", + "description": "", + "value": ["tMvel910bnrJ", "pJXgWoTpPoMy"] + }, + { + "renderTypeList": ["reference"], + "valueType": "object", + "canEdit": true, + "key": "error", + "label": "错误信息", + "description": "", + "value": ["tMvel910bnrJ", "error"] + } + ], + "outputs": [] + }, + { + "nodeId": "tMvel910bnrJ", + "name": "HTTP 请求", + "intro": "可以发出一个 HTTP 请求,实现更为复杂的操作(联网搜索、数据库查询等)", + "avatar": "core/workflow/template/httpRequest", + "flowNodeType": "httpRequest468", + "showStatus": true, + "position": { + "x": 1044.8838211811253, + "y": -414.7785530936485 + }, + "version": "481", + "inputs": [ + { + "key": "system_addInputParam", + "renderTypeList": ["addInputParam"], + "valueType": "dynamic", + "label": "", + "required": false, + "description": "core.module.input.description.HTTP Dynamic Input", + "customInputConfig": { + "selectValueTypeList": [ + "string", + "number", + "boolean", + "object", + "arrayString", + "arrayNumber", + "arrayBoolean", + "arrayObject", + "any", + "chatHistory", + "datasetQuote", + "dynamic", + "selectApp", + "selectDataset" + ], + "showDescription": false, + "showDefaultValue": true + } + }, + { + "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 {{authorization}}" + } + ], + "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 + }, + { + "renderTypeList": ["reference"], + "valueType": "string", + "canEdit": true, + "key": "prompt", + "label": "prompt", + "customInputConfig": { + "selectValueTypeList": [ + "string", + "number", + "boolean", + "object", + "arrayString", + "arrayNumber", + "arrayBoolean", + "arrayObject", + "any", + "chatHistory", + "datasetQuote", + "dynamic", + "selectApp", + "selectDataset" + ], + "showDescription": false, + "showDefaultValue": true + }, + "required": true, + "value": ["pluginInput", "绘图提示词"] + } + ], + "outputs": [ + { + "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" + }, + { + "id": "system_addOutputParam", + "key": "system_addOutputParam", + "type": "dynamic", + "valueType": "dynamic", + "label": "", + "customFieldConfig": { + "selectValueTypeList": [ + "string", + "number", + "boolean", + "object", + "arrayString", + "arrayNumber", + "arrayBoolean", + "arrayObject", + "any", + "chatHistory", + "datasetQuote", + "dynamic", + "selectApp", + "selectDataset" + ], + "showDescription": false, + "showDefaultValue": false + } + }, + { + "id": "pJXgWoTpPoMy", + "valueType": "string", + "type": "dynamic", + "key": "data[0].url", + "label": "data[0].url" + } + ] + } + ], + "edges": [ + { + "source": "pluginInput", + "target": "tMvel910bnrJ", + "sourceHandle": "pluginInput-source-right", + "targetHandle": "tMvel910bnrJ-target-left" + }, + { + "source": "tMvel910bnrJ", + "target": "pluginOutput", + "sourceHandle": "tMvel910bnrJ-source-right", + "targetHandle": "pluginOutput-target-left" + } + ] + } +} diff --git a/projects/app/public/imgs/app/templates/feishu.svg b/projects/app/public/appMarketTemplates/plugin-feishu/avatar.svg similarity index 100% rename from projects/app/public/imgs/app/templates/feishu.svg rename to projects/app/public/appMarketTemplates/plugin-feishu/avatar.svg diff --git a/projects/app/public/appMarketTemplates/plugin-feishu/template.json b/projects/app/public/appMarketTemplates/plugin-feishu/template.json new file mode 100644 index 000000000..33e326d9a --- /dev/null +++ b/projects/app/public/appMarketTemplates/plugin-feishu/template.json @@ -0,0 +1,234 @@ +{ + "name": "飞书 webhook 插件", + "intro": "通过 webhook 给飞书机器人发送一条消息", + "author": "Fastgpt", + "avatar": "/appMarketTemplates/plugin-feishu/avatar.svg", + "type": "plugin", + "tags": ["recommendation", "office-services"], + "workflow": { + "nodes": [ + { + "nodeId": "pluginInput", + "name": "自定义插件输入", + "intro": "自定义配置外部输入,使用插件时,仅暴露自定义配置的输入", + "avatar": "core/workflow/template/workflowStart", + "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": "core/workflow/template/httpRequest", + "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" + }, + { + "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" + } + ] + } +} diff --git a/projects/app/public/appMarketTemplates/simpleDatasetChat/template.json b/projects/app/public/appMarketTemplates/simpleDatasetChat/template.json new file mode 100644 index 000000000..afa55bf5a --- /dev/null +++ b/projects/app/public/appMarketTemplates/simpleDatasetChat/template.json @@ -0,0 +1,337 @@ +{ + "name": "知识库+对话引导", + "intro": "每次提问时进行一次知识库搜索,将搜索结果注入 LLM 模型进行参考回答", + "author": "Fastgpt", + "avatar": "core/workflow/template/datasetSearch", + "type": "simple", + "tags": ["office-services"], + "workflow": { + "nodes": [ + { + "nodeId": "userGuide", + "name": "系统配置", + "intro": "可以配置应用的系统参数", + "avatar": "core/workflow/template/systemConfig", + "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": false + }, + { + "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": "core/workflow/template/workflowStart", + "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": "core/workflow/template/aiChat", + "flowNodeType": "FlowNodeTypeEnum.chatNode", + "showStatus": true, + "position": { + "x": 1638.509551404687, + "y": -341.0428450861567 + }, + "version": "481", + "inputs": [ + { + "key": "model", + "renderTypeList": [ + "FlowNodeInputTypeEnum.settingLLMModel", + "FlowNodeInputTypeEnum.reference" + ], + "label": "core.module.input.label.aiModel", + "valueType": "WorkflowIOValueTypeEnum.string", + "value": "gpt-4o-mini" + }, + { + "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": ["iKBoX2vIzETU", "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": "iKBoX2vIzETU", + "name": "知识库搜索", + "intro": "调用\"语义检索\"和\"全文检索\"能力,从\"知识库\"中查找可能与问题相关的参考内容", + "avatar": "core/workflow/template/datasetSearch", + "flowNodeType": "FlowNodeTypeEnum.datasetSearchNode", + "showStatus": true, + "position": { + "x": 918.5901682164496, + "y": -227.11542247619582 + }, + "version": "481", + "inputs": [ + { + "key": "datasets", + "renderTypeList": [ + "FlowNodeInputTypeEnum.selectDataset", + "FlowNodeInputTypeEnum.reference" + ], + "label": "core.module.input.label.Select dataset", + "value": [], + "valueType": "WorkflowIOValueTypeEnum.selectDataset", + "list": [], + "required": true + }, + { + "key": "similarity", + "renderTypeList": ["FlowNodeInputTypeEnum.selectDatasetParamsModal"], + "label": "", + "value": 0.4, + "valueType": "WorkflowIOValueTypeEnum.number" + }, + { + "key": "limit", + "renderTypeList": ["FlowNodeInputTypeEnum.hidden"], + "label": "", + "value": 1500, + "valueType": "WorkflowIOValueTypeEnum.number" + }, + { + "key": "searchMode", + "renderTypeList": ["FlowNodeInputTypeEnum.hidden"], + "label": "", + "valueType": "WorkflowIOValueTypeEnum.string", + "value": "embedding" + }, + { + "key": "usingReRank", + "renderTypeList": ["FlowNodeInputTypeEnum.hidden"], + "label": "", + "valueType": "WorkflowIOValueTypeEnum.boolean", + "value": false + }, + { + "key": "datasetSearchUsingExtensionQuery", + "renderTypeList": ["FlowNodeInputTypeEnum.hidden"], + "label": "", + "valueType": "WorkflowIOValueTypeEnum.boolean", + "value": true + }, + { + "key": "datasetSearchExtensionModel", + "renderTypeList": ["FlowNodeInputTypeEnum.hidden"], + "label": "", + "valueType": "WorkflowIOValueTypeEnum.string" + }, + { + "key": "datasetSearchExtensionBg", + "renderTypeList": ["FlowNodeInputTypeEnum.hidden"], + "label": "", + "valueType": "WorkflowIOValueTypeEnum.string", + "value": "" + }, + { + "key": "userChatInput", + "renderTypeList": ["FlowNodeInputTypeEnum.reference", "FlowNodeInputTypeEnum.textarea"], + "valueType": "WorkflowIOValueTypeEnum.string", + "label": "用户问题", + "required": true, + "toolDescription": "需要检索的内容", + "value": ["workflowStartNodeId", "userChatInput"] + } + ], + "outputs": [ + { + "id": "quoteQA", + "key": "quoteQA", + "label": "core.module.Dataset quote.label", + "type": "FlowNodeOutputTypeEnum.static", + "valueType": "WorkflowIOValueTypeEnum.datasetQuote", + "description": "特殊数组格式,搜索结果为空时,返回空数组。" + } + ] + } + ], + "edges": [ + { + "source": "workflowStartNodeId", + "target": "iKBoX2vIzETU", + "sourceHandle": "workflowStartNodeId-source-right", + "targetHandle": "iKBoX2vIzETU-target-left" + }, + { + "source": "iKBoX2vIzETU", + "target": "7BdojPlukIQw", + "sourceHandle": "iKBoX2vIzETU-source-right", + "targetHandle": "7BdojPlukIQw-target-left" + } + ] + } +} diff --git a/projects/app/public/appMarketTemplates/srt-translate/template.json b/projects/app/public/appMarketTemplates/srt-translate/template.json new file mode 100644 index 000000000..7e1e2d51d --- /dev/null +++ b/projects/app/public/appMarketTemplates/srt-translate/template.json @@ -0,0 +1,1928 @@ +{ + "name": "长字幕反思翻译机器人", + "intro": "利用 AI 自我反思提升翻译质量,同时循环迭代执行 AI 工作流来突破 LLM tokens 限制,实现一个高效的长字幕翻译机器人", + "author": "Fastgpt", + "avatar": "/appMarketTemplates/TranslateRobot/avatar.svg", + "tags": ["office-services"], + "type": "advanced", + "workflow": { + "nodes": [ + { + "nodeId": "userGuide", + "name": "系统配置", + "intro": "可以配置应用的系统参数", + "avatar": "core/workflow/template/systemConfig", + "flowNodeType": "userGuide", + "position": { + "x": -1453.0815298642474, + "y": 269.10239463914263 + }, + "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": "core/workflow/template/workflowStart", + "flowNodeType": "workflowStart", + "position": { + "x": -1491.3235962441404, + "y": 1277.8094190109027 + }, + "version": "481", + "inputs": [ + { + "key": "userChatInput", + "renderTypeList": ["reference", "textarea"], + "valueType": "string", + "label": "用户问题", + "required": true, + "toolDescription": "用户问题" + } + ], + "outputs": [ + { + "id": "userChatInput", + "key": "userChatInput", + "label": "common:core.module.input.label.user question", + "type": "static", + "valueType": "string" + } + ] + }, + { + "nodeId": "yjFO3YcM7KG2", + "name": "LLM 翻译", + "intro": "AI 大模型对话", + "avatar": "core/workflow/template/aiChat", + "flowNodeType": "chatNode", + "showStatus": true, + "position": { + "x": 2584.1800627074813, + "y": 962.3727118784907 + }, + "version": "481", + "inputs": [ + { + "key": "model", + "renderTypeList": ["settingLLMModel", "reference"], + "label": "core.module.input.label.aiModel", + "valueType": "string", + "selectedTypeIndex": 0, + "value": "gpt-4o" + }, + { + "key": "temperature", + "renderTypeList": ["hidden"], + "label": "", + "value": 3, + "valueType": "number", + "min": 0, + "max": 10, + "step": 1 + }, + { + "key": "maxToken", + "renderTypeList": ["hidden"], + "label": "", + "value": 2000, + "valueType": "number", + "min": 100, + "max": 4000, + "step": 50 + }, + { + "key": "isResponseAnswerText", + "renderTypeList": ["hidden"], + "label": "", + "value": false, + "valueType": "boolean" + }, + { + "key": "quoteTemplate", + "renderTypeList": ["hidden"], + "label": "", + "valueType": "string" + }, + { + "key": "quotePrompt", + "renderTypeList": ["hidden"], + "label": "", + "valueType": "string" + }, + { + "key": "aiChatVision", + "renderTypeList": ["hidden"], + "label": "", + "valueType": "boolean", + "value": true + }, + { + "key": "systemPrompt", + "renderTypeList": ["textarea", "reference"], + "max": 3000, + "valueType": "string", + "label": "core.ai.Prompt", + "description": "core.app.tip.chatNodeSystemPromptTip", + "placeholder": "core.app.tip.chatNodeSystemPromptTip", + "value": "# Role: 资深字幕翻译专家\n\n## Background:\n你是一位经验丰富的{{source_lang}}和{{target_lang}}字幕翻译专家,精通{{source_lang}}和{{target_lang}}互译,尤其擅长将{{source_lang}}字幕译成流畅易懂的{{target_lang}}字幕。你曾多次带领团队完成大型商业电影的字幕翻译项目,所翻译的字幕广受好评。\n\n## Attention:\n- 翻译过程中要始终坚持\"信、达、雅\"的原则,但\"达\"尤为重要\n- 翻译的字幕要符合{{target_lang}}的表达习惯,通俗易懂,连贯流畅\n- 避免使用过于文绉绉的表达和晦涩难懂的典故引用 \n- 诗词歌词等内容需按原文换行和节奏分行,不破坏原排列格式 \n- 翻译对象是字幕,请进入整段文本的语境中对需要翻译的文本段进行翻译\n- 是标识每一帧字幕的标签,请严格按照对文本的分割逐帧翻译\n\n## Constraints:\n- 必须严格遵循四轮翻译流程:直译、意译、反思、提升\n- 译文要忠实原文,准确无误,不能遗漏或曲解原意\n- 最终译文使用Markdown的代码块呈现,但是不用输出markdown这个单词\n- 是标识每一帧字幕的标签,请严格按照对文本的分割逐帧翻译,每一帧字幕末尾不要加\\n 回车标识,且第一帧字幕开头不需要加标识\n\n## Goals:\n- 通过四轮翻译流程,将{{source_lang}}字幕译成高质量的{{target_lang}}字幕\n- 翻译的字幕要准确传达原字幕意思,语言表达力求浅显易懂,朗朗上口 \n\n## Workflow:\n1. 第一轮直译:严格按照逐句翻译,不遗漏任何信息\n2. 第二轮意译:在直译的基础上用通俗流畅的{{target_lang}}意译原文,逐句翻译,保留标识标签\n3. 第三轮反思:仔细审视译文,分点列出一份建设性的批评和有用的建议清单以改进翻译,对每一句话提出建议,从以下四个角度展开\n (i) 准确性(纠正添加、误译、遗漏或未翻译的文本错误),\n (ii) 流畅性(应用{{target_lang}}的语法、拼写和标点规则,并确保没有不必要的重复),\n (iii) 风格(确保翻译反映源文本的风格并考虑其文化背景),\n (iv) 术语(确保术语使用一致且反映源文本所在领域,注意确保使用{{target_lang}}中的等效习语)\n4. 第四轮提升:严格遵循第三轮提出的建议对翻译修改,定稿出一个简洁畅达、符合大众观影习惯的字幕译文,保留标识标签\n\n## OutputFormat:\n- 每一轮前用【思考】说明该轮要点\n- 第一轮和第二轮翻译后用【翻译】呈现译文\n- 第三轮输出建议清单,分点列出,在每一点前用*xxx*标识这条建议对应的要点,如*风格*;建议前用【思考】说明该轮要点,建议后用【建议】呈现建议\n- 第四轮在\\`\\`\\`代码块中展示最终{{target_lang}}字幕文件内容,如\\`\\`\\`xxx\\`\\`\\`\n\n## Suggestions:\n- 直译时力求忠实原文,但注意控制每帧字幕的字数,必要时进行精简压缩\n- 意译时在准确表达原意的基础上,用最朴实无华的{{target_lang}}来表达\n- 反思环节重点关注译文是否符合{{target_lang}}表达习惯,是否通俗易懂,是否准确流畅,是否术语一致\n- 提升环节采用反思环节的建议对意译环节的翻译进行修改,适度采用一些口语化的表达、网络流行语等,增强字幕的亲和力\n- 注意是很重要的标识标签,请确保标签能在正确位置输出" + }, + { + "key": "history", + "renderTypeList": ["numberInput", "reference"], + "valueType": "chatHistory", + "label": "core.module.input.label.chat history", + "description": "最多携带多少轮对话记录", + "required": true, + "min": 0, + "max": 50, + "value": 6 + }, + { + "key": "quoteQA", + "renderTypeList": ["settingDatasetQuotePrompt"], + "label": "", + "debugLabel": "知识库引用", + "description": "", + "valueType": "datasetQuote" + }, + { + "key": "stringQuoteText", + "renderTypeList": ["reference", "textarea"], + "label": "app:document_quote", + "debugLabel": "app:document_quote", + "description": "app:document_quote_tip", + "valueType": "string" + }, + { + "key": "userChatInput", + "renderTypeList": ["reference", "textarea"], + "valueType": "string", + "label": "用户问题", + "required": true, + "toolDescription": "用户问题", + "value": ["bxz97Vg4Omux", "system_text"] + } + ], + "outputs": [ + { + "id": "history", + "key": "history", + "required": true, + "label": "core.module.output.label.New context", + "description": "core.module.output.description.New context", + "valueType": "chatHistory", + "type": "static" + }, + { + "id": "answerText", + "key": "answerText", + "required": true, + "label": "core.module.output.label.Ai response content", + "description": "core.module.output.description.Ai response content", + "valueType": "string", + "type": "static" + } + ] + }, + { + "nodeId": "bxz97Vg4Omux", + "name": "LLM 翻译提示词", + "intro": "可对固定或传入的文本进行加工后输出,非字符串类型数据最终会转成字符串类型。", + "avatar": "core/workflow/template/textConcat", + "flowNodeType": "textEditor", + "position": { + "x": 1881.9891746911078, + "y": 1112.4113692581143 + }, + "version": "486", + "inputs": [ + { + "key": "system_addInputParam", + "renderTypeList": ["addInputParam"], + "valueType": "dynamic", + "label": "", + "required": false, + "description": "可以引用其他节点的输出,作为文本拼接的变量,通过 {{字段名}} 来引用变量", + "customInputConfig": { + "selectValueTypeList": [ + "string", + "number", + "boolean", + "object", + "arrayString", + "arrayNumber", + "arrayBoolean", + "arrayObject", + "any", + "chatHistory", + "datasetQuote", + "dynamic", + "selectApp", + "selectDataset" + ], + "showDescription": false, + "showDefaultValue": false + } + }, + { + "key": "system_textareaInput", + "renderTypeList": ["textarea"], + "valueType": "string", + "required": true, + "label": "拼接文本", + "placeholder": "可通过 {{字段名}} 来引用变量", + "value": "你的任务是将文本从{{source_lang}}翻译成{{target_lang}}\n\n源文本如下,由XML标签分隔:\n\n\n\n{{tagged_text}}\n\n\n\n仅翻译源文本中由分隔的部分,将其余的源文本作为上下文\n\n重申一下,你应该只翻译文本的这一部分,这里再次显示在之间:\n\n\n\n{{chunk_to_translate}}\n\n" + }, + { + "renderTypeList": ["reference"], + "valueType": "string", + "canEdit": true, + "key": "tagged_text", + "label": "tagged_text", + "customInputConfig": { + "selectValueTypeList": [ + "string", + "number", + "boolean", + "object", + "arrayString", + "arrayNumber", + "arrayBoolean", + "arrayObject", + "any", + "chatHistory", + "datasetQuote", + "dynamic", + "selectApp", + "selectDataset" + ], + "showDescription": false, + "showDefaultValue": false + }, + "required": true, + "value": ["quYZgsW32ApA", "xhXu6sdEWBnF"] + }, + { + "renderTypeList": ["reference"], + "valueType": "string", + "canEdit": true, + "key": "chunk_to_translate", + "label": "chunk_to_translate", + "customInputConfig": { + "selectValueTypeList": [ + "string", + "number", + "boolean", + "object", + "arrayString", + "arrayNumber", + "arrayBoolean", + "arrayObject", + "any", + "chatHistory", + "datasetQuote", + "dynamic", + "selectApp", + "selectDataset" + ], + "showDescription": false, + "showDefaultValue": false + }, + "required": true, + "value": ["quYZgsW32ApA", "eCp73lztAEGK"] + } + ], + "outputs": [ + { + "id": "system_text", + "key": "system_text", + "label": "拼接结果", + "type": "static", + "valueType": "string" + } + ] + }, + { + "nodeId": "w4heEpNflz59", + "name": "判断是否执行结束", + "intro": "根据一定的条件,执行不同的分支。", + "avatar": "core/workflow/template/ifelse", + "flowNodeType": "ifElseNode", + "showStatus": true, + "position": { + "x": 5610.256715310997, + "y": 1232.1024649538042 + }, + "version": "481", + "inputs": [ + { + "key": "ifElseList", + "renderTypeList": ["hidden"], + "valueType": "any", + "label": "", + "value": [ + { + "condition": "AND", + "list": [ + { + "variable": ["a2lqxASWi1vb", "nmBmGaARbKkl"], + "condition": "equalTo", + "value": "true" + } + ] + } + ] + } + ], + "outputs": [ + { + "id": "ifElseResult", + "key": "ifElseResult", + "label": "判断结果", + "valueType": "string", + "type": "static" + } + ] + }, + { + "nodeId": "a2lqxASWi1vb", + "name": "判断是否执行结束", + "intro": "执行一段简单的脚本代码,通常用于进行复杂的数据处理。", + "avatar": "core/workflow/template/codeRun", + "flowNodeType": "code", + "showStatus": true, + "position": { + "x": 5068.150809685475, + "y": 940.8168438455639 + }, + "version": "482", + "inputs": [ + { + "key": "system_addInputParam", + "renderTypeList": ["addInputParam"], + "valueType": "dynamic", + "label": "", + "required": false, + "description": "这些变量会作为代码的运行的输入参数", + "customInputConfig": { + "selectValueTypeList": [ + "string", + "number", + "boolean", + "object", + "arrayString", + "arrayNumber", + "arrayBoolean", + "arrayObject", + "any", + "chatHistory", + "datasetQuote", + "dynamic", + "selectApp", + "selectDataset" + ], + "showDescription": false, + "showDefaultValue": true + } + }, + { + "key": "codeType", + "renderTypeList": ["hidden"], + "label": "", + "value": "js" + }, + { + "key": "code", + "renderTypeList": ["custom"], + "label": "", + "value": "function main({chunks, currentChunk}){\n const findIndex = chunks.findIndex((item) => item === currentChunk)\n\n return {\n isEnd: chunks.length-1 === findIndex,\n i: findIndex + 1,\n }\n}" + }, + { + "renderTypeList": ["reference"], + "valueType": "arrayString", + "canEdit": true, + "key": "chunks", + "label": "chunks", + "customInputConfig": { + "selectValueTypeList": [ + "string", + "number", + "boolean", + "object", + "arrayString", + "arrayNumber", + "arrayBoolean", + "arrayObject", + "any", + "chatHistory", + "datasetQuote", + "dynamic", + "selectApp", + "selectDataset" + ], + "showDescription": false, + "showDefaultValue": true + }, + "required": true, + "value": ["y3WEYOQ09CGC", "qLUQfhG0ILRX"] + }, + { + "renderTypeList": ["reference"], + "valueType": "string", + "canEdit": true, + "key": "currentChunk", + "label": "currentChunk", + "customInputConfig": { + "selectValueTypeList": [ + "string", + "number", + "boolean", + "object", + "arrayString", + "arrayNumber", + "arrayBoolean", + "arrayObject", + "any", + "chatHistory", + "datasetQuote", + "dynamic", + "selectApp", + "selectDataset" + ], + "showDescription": false, + "showDefaultValue": true + }, + "required": true, + "value": ["quYZgsW32ApA", "eCp73lztAEGK"] + } + ], + "outputs": [ + { + "id": "system_rawResponse", + "key": "system_rawResponse", + "label": "完整响应数据", + "valueType": "object", + "type": "static" + }, + { + "id": "error", + "key": "error", + "label": "运行错误", + "description": "代码运行错误信息,成功时返回空", + "valueType": "object", + "type": "static" + }, + { + "id": "system_addOutputParam", + "key": "system_addOutputParam", + "type": "dynamic", + "valueType": "dynamic", + "label": "", + "customFieldConfig": { + "selectValueTypeList": [ + "string", + "number", + "boolean", + "object", + "arrayString", + "arrayNumber", + "arrayBoolean", + "arrayObject", + "any", + "chatHistory", + "datasetQuote", + "dynamic", + "selectApp", + "selectDataset" + ], + "showDescription": false, + "showDefaultValue": false + }, + "description": "将代码中 return 的对象作为输出,传递给后续的节点。变量名需要对应 return 的 key" + }, + { + "id": "nmBmGaARbKkl", + "valueType": "boolean", + "type": "dynamic", + "key": "isEnd", + "label": "isEnd" + }, + { + "id": "nqB98uKpq6Ig", + "valueType": "number", + "type": "dynamic", + "key": "i", + "label": "i" + } + ] + }, + { + "nodeId": "quYZgsW32ApA", + "name": "格式化源文本块", + "intro": "执行一段简单的脚本代码,通常用于进行复杂的数据处理。", + "avatar": "core/workflow/template/codeRun", + "flowNodeType": "code", + "showStatus": true, + "position": { + "x": 1306.0466226590386, + "y": 1038.0950796039954 + }, + "version": "482", + "inputs": [ + { + "key": "system_addInputParam", + "renderTypeList": ["addInputParam"], + "valueType": "dynamic", + "label": "", + "required": false, + "description": "这些变量会作为代码的运行的输入参数", + "customInputConfig": { + "selectValueTypeList": [ + "string", + "number", + "boolean", + "object", + "arrayString", + "arrayNumber", + "arrayBoolean", + "arrayObject", + "any", + "chatHistory", + "datasetQuote", + "dynamic", + "selectApp", + "selectDataset" + ], + "showDescription": false, + "showDefaultValue": true + } + }, + { + "key": "codeType", + "renderTypeList": ["hidden"], + "label": "", + "value": "js" + }, + { + "key": "code", + "renderTypeList": ["custom"], + "label": "", + "value": "function main({source_text_chunks, i=0}){\n let before = source_text_chunks.slice(0, i).join(\"\");\n let current = \" \" + source_text_chunks[i] + \"\";\n let after = source_text_chunks.slice(i + 1).join(\"\");\n let tagged_text = before + current + after;\n\n return {\n tagged_text,\n chunk_to_translate: source_text_chunks[i],\n }\n}" + }, + { + "renderTypeList": ["reference"], + "valueType": "number", + "canEdit": true, + "key": "i", + "label": "i", + "customInputConfig": { + "selectValueTypeList": [ + "string", + "number", + "boolean", + "object", + "arrayString", + "arrayNumber", + "arrayBoolean", + "arrayObject", + "any", + "chatHistory", + "datasetQuote", + "dynamic", + "selectApp", + "selectDataset" + ], + "showDescription": false, + "showDefaultValue": true + }, + "required": true, + "value": ["a2lqxASWi1vb", "nqB98uKpq6Ig"] + }, + { + "renderTypeList": ["reference"], + "valueType": "arrayString", + "canEdit": true, + "key": "source_text_chunks", + "label": "source_text_chunks", + "customInputConfig": { + "selectValueTypeList": [ + "string", + "number", + "boolean", + "object", + "arrayString", + "arrayNumber", + "arrayBoolean", + "arrayObject", + "any", + "chatHistory", + "datasetQuote", + "dynamic", + "selectApp", + "selectDataset" + ], + "showDescription": false, + "showDefaultValue": true + }, + "required": true, + "value": ["y3WEYOQ09CGC", "qLUQfhG0ILRX"] + } + ], + "outputs": [ + { + "id": "system_rawResponse", + "key": "system_rawResponse", + "label": "完整响应数据", + "valueType": "object", + "type": "static" + }, + { + "id": "error", + "key": "error", + "label": "运行错误", + "description": "代码运行错误信息,成功时返回空", + "valueType": "object", + "type": "static" + }, + { + "id": "system_addOutputParam", + "key": "system_addOutputParam", + "type": "dynamic", + "valueType": "dynamic", + "label": "", + "customFieldConfig": { + "selectValueTypeList": [ + "string", + "number", + "boolean", + "object", + "arrayString", + "arrayNumber", + "arrayBoolean", + "arrayObject", + "any", + "chatHistory", + "datasetQuote", + "dynamic", + "selectApp", + "selectDataset" + ], + "showDescription": false, + "showDefaultValue": false + }, + "description": "将代码中 return 的对象作为输出,传递给后续的节点。变量名需要对应 return 的 key" + }, + { + "id": "xhXu6sdEWBnF", + "valueType": "string", + "type": "dynamic", + "key": "tagged_text", + "label": "tagged_text" + }, + { + "id": "eCp73lztAEGK", + "valueType": "string", + "type": "dynamic", + "key": "chunk_to_translate", + "label": "chunk_to_translate" + } + ] + }, + { + "nodeId": "izsNX8FXGD1t", + "name": "指定回复", + "intro": "该模块可以直接回复一段指定的内容。常用于引导、提示。非字符串内容传入时,会转成字符串进行输出。", + "avatar": "core/workflow/template/reply", + "flowNodeType": "answerNode", + "position": { + "x": 6412.138830862469, + "y": 1235.7269544046057 + }, + "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": "\n\n*** 字幕反思翻译完成!***" + } + ], + "outputs": [] + }, + { + "nodeId": "vlNHndpNuFXB", + "name": "取出 LLM 翻译第四轮文本", + "intro": "执行一段简单的脚本代码,通常用于进行复杂的数据处理。", + "avatar": "core/workflow/template/codeRun", + "flowNodeType": "code", + "showStatus": true, + "position": { + "x": 3292.3569279448307, + "y": 996.4264559884845 + }, + "version": "482", + "inputs": [ + { + "key": "system_addInputParam", + "renderTypeList": ["addInputParam"], + "valueType": "dynamic", + "label": "", + "required": false, + "description": "这些变量会作为代码的运行的输入参数", + "editField": { + "key": true, + "valueType": true + }, + "customInputConfig": { + "selectValueTypeList": [ + "string", + "number", + "boolean", + "object", + "arrayString", + "arrayNumber", + "arrayBoolean", + "arrayObject", + "any", + "chatHistory", + "datasetQuote", + "dynamic", + "selectApp", + "selectDataset" + ], + "showDescription": false, + "showDefaultValue": true + } + }, + { + "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].trim() \n }\n }\n\n return {\n result: '未截取到翻译内容'\n }\n}" + }, + { + "key": "data1", + "valueType": "string", + "label": "data1", + "renderTypeList": ["reference"], + "description": "", + "canEdit": true, + "editField": { + "key": true, + "valueType": true + }, + "value": ["yjFO3YcM7KG2", "answerText"], + "customInputConfig": { + "selectValueTypeList": [ + "string", + "number", + "boolean", + "object", + "arrayString", + "arrayNumber", + "arrayBoolean", + "arrayObject", + "any", + "chatHistory", + "datasetQuote", + "dynamic", + "selectApp", + "selectDataset" + ], + "showDescription": false, + "showDefaultValue": true + } + } + ], + "outputs": [ + { + "id": "system_rawResponse", + "key": "system_rawResponse", + "label": "完整响应数据", + "valueType": "object", + "type": "static" + }, + { + "id": "error", + "key": "error", + "label": "运行错误", + "description": "代码运行错误信息,成功时返回空", + "valueType": "object", + "type": "static" + }, + { + "id": "system_addOutputParam", + "key": "system_addOutputParam", + "type": "dynamic", + "valueType": "dynamic", + "label": "", + "customFieldConfig": { + "selectValueTypeList": [ + "string", + "number", + "boolean", + "object", + "arrayString", + "arrayNumber", + "arrayBoolean", + "arrayObject", + "any", + "chatHistory", + "datasetQuote", + "dynamic", + "selectApp", + "selectDataset" + ], + "showDescription": false, + "showDefaultValue": false + }, + "description": "将代码中 return 的对象作为输出,传递给后续的节点。变量名需要对应 return 的 key" + }, + { + "id": "qLUQfhG0ILRX", + "type": "dynamic", + "key": "result", + "valueType": "string", + "label": "result" + }, + { + "id": "gR0mkQpJ4Og8", + "type": "dynamic", + "key": "data2", + "valueType": "string", + "label": "data2" + } + ] + }, + { + "nodeId": "qlt9KJbbS9yJ", + "name": "判断源语言和目标语言是否相同", + "intro": "根据一定的条件,执行不同的分支。", + "avatar": "core/workflow/template/ifelse", + "flowNodeType": "ifElseNode", + "showStatus": true, + "position": { + "x": -646.0682391158168, + "y": 1352.6591494737195 + }, + "version": "481", + "inputs": [ + { + "key": "ifElseList", + "renderTypeList": ["hidden"], + "valueType": "any", + "label": "", + "value": [ + { + "condition": "AND", + "list": [ + { + "variable": ["frjbsrlnJJsR", "qLUQfhG0ILRX"], + "condition": "equalTo", + "value": "false" + } + ] + } + ] + } + ], + "outputs": [ + { + "id": "ifElseResult", + "key": "ifElseResult", + "label": "判断结果", + "valueType": "string", + "type": "static" + } + ] + }, + { + "nodeId": "frjbsrlnJJsR", + "name": "判断源语言和目标语言是否相同", + "intro": "执行一段简单的脚本代码,通常用于进行复杂的数据处理。", + "avatar": "core/workflow/template/codeRun", + "flowNodeType": "code", + "showStatus": true, + "position": { + "x": -1152.6572772702038, + "y": 1092.3001349756628 + }, + "version": "482", + "inputs": [ + { + "key": "system_addInputParam", + "renderTypeList": ["addInputParam"], + "valueType": "dynamic", + "label": "", + "required": false, + "description": "这些变量会作为代码的运行的输入参数", + "customInputConfig": { + "selectValueTypeList": [ + "string", + "number", + "boolean", + "object", + "arrayString", + "arrayNumber", + "arrayBoolean", + "arrayObject", + "any", + "chatHistory", + "datasetQuote", + "dynamic", + "selectApp", + "selectDataset" + ], + "showDescription": false, + "showDefaultValue": true + } + }, + { + "key": "codeType", + "renderTypeList": ["hidden"], + "label": "", + "value": "js" + }, + { + "key": "code", + "renderTypeList": ["custom"], + "label": "", + "value": "function main({source_lang, target_lang}){\n \n return {\n result: source_lang === target_lang\n }\n}" + }, + { + "renderTypeList": ["reference"], + "valueType": "string", + "canEdit": true, + "key": "source_lang", + "label": "source_lang", + "customInputConfig": { + "selectValueTypeList": [ + "string", + "number", + "boolean", + "object", + "arrayString", + "arrayNumber", + "arrayBoolean", + "arrayObject", + "any", + "chatHistory", + "datasetQuote", + "dynamic", + "selectApp", + "selectDataset" + ], + "showDescription": false, + "showDefaultValue": true + }, + "required": true, + "value": ["VARIABLE_NODE_ID", "source_lang"] + }, + { + "renderTypeList": ["reference"], + "valueType": "string", + "canEdit": true, + "key": "target_lang", + "label": "target_lang", + "customInputConfig": { + "selectValueTypeList": [ + "string", + "number", + "boolean", + "object", + "arrayString", + "arrayNumber", + "arrayBoolean", + "arrayObject", + "any", + "chatHistory", + "datasetQuote", + "dynamic", + "selectApp", + "selectDataset" + ], + "showDescription": false, + "showDefaultValue": true + }, + "required": true, + "value": ["VARIABLE_NODE_ID", "target_lang"] + } + ], + "outputs": [ + { + "id": "system_rawResponse", + "key": "system_rawResponse", + "label": "完整响应数据", + "valueType": "object", + "type": "static" + }, + { + "id": "error", + "key": "error", + "label": "运行错误", + "description": "代码运行错误信息,成功时返回空", + "valueType": "object", + "type": "static" + }, + { + "id": "system_addOutputParam", + "key": "system_addOutputParam", + "type": "dynamic", + "valueType": "dynamic", + "label": "", + "customFieldConfig": { + "selectValueTypeList": [ + "string", + "number", + "boolean", + "object", + "arrayString", + "arrayNumber", + "arrayBoolean", + "arrayObject", + "any", + "chatHistory", + "datasetQuote", + "dynamic", + "selectApp", + "selectDataset" + ], + "showDescription": false, + "showDefaultValue": false + }, + "description": "将代码中 return 的对象作为输出,传递给后续的节点。变量名需要对应 return 的 key" + }, + { + "id": "qLUQfhG0ILRX", + "type": "dynamic", + "key": "result", + "valueType": "boolean", + "label": "result" + } + ] + }, + { + "nodeId": "dFxrGZS3Wmnz", + "name": "提示源语言与目标语言相同", + "intro": "该模块可以直接回复一段指定的内容。常用于引导、提示。非字符串内容传入时,会转成字符串进行输出。", + "avatar": "core/workflow/template/reply", + "flowNodeType": "answerNode", + "position": { + "x": -523.8880105943567, + "y": 1735.994691812213 + }, + "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": 0, + "value": "{{source_lang}} 无需再次翻译为 {{target_lang}} ~" + } + ], + "outputs": [] + }, + { + "nodeId": "tqzmK5oPR9BA", + "name": "输出翻译", + "intro": "该模块可以直接回复一段指定的内容。常用于引导、提示。非字符串内容传入时,会转成字符串进行输出。", + "avatar": "core/workflow/template/reply", + "flowNodeType": "answerNode", + "position": { + "x": 4368.135274121754, + "y": 1308.859868496928 + }, + "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": ["ppPP6o7YYSTJ", "dYalXmYJ60bj"] + } + ], + "outputs": [] + }, + { + "nodeId": "kbr342XlxSZR", + "name": "提取字幕信息", + "intro": "执行一段简单的脚本代码,通常用于进行复杂的数据处理。", + "avatar": "core/workflow/template/codeRun", + "flowNodeType": "code", + "showStatus": true, + "position": { + "x": 207.77750594024815, + "y": 1057.1062190161417 + }, + "version": "482", + "inputs": [ + { + "key": "system_addInputParam", + "renderTypeList": ["addInputParam"], + "valueType": "dynamic", + "label": "", + "required": false, + "description": "这些变量会作为代码的运行的输入参数", + "customInputConfig": { + "selectValueTypeList": [ + "string", + "number", + "boolean", + "object", + "arrayString", + "arrayNumber", + "arrayBoolean", + "arrayObject", + "any", + "chatHistory", + "datasetQuote", + "dynamic", + "selectApp", + "selectDataset" + ], + "showDescription": false, + "showDefaultValue": true + } + }, + { + "key": "codeType", + "renderTypeList": ["hidden"], + "label": "", + "value": "js" + }, + { + "key": "code", + "renderTypeList": ["custom"], + "label": "", + "value": "function main({text}){\n const lines = text.split('\\n');\n const timePattern = /\\d{2}:\\d{2}:\\d{2},\\d{3} --> \\d{2}:\\d{2}:\\d{2},\\d{3}/;\n const numberInfo = [];\n const timeInfo = [];\n const textInfo = [];\n let currentText = [];\n\n // 提取序号、时间戳和文本信息\n lines.forEach(line => {\n if (/^\\d+$/.test(line.trim())) {\n numberInfo.push(line.trim());\n } else if (timePattern.test(line)) {\n timeInfo.push(line);\n if (currentText.length > 0) {\n textInfo.push(currentText.join(' '));\n currentText = [];\n }\n } else if (line.trim() === '') {\n // Skip empty lines\n } else {\n currentText.push(line.trim());\n }\n });\n\n if (currentText.length > 0) {\n textInfo.push(currentText.join(' '));\n }\n\n return { numberInfo, timeInfo, textInfo };\n}" + }, + { + "renderTypeList": ["reference"], + "valueType": "string", + "canEdit": true, + "key": "text", + "label": "text", + "customInputConfig": { + "selectValueTypeList": [ + "string", + "number", + "boolean", + "object", + "arrayString", + "arrayNumber", + "arrayBoolean", + "arrayObject", + "any", + "chatHistory", + "datasetQuote", + "dynamic", + "selectApp", + "selectDataset" + ], + "showDescription": false, + "showDefaultValue": true + }, + "required": true, + "value": ["448745", "userChatInput"] + } + ], + "outputs": [ + { + "id": "system_rawResponse", + "key": "system_rawResponse", + "label": "完整响应数据", + "valueType": "object", + "type": "static" + }, + { + "id": "error", + "key": "error", + "label": "运行错误", + "description": "代码运行错误信息,成功时返回空", + "valueType": "object", + "type": "static" + }, + { + "id": "system_addOutputParam", + "key": "system_addOutputParam", + "type": "dynamic", + "valueType": "dynamic", + "label": "", + "customFieldConfig": { + "selectValueTypeList": [ + "string", + "number", + "boolean", + "object", + "arrayString", + "arrayNumber", + "arrayBoolean", + "arrayObject", + "any", + "chatHistory", + "datasetQuote", + "dynamic", + "selectApp", + "selectDataset" + ], + "showDescription": false, + "showDefaultValue": false + }, + "description": "将代码中 return 的对象作为输出,传递给后续的节点。变量名需要对应 return 的 key" + }, + { + "id": "h3qVuGhV9HNm", + "valueType": "arrayString", + "type": "dynamic", + "key": "timeInfo", + "label": "timeInfo" + }, + { + "id": "zGYRMNA9xGuI", + "valueType": "arrayString", + "type": "dynamic", + "key": "textInfo", + "label": "textInfo" + }, + { + "id": "dhzTt6Riz8Dp", + "valueType": "arrayString", + "type": "dynamic", + "key": "numberInfo", + "label": "numberInfo" + } + ] + }, + { + "nodeId": "ppPP6o7YYSTJ", + "name": "格式化字幕文件", + "intro": "执行一段简单的脚本代码,通常用于进行复杂的数据处理。", + "avatar": "core/workflow/template/codeRun", + "flowNodeType": "code", + "showStatus": true, + "position": { + "x": 3830.732983153034, + "y": 828.5283022715971 + }, + "version": "482", + "inputs": [ + { + "key": "system_addInputParam", + "renderTypeList": ["addInputParam"], + "valueType": "dynamic", + "label": "", + "required": false, + "description": "这些变量会作为代码的运行的输入参数", + "customInputConfig": { + "selectValueTypeList": [ + "string", + "number", + "boolean", + "object", + "arrayString", + "arrayNumber", + "arrayBoolean", + "arrayObject", + "any", + "chatHistory", + "datasetQuote", + "dynamic", + "selectApp", + "selectDataset" + ], + "showDescription": false, + "showDefaultValue": true + } + }, + { + "key": "codeType", + "renderTypeList": ["hidden"], + "label": "", + "value": "js" + }, + { + "key": "code", + "renderTypeList": ["custom"], + "label": "", + "value": "function main({combinedText, transedText, timeInfo, currentIndex=0,numberInfo}){\n const textLines = combinedText.split('');\n const resultLines = transedText.split('');\n const combinedLines = [];\n\n resultLines.forEach((line, index) => {\n combinedLines.push(numberInfo[currentIndex+index]);\n combinedLines.push(timeInfo[currentIndex+index]);\n combinedLines.push(line)\n combinedLines.push(textLines[index]);\n combinedLines.push('');\n });\n\n const srtContent = combinedLines.join('\\n');\n \n\n return {\n srtContent,\n currentIndex: currentIndex+textLines.length\n }\n}" + }, + { + "renderTypeList": ["reference"], + "valueType": "string", + "canEdit": true, + "key": "combinedText", + "label": "combinedText", + "customInputConfig": { + "selectValueTypeList": [ + "string", + "number", + "boolean", + "object", + "arrayString", + "arrayNumber", + "arrayBoolean", + "arrayObject", + "any", + "chatHistory", + "datasetQuote", + "dynamic", + "selectApp", + "selectDataset" + ], + "showDescription": false, + "showDefaultValue": true + }, + "required": true, + "value": ["quYZgsW32ApA", "eCp73lztAEGK"] + }, + { + "renderTypeList": ["reference"], + "valueType": "string", + "canEdit": true, + "key": "transedText", + "label": "transedText", + "customInputConfig": { + "selectValueTypeList": [ + "string", + "number", + "boolean", + "object", + "arrayString", + "arrayNumber", + "arrayBoolean", + "arrayObject", + "any", + "chatHistory", + "datasetQuote", + "dynamic", + "selectApp", + "selectDataset" + ], + "showDescription": false, + "showDefaultValue": true + }, + "required": true, + "value": ["vlNHndpNuFXB", "qLUQfhG0ILRX"] + }, + { + "renderTypeList": ["reference"], + "valueType": "arrayString", + "canEdit": true, + "key": "timeInfo", + "label": "timeInfo", + "customInputConfig": { + "selectValueTypeList": [ + "string", + "number", + "boolean", + "object", + "arrayString", + "arrayNumber", + "arrayBoolean", + "arrayObject", + "any", + "chatHistory", + "datasetQuote", + "dynamic", + "selectApp", + "selectDataset" + ], + "showDescription": false, + "showDefaultValue": true + }, + "required": true, + "value": ["kbr342XlxSZR", "h3qVuGhV9HNm"] + }, + { + "renderTypeList": ["reference"], + "valueType": "number", + "canEdit": true, + "key": "currentIndex", + "label": "currentIndex", + "customInputConfig": { + "selectValueTypeList": [ + "string", + "number", + "boolean", + "object", + "arrayString", + "arrayNumber", + "arrayBoolean", + "arrayObject", + "any", + "chatHistory", + "datasetQuote", + "dynamic", + "selectApp", + "selectDataset" + ], + "showDescription": false, + "showDefaultValue": true + }, + "required": true, + "value": ["ppPP6o7YYSTJ", "u6eqeC0pEPe0"] + }, + { + "renderTypeList": ["reference"], + "valueType": "arrayString", + "canEdit": true, + "key": "numberInfo", + "label": "numberInfo", + "customInputConfig": { + "selectValueTypeList": [ + "string", + "number", + "boolean", + "object", + "arrayString", + "arrayNumber", + "arrayBoolean", + "arrayObject", + "any", + "chatHistory", + "datasetQuote", + "dynamic", + "selectApp", + "selectDataset" + ], + "showDescription": false, + "showDefaultValue": true + }, + "required": true, + "value": ["kbr342XlxSZR", "dhzTt6Riz8Dp"] + } + ], + "outputs": [ + { + "id": "system_rawResponse", + "key": "system_rawResponse", + "label": "完整响应数据", + "valueType": "object", + "type": "static" + }, + { + "id": "error", + "key": "error", + "label": "运行错误", + "description": "代码运行错误信息,成功时返回空", + "valueType": "object", + "type": "static" + }, + { + "id": "system_addOutputParam", + "key": "system_addOutputParam", + "type": "dynamic", + "valueType": "dynamic", + "label": "", + "customFieldConfig": { + "selectValueTypeList": [ + "string", + "number", + "boolean", + "object", + "arrayString", + "arrayNumber", + "arrayBoolean", + "arrayObject", + "any", + "chatHistory", + "datasetQuote", + "dynamic", + "selectApp", + "selectDataset" + ], + "showDescription": false, + "showDefaultValue": false + }, + "description": "将代码中 return 的对象作为输出,传递给后续的节点。变量名需要对应 return 的 key" + }, + { + "id": "dYalXmYJ60bj", + "valueType": "string", + "type": "dynamic", + "key": "srtContent", + "label": "srtContent" + }, + { + "id": "u6eqeC0pEPe0", + "valueType": "number", + "type": "dynamic", + "key": "currentIndex", + "label": "currentIndex" + } + ] + }, + { + "nodeId": "y3WEYOQ09CGC", + "name": "切分文本", + "intro": "执行一段简单的脚本代码,通常用于进行复杂的数据处理。", + "avatar": "core/workflow/template/codeRun", + "flowNodeType": "code", + "showStatus": true, + "position": { + "x": 778.9569641790565, + "y": 1108.0575844436903 + }, + "version": "482", + "inputs": [ + { + "key": "system_addInputParam", + "renderTypeList": ["addInputParam"], + "valueType": "dynamic", + "label": "", + "required": false, + "description": "这些变量会作为代码的运行的输入参数", + "customInputConfig": { + "selectValueTypeList": [ + "string", + "number", + "boolean", + "object", + "arrayString", + "arrayNumber", + "arrayBoolean", + "arrayObject", + "any", + "chatHistory", + "datasetQuote", + "dynamic", + "selectApp", + "selectDataset" + ], + "showDescription": false, + "showDefaultValue": true + } + }, + { + "key": "codeType", + "renderTypeList": ["hidden"], + "label": "", + "value": "js" + }, + { + "key": "code", + "renderTypeList": ["custom"], + "label": "", + "value": "function main({textArray}){\n const groupSize = 40\n const delimiter = ''\n\n const result = [];\n\n for (let i = 0; i < textArray.length; i += groupSize) {\n result.push(textArray.slice(i, i + groupSize).join(delimiter));\n }\n\n return {result};\n}" + }, + { + "renderTypeList": ["reference"], + "valueType": "arrayString", + "canEdit": true, + "key": "textArray", + "label": "textArray", + "customInputConfig": { + "selectValueTypeList": [ + "string", + "number", + "boolean", + "object", + "arrayString", + "arrayNumber", + "arrayBoolean", + "arrayObject", + "any", + "chatHistory", + "datasetQuote", + "dynamic", + "selectApp", + "selectDataset" + ], + "showDescription": false, + "showDefaultValue": true + }, + "required": true, + "value": ["kbr342XlxSZR", "zGYRMNA9xGuI"] + } + ], + "outputs": [ + { + "id": "system_rawResponse", + "key": "system_rawResponse", + "label": "完整响应数据", + "valueType": "object", + "type": "static" + }, + { + "id": "error", + "key": "error", + "label": "运行错误", + "description": "代码运行错误信息,成功时返回空", + "valueType": "object", + "type": "static" + }, + { + "id": "system_addOutputParam", + "key": "system_addOutputParam", + "type": "dynamic", + "valueType": "dynamic", + "label": "", + "customFieldConfig": { + "selectValueTypeList": [ + "string", + "number", + "boolean", + "object", + "arrayString", + "arrayNumber", + "arrayBoolean", + "arrayObject", + "any", + "chatHistory", + "datasetQuote", + "dynamic", + "selectApp", + "selectDataset" + ], + "showDescription": false, + "showDefaultValue": false + }, + "description": "将代码中 return 的对象作为输出,传递给后续的节点。变量名需要对应 return 的 key" + }, + { + "id": "qLUQfhG0ILRX", + "type": "dynamic", + "key": "result", + "valueType": "arrayString", + "label": "result" + } + ] + } + ], + "edges": [ + { + "source": "bxz97Vg4Omux", + "target": "yjFO3YcM7KG2", + "sourceHandle": "bxz97Vg4Omux-source-right", + "targetHandle": "yjFO3YcM7KG2-target-left" + }, + { + "source": "a2lqxASWi1vb", + "target": "w4heEpNflz59", + "sourceHandle": "a2lqxASWi1vb-source-right", + "targetHandle": "w4heEpNflz59-target-left" + }, + { + "source": "w4heEpNflz59", + "target": "izsNX8FXGD1t", + "sourceHandle": "w4heEpNflz59-source-IF", + "targetHandle": "izsNX8FXGD1t-target-left" + }, + { + "source": "448745", + "target": "frjbsrlnJJsR", + "sourceHandle": "448745-source-right", + "targetHandle": "frjbsrlnJJsR-target-left" + }, + { + "source": "frjbsrlnJJsR", + "target": "qlt9KJbbS9yJ", + "sourceHandle": "frjbsrlnJJsR-source-right", + "targetHandle": "qlt9KJbbS9yJ-target-left" + }, + { + "source": "tqzmK5oPR9BA", + "target": "a2lqxASWi1vb", + "sourceHandle": "tqzmK5oPR9BA-source-right", + "targetHandle": "a2lqxASWi1vb-target-left" + }, + { + "source": "yjFO3YcM7KG2", + "target": "vlNHndpNuFXB", + "sourceHandle": "yjFO3YcM7KG2-source-right", + "targetHandle": "vlNHndpNuFXB-target-left" + }, + { + "source": "ppPP6o7YYSTJ", + "target": "tqzmK5oPR9BA", + "sourceHandle": "ppPP6o7YYSTJ-source-right", + "targetHandle": "tqzmK5oPR9BA-target-left" + }, + { + "source": "kbr342XlxSZR", + "target": "y3WEYOQ09CGC", + "sourceHandle": "kbr342XlxSZR-source-right", + "targetHandle": "y3WEYOQ09CGC-target-left" + }, + { + "source": "y3WEYOQ09CGC", + "target": "quYZgsW32ApA", + "sourceHandle": "y3WEYOQ09CGC-source-right", + "targetHandle": "quYZgsW32ApA-target-left" + }, + { + "source": "quYZgsW32ApA", + "target": "bxz97Vg4Omux", + "sourceHandle": "quYZgsW32ApA-source-right", + "targetHandle": "bxz97Vg4Omux-target-left" + }, + { + "source": "w4heEpNflz59", + "target": "quYZgsW32ApA", + "sourceHandle": "w4heEpNflz59-source-ELSE", + "targetHandle": "quYZgsW32ApA-target-left" + }, + { + "source": "qlt9KJbbS9yJ", + "target": "kbr342XlxSZR", + "sourceHandle": "qlt9KJbbS9yJ-source-IF", + "targetHandle": "kbr342XlxSZR-target-left" + }, + { + "source": "qlt9KJbbS9yJ", + "target": "dFxrGZS3Wmnz", + "sourceHandle": "qlt9KJbbS9yJ-source-ELSE", + "targetHandle": "dFxrGZS3Wmnz-target-right" + }, + { + "source": "vlNHndpNuFXB", + "target": "ppPP6o7YYSTJ", + "sourceHandle": "vlNHndpNuFXB-source-right", + "targetHandle": "ppPP6o7YYSTJ-target-left" + } + ], + "chatConfig": { + "welcomeText": "你好,欢迎使用长字幕反思翻译机器人。\n\n在完成下方设置后,可以直接输入需要翻译的文本", + "variables": [ + { + "id": "v98n5b", + "key": "source_lang", + "label": "源语言", + "type": "select", + "required": true, + "maxLen": 50, + "enums": [ + { + "value": "简体中文" + }, + { + "value": "繁體中文" + }, + { + "value": "English" + }, + { + "value": "Español" + }, + { + "value": "Français" + }, + { + "value": "Deutsch" + }, + { + "value": "Italiano" + }, + { + "value": "日本語" + }, + { + "value": "한국어" + }, + { + "value": "Русский" + }, + { + "value": "العربية" + }, + { + "value": "Bahasa Indonesia" + }, + { + "value": "Polski" + } + ], + "icon": "core/app/variable/select" + }, + { + "id": "c3tvge", + "key": "target_lang", + "label": "目标语言", + "type": "select", + "required": true, + "maxLen": 50, + "enums": [ + { + "value": "简体中文" + }, + { + "value": "繁體中文" + }, + { + "value": "English" + }, + { + "value": "Español" + }, + { + "value": "Français" + }, + { + "value": "Deutsch" + }, + { + "value": "Italiano" + }, + { + "value": "日本語" + }, + { + "value": "한국어" + }, + { + "value": "Русский" + }, + { + "value": "العربية" + }, + { + "value": "Bahasa Indonesia" + }, + { + "value": "Polski" + } + ], + "icon": "core/app/variable/select" + } + ], + "scheduledTriggerConfig": { + "cronString": "", + "timezone": "Asia/Shanghai", + "defaultPrompt": "" + }, + "_id": "6688b45317c65410d61d58aa" + } + } +} diff --git a/projects/app/public/appMarketTemplates/timeBot/template.json b/projects/app/public/appMarketTemplates/timeBot/template.json new file mode 100644 index 000000000..d644ee12b --- /dev/null +++ b/projects/app/public/appMarketTemplates/timeBot/template.json @@ -0,0 +1,186 @@ +{ + "name": "知道时间的机器人", + "intro": "通过挂载时间插件,让模型获取当前最新时间", + "author": "Fastgpt", + "avatar": "core/workflow/template/getTime", + "tags": ["recommendation", "roleplay"], + "type": "simple", + "weight": 1, + "workflow": { + "nodes": [ + { + "nodeId": "userGuide", + "name": "系统配置", + "intro": "可以配置应用的系统参数", + "avatar": "/imgs/workflow/userGuide.png", + "flowNodeType": "userGuide", + "position": { + "x": 531.2422736065552, + "y": -486.7611729549753 + }, + "version": "481", + "inputs": [], + "outputs": [] + }, + { + "nodeId": "workflowStartNodeId", + "name": "流程开始", + "intro": "", + "avatar": "/imgs/workflow/userChatInput.svg", + "flowNodeType": "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": "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-getTime" + } + ], + "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": "" + } + } + } +} diff --git a/projects/app/public/imgs/app/templateFill.svg b/projects/app/public/imgs/app/templateFill.svg new file mode 100644 index 000000000..9ef1df7a4 --- /dev/null +++ b/projects/app/public/imgs/app/templateFill.svg @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/projects/app/public/imgs/app/templates/dalle.svg b/projects/app/public/imgs/app/templates/dalle.svg deleted file mode 100644 index 6eda6b8a8..000000000 --- a/projects/app/public/imgs/app/templates/dalle.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/projects/app/src/components/core/ai/SettingLLMModel/index.tsx b/projects/app/src/components/core/ai/SettingLLMModel/index.tsx index 4f93f8c90..00a2d7d27 100644 --- a/projects/app/src/components/core/ai/SettingLLMModel/index.tsx +++ b/projects/app/src/components/core/ai/SettingLLMModel/index.tsx @@ -15,9 +15,15 @@ type Props = { llmModelType?: `${LLMModelTypeEnum}`; defaultData: SettingAIDataType; onChange: (e: SettingAIDataType) => void; + bg?: string; }; -const SettingLLMModel = ({ llmModelType = LLMModelTypeEnum.all, defaultData, onChange }: Props) => { +const SettingLLMModel = ({ + llmModelType = LLMModelTypeEnum.all, + defaultData, + onChange, + bg = 'white' +}: Props) => { const { t } = useTranslation(); const { llmModelList } = useSystemStore(); @@ -63,6 +69,7 @@ const SettingLLMModel = ({ llmModelType = LLMModelTypeEnum.all, defaultData, onC w={'100%'} justifyContent={'flex-start'} variant={'whiteFlow'} + bg={bg} _active={{ transform: 'none' }} diff --git a/projects/app/src/components/core/app/WelcomeTextConfig.tsx b/projects/app/src/components/core/app/WelcomeTextConfig.tsx index 93d32e6b9..e4d156f75 100644 --- a/projects/app/src/components/core/app/WelcomeTextConfig.tsx +++ b/projects/app/src/components/core/app/WelcomeTextConfig.tsx @@ -22,6 +22,7 @@ const WelcomeTextConfig = (props: TextareaProps) => { mt={2} rows={6} fontSize={'sm'} + bg={'myGray.50'} placeholder={t('common:core.app.tip.welcomeTextTip')} {...props} /> diff --git a/projects/app/src/pages/api/core/app/create.ts b/projects/app/src/pages/api/core/app/create.ts index 3ad84bc75..623fcd180 100644 --- a/projects/app/src/pages/api/core/app/create.ts +++ b/projects/app/src/pages/api/core/app/create.ts @@ -22,10 +22,11 @@ export type CreateAppBody = { type?: AppTypeEnum; modules: AppSchema['modules']; edges?: AppSchema['edges']; + chatConfig?: AppSchema['chatConfig']; }; async function handler(req: ApiRequestProps) { - const { parentId, name, avatar, type, modules, edges } = req.body; + const { parentId, name, avatar, type, modules, edges, chatConfig } = req.body; if (!name || !type || !Array.isArray(modules)) { return Promise.reject(CommonErrEnum.inheritPermissionError); @@ -50,6 +51,7 @@ async function handler(req: ApiRequestProps) { type, modules, edges, + chatConfig, teamId, tmbId }); @@ -67,6 +69,7 @@ export const onCreateApp = async ({ type, modules, edges, + chatConfig, teamId, tmbId, pluginData, @@ -78,6 +81,7 @@ export const onCreateApp = async ({ type?: AppTypeEnum; modules?: AppSchema['modules']; edges?: AppSchema['edges']; + chatConfig?: AppSchema['chatConfig']; intro?: string; teamId: string; tmbId: string; @@ -96,6 +100,7 @@ export const onCreateApp = async ({ tmbId, modules, edges, + chatConfig, type, version: 'v2', pluginData, @@ -111,7 +116,8 @@ export const onCreateApp = async ({ { appId, nodes: modules, - edges + edges, + chatConfig } ], { session } diff --git a/projects/app/src/pages/api/core/app/template/detail.ts b/projects/app/src/pages/api/core/app/template/detail.ts new file mode 100644 index 000000000..29c80a434 --- /dev/null +++ b/projects/app/src/pages/api/core/app/template/detail.ts @@ -0,0 +1,21 @@ +import type { NextApiRequest, NextApiResponse } from 'next'; +import { authCert } from '@fastgpt/service/support/permission/auth/common'; +import { NextAPI } from '@/service/middleware/entry'; +import { TemplateMarketItemType } from '@fastgpt/global/core/workflow/type'; +import { getTemplateMarketItemDetail } from '@/service/core/app/template'; + +type Props = { + templateId: string; +}; + +async function handler( + req: NextApiRequest, + res: NextApiResponse +): Promise { + await authCert({ req, authToken: true }); + const { templateId } = req.query as Props; + + return getTemplateMarketItemDetail(templateId); +} + +export default NextAPI(handler); diff --git a/projects/app/src/pages/api/core/app/template/list.ts b/projects/app/src/pages/api/core/app/template/list.ts new file mode 100644 index 000000000..96449876c --- /dev/null +++ b/projects/app/src/pages/api/core/app/template/list.ts @@ -0,0 +1,16 @@ +import type { NextApiRequest, NextApiResponse } from 'next'; +import { authCert } from '@fastgpt/service/support/permission/auth/common'; +import { NextAPI } from '@/service/middleware/entry'; +import { TemplateMarketListItemType } from '@fastgpt/global/core/workflow/type'; +import { getTemplateMarketItemList } from '@/service/core/app/template'; + +async function handler( + req: NextApiRequest, + res: NextApiResponse +): Promise { + await authCert({ req, authToken: true }); + + return getTemplateMarketItemList(); +} + +export default NextAPI(handler); diff --git a/projects/app/src/pages/app/detail/components/SimpleApp/Edit.tsx b/projects/app/src/pages/app/detail/components/SimpleApp/Edit.tsx index feedac8a3..fd1c93b3e 100644 --- a/projects/app/src/pages/app/detail/components/SimpleApp/Edit.tsx +++ b/projects/app/src/pages/app/detail/components/SimpleApp/Edit.tsx @@ -30,7 +30,6 @@ const Edit = ({ // show selected dataset useMount(() => { loadAllDatasets(); - setAppForm( appWorkflow2Form({ nodes: appDetail.modules, diff --git a/projects/app/src/pages/app/detail/components/SimpleApp/EditForm.tsx b/projects/app/src/pages/app/detail/components/SimpleApp/EditForm.tsx index 0ee1985c0..55dd5fdee 100644 --- a/projects/app/src/pages/app/detail/components/SimpleApp/EditForm.tsx +++ b/projects/app/src/pages/app/detail/components/SimpleApp/EditForm.tsx @@ -135,13 +135,14 @@ const EditForm = ({ - {appT('ai_settings')} + {t('app:ai_settings')} {t('common:core.ai.Model')} { startTst(() => { setAppForm((state) => ({ diff --git a/projects/app/src/pages/app/detail/components/SimpleApp/Header.tsx b/projects/app/src/pages/app/detail/components/SimpleApp/Header.tsx index a17de1347..3cf5c5567 100644 --- a/projects/app/src/pages/app/detail/components/SimpleApp/Header.tsx +++ b/projects/app/src/pages/app/detail/components/SimpleApp/Header.tsx @@ -52,7 +52,6 @@ const Header = ({ const isPublished = useMemo(() => { const data = form2AppWorkflow(appForm, t); - return compareWorkflow( { nodes: appDetail.modules, diff --git a/projects/app/src/pages/app/list/components/CreateModal.tsx b/projects/app/src/pages/app/list/components/CreateModal.tsx index e647b784b..ee22875f8 100644 --- a/projects/app/src/pages/app/list/components/CreateModal.tsx +++ b/projects/app/src/pages/app/list/components/CreateModal.tsx @@ -1,15 +1,5 @@ -import React, { useCallback, useRef } from 'react'; -import { - Box, - Flex, - Button, - ModalFooter, - ModalBody, - Input, - Grid, - useTheme, - Card -} from '@chakra-ui/react'; +import React, { useCallback, useMemo, useRef } from 'react'; +import { Box, Flex, Button, ModalFooter, ModalBody, Input, Grid, Card } from '@chakra-ui/react'; import { useSelectFile } from '@/web/common/file/hooks/useSelectFile'; import { useForm } from 'react-hook-form'; import { compressImgFileAndUpload } from '@/web/common/file/controller'; @@ -17,8 +7,8 @@ import { getErrText } from '@fastgpt/global/common/error/utils'; import { useToast } from '@fastgpt/web/hooks/useToast'; import { postCreateApp } from '@/web/core/app/api'; import { useRouter } from 'next/router'; -import { simpleBotTemplates, workflowTemplates, pluginTemplates } from '@/web/core/app/templates'; -import { useRequest } from '@fastgpt/web/hooks/useRequest'; +import { emptyTemplates } from '@/web/core/app/templates'; +import { useRequest2 } from '@fastgpt/web/hooks/useRequest'; import Avatar from '@fastgpt/web/components/common/Avatar'; import MyTooltip from '@fastgpt/web/components/common/MyTooltip'; import MyModal from '@fastgpt/web/components/common/MyModal'; @@ -27,20 +17,31 @@ import { MongoImageTypeEnum } from '@fastgpt/global/common/file/image/constants' import { useContextSelector } from 'use-context-selector'; import { AppListContext } from './context'; import { AppTypeEnum } from '@fastgpt/global/core/app/constants'; -import { useI18n } from '@/web/context/I18n'; import { useSystem } from '@fastgpt/web/hooks/useSystem'; +import { ChevronRightIcon } from '@chakra-ui/icons'; +import MyIcon from '@fastgpt/web/components/common/Icon'; +import { + getTemplateMarketItemDetail, + getTemplateMarketItemList +} from '@/web/core/app/api/template'; type FormType = { avatar: string; name: string; - templateId: string; }; export type CreateAppType = AppTypeEnum.simple | AppTypeEnum.workflow | AppTypeEnum.plugin; -const CreateModal = ({ onClose, type }: { type: CreateAppType; onClose: () => void }) => { +const CreateModal = ({ + onClose, + type, + onOpenTemplateModal +}: { + type: CreateAppType; + onClose: () => void; + onOpenTemplateModal: (type: AppTypeEnum) => void; +}) => { const { t } = useTranslation(); - const { appT } = useI18n(); const { toast } = useToast(); const router = useRouter(); const { parentId, loadMyApps } = useContextSelector(AppListContext, (v) => v); @@ -49,34 +50,39 @@ const CreateModal = ({ onClose, type }: { type: CreateAppType; onClose: () => vo const typeMap = useRef({ [AppTypeEnum.simple]: { icon: 'core/app/simpleBot', - title: appT('type.Create simple bot'), + title: t('app:type.Create simple bot'), avatar: '/imgs/app/avatar/simple.svg', - templates: simpleBotTemplates + emptyCreateText: t('app:create_empty_app') }, [AppTypeEnum.workflow]: { icon: 'core/app/type/workflowFill', avatar: '/imgs/app/avatar/workflow.svg', - title: appT('type.Create workflow bot'), - templates: workflowTemplates + title: t('app:type.Create workflow bot'), + emptyCreateText: t('app:create_empty_workflow') }, [AppTypeEnum.plugin]: { icon: 'core/app/type/pluginFill', avatar: '/imgs/app/avatar/plugin.svg', - title: appT('type.Create plugin bot'), - templates: pluginTemplates + title: t('app:type.Create plugin bot'), + emptyCreateText: t('app:create_empty_plugin') } }); const typeData = typeMap.current[type]; + const { data: templateList = [] } = useRequest2(getTemplateMarketItemList, { + manual: false + }); + const filterTemplates = useMemo(() => { + return templateList.filter((item) => item.type === type).slice(0, 3); + }, [templateList, type]); + const { register, setValue, watch, handleSubmit } = useForm({ defaultValues: { avatar: typeData.avatar, - name: '', - templateId: typeData.templates[0].id + name: '' } }); const avatar = watch('avatar'); - const templateId = watch('templateId'); const { File, onOpen: onOpenSelectFile } = useSelectFile({ fileType: '.jpg,.png', @@ -105,29 +111,42 @@ const CreateModal = ({ onClose, type }: { type: CreateAppType; onClose: () => vo [setValue, t, toast] ); - const { mutate: onclickCreate, isLoading: creating } = useRequest({ - mutationFn: async (data: FormType) => { - const template = typeData.templates.find((item) => item.id === data.templateId); - if (!template) { - return Promise.reject(t('common:core.dataset.error.Template does not exist')); + const { runAsync: onclickCreate, loading: isCreating } = useRequest2( + async (data: FormType, templateId?: string) => { + if (!templateId) { + return postCreateApp({ + parentId, + avatar: data.avatar, + name: data.name, + type, + modules: emptyTemplates[type].nodes, + edges: emptyTemplates[type].edges, + chatConfig: emptyTemplates[type].chatConfig + }); } + + const templateDetail = await getTemplateMarketItemDetail({ templateId: templateId }); + return postCreateApp({ parentId, - avatar: data.avatar || template.avatar, + avatar: data.avatar || templateDetail.avatar, name: data.name, - type: template.type, - modules: template.modules || [], - edges: template.edges || [] + type: templateDetail.type, + modules: templateDetail.workflow.nodes || [], + edges: templateDetail.workflow.edges || [], + chatConfig: templateDetail.workflow.chatConfig }); }, - onSuccess(id: string) { - router.push(`/app/detail?appId=${id}`); - loadMyApps(); - onClose(); - }, - successToast: t('common:common.Create Success'), - errorToast: t('common:common.Create Failed') - }); + { + onSuccess(id: string) { + router.push(`/app/detail?appId=${id}`); + loadMyApps(); + onClose(); + }, + successToast: t('common:common.Create Success'), + errorToast: t('common:common.Create Failed') + } + ); return ( vo isOpen onClose={onClose} isCentered={!isPc} + maxW={['90vw', '40rem']} + isLoading={isCreating} > - + {t('common:common.Set Name')} @@ -146,8 +167,8 @@ const CreateModal = ({ onClose, type }: { type: CreateAppType; onClose: () => vo vo - - {t('common:core.app.Select app from template')} - + + + {t('common:core.app.Select app from template')} + + + onOpenTemplateModal(type)} + alignItems={'center'} + cursor={'pointer'} + color={'myGray.600'} + fontSize={'xs'} + _hover={{ color: 'blue.700' }} + > + {t('common:core.app.more')} + + + - {typeData.templates.map((item) => ( + onclickCreate(data))} + > + + + {typeData.emptyCreateText} + + + {filterTemplates.map((item) => ( { - setValue('templateId', item.id); + borderWidth={'1px'} + borderColor={'myGray.200'} + boxShadow={'3'} + h={'8.25rem'} + _hover={{ + borderColor: 'primary.300', + '& .buttons': { + display: 'flex' + } }} + display={'flex'} + flexDirection={'column'} > - + {t(item.name as any)} - + {t(item.intro as any)} + + By {item.author} + + + + ))} - - - - - - ); diff --git a/projects/app/src/pages/app/list/components/TemplateMarketModal.tsx b/projects/app/src/pages/app/list/components/TemplateMarketModal.tsx new file mode 100644 index 000000000..e7070d282 --- /dev/null +++ b/projects/app/src/pages/app/list/components/TemplateMarketModal.tsx @@ -0,0 +1,452 @@ +import { + Box, + Button, + Flex, + Grid, + HStack, + Modal, + ModalBody, + ModalCloseButton, + ModalContent, + ModalHeader, + ModalOverlay +} from '@chakra-ui/react'; +import Avatar from '@fastgpt/web/components/common/Avatar'; +import { useCallback, useState } from 'react'; +import MyBox from '@fastgpt/web/components/common/MyBox'; +import AppTypeTag from './TypeTag'; +import { AppTemplateTypeEnum, AppTypeEnum } from '@fastgpt/global/core/app/constants'; +import { useRequest2 } from '@fastgpt/web/hooks/useRequest'; +import { + getTemplateMarketItemDetail, + getTemplateMarketItemList +} from '@/web/core/app/api/template'; +import { TemplateMarketListItemType } from '@fastgpt/global/core/workflow/type'; +import { postCreateApp } from '@/web/core/app/api'; +import { useContextSelector } from 'use-context-selector'; +import { AppListContext } from './context'; +import { useRouter } from 'next/router'; +import MySelect from '@fastgpt/web/components/common/MySelect'; +import { useTranslation } from 'next-i18next'; +import { useSystem } from '@fastgpt/web/hooks/useSystem'; +import EmptyTip from '@fastgpt/web/components/common/EmptyTip'; +import SearchInput from '../../../../../../../packages/web/components/common/Input/SearchInput/index'; +import MyIcon from '@fastgpt/web/components/common/Icon'; +import { useSystemStore } from '@/web/common/system/useSystemStore'; + +type TemplateAppType = AppTypeEnum | 'all'; + +const TemplateMarketModal = ({ + defaultType = 'all', + onClose +}: { + defaultType?: TemplateAppType; + onClose: () => void; +}) => { + const { t } = useTranslation(); + const { feConfigs } = useSystemStore(); + const templateTags = [ + { + id: AppTemplateTypeEnum.recommendation, + label: t('app:templateMarket.templateTags.Recommendation') + }, + { + id: AppTemplateTypeEnum.writing, + label: t('app:templateMarket.templateTags.Writing') + }, + { + id: AppTemplateTypeEnum.imageGeneration, + label: t('app:templateMarket.templateTags.Image_generation') + }, + { + id: AppTemplateTypeEnum.webSearch, + label: t('app:templateMarket.templateTags.Web_search') + }, + { + id: AppTemplateTypeEnum.roleplay, + label: t('app:templateMarket.templateTags.Roleplay') + }, + { + id: AppTemplateTypeEnum.officeServices, + label: t('app:templateMarket.templateTags.Office_services') + } + ]; + + const { parentId } = useContextSelector(AppListContext, (v) => v); + const router = useRouter(); + const { isPc } = useSystem(); + + const [currentTag, setCurrentTag] = useState(templateTags[0].id); + const [currentAppType, setCurrentAppType] = useState(defaultType); + const [currentSearch, setCurrentSearch] = useState(''); + + const { data: templateList = [], loading: isLoadingTemplates } = useRequest2( + getTemplateMarketItemList, + { + manual: false + } + ); + + const { runAsync: onUseTemplate, loading: isCreating } = useRequest2( + async (id: string) => { + const templateDetail = await getTemplateMarketItemDetail({ templateId: id }); + return postCreateApp({ + parentId, + avatar: templateDetail.avatar, + name: templateDetail.name, + type: templateDetail.type, + modules: templateDetail.workflow.nodes || [], + edges: templateDetail.workflow.edges || [], + chatConfig: templateDetail.workflow.chatConfig + }); + }, + { + onSuccess(id: string) { + onClose(); + router.push(`/app/detail?appId=${id}`); + }, + successToast: t('common:common.Create Success'), + errorToast: t('common:common.Create Failed') + } + ); + + const { run: handleScroll } = useRequest2( + async () => { + let firstVisibleTitle: any = null; + + templateTags + .map((type) => type.id) + .forEach((type: string) => { + const element = document.getElementById(type); + if (!element) return; + + const elementRect = element.getBoundingClientRect(); + if (elementRect.top <= window.innerHeight && elementRect.bottom >= 0) { + if ( + !firstVisibleTitle || + elementRect.top < firstVisibleTitle.getBoundingClientRect().top + ) { + firstVisibleTitle = element; + } + } + }); + + if (firstVisibleTitle) { + setCurrentTag(firstVisibleTitle.id); + } + }, + { + throttleWait: 100 + } + ); + + const TemplateCard = useCallback( + ({ item }: { item: TemplateMarketListItemType }) => { + const { t } = useTranslation(); + + return ( + + + + + {item.name} + + + + + + + {item.intro || t('app:templateMarket.no_intro')} + + + + By {item.author} + + + + + + ); + }, + [onUseTemplate] + ); + + return ( + onClose && onClose()} + autoFocus={false} + blockScrollOnMount={false} + closeOnOverlayClick={false} + isCentered + > + + + + + {t('app:templateMarket.Template_market')} + + + + { + setCurrentAppType(value as AppTypeEnum | 'all'); + }} + bg={'myGray.100'} + minW={'7rem'} + borderRadius={'sm'} + list={[ + { label: t('app:type.All'), value: 'all' }, + { label: t('app:type.Simple bot'), value: AppTypeEnum.simple }, + { label: t('app:type.Workflow bot'), value: AppTypeEnum.workflow }, + { label: t('app:type.Plugin'), value: AppTypeEnum.plugin } + ]} + /> + + + {isPc && ( + + setCurrentSearch(e.target.value)} + h={8} + bg={'myGray.50'} + maxLength={20} + borderRadius={'sm'} + /> + + )} + + + + {isPc && ( + + {templateTags.map((item) => { + return ( + { + setCurrentTag(item.id); + const anchor = document.getElementById(item.id); + if (anchor) { + anchor.scrollIntoView({ behavior: 'auto', block: 'start' }); + } + }} + > + {item.label} + + ); + })} + + + {feConfigs?.appTemplateCourse && ( + window.open(feConfigs.appTemplateCourse)} + gap={1} + > + + {t('common:contribute_app_template')} + + )} + + )} + + + {currentSearch ? ( + <> + + {t('common:xx_search_result', { key: currentSearch })} + + {(() => { + const templates = templateList.filter((template) => + `${template.name}${template.intro}`.includes(currentSearch) + ); + + if (templates.length > 0) { + return ( + + {templates.map((item) => ( + + ))} + + ); + } + + return ; + })()} + + ) : ( + <> + {templateTags.map((item) => { + const currentTemplates = templateList + ?.filter((template) => template.tags.includes(item.id)) + .filter((template) => { + if (currentAppType === 'all') return true; + return template.type === currentAppType; + }); + + if (currentTemplates.length === 0) return null; + + return ( + + + {item.label} + + + {currentTemplates.map((item) => ( + + ))} + + + ); + })} + + )} + + + + + + ); +}; + +export default TemplateMarketModal; diff --git a/projects/app/src/pages/app/list/components/TypeTag.tsx b/projects/app/src/pages/app/list/components/TypeTag.tsx index 80e37c8e4..63111dfff 100644 --- a/projects/app/src/pages/app/list/components/TypeTag.tsx +++ b/projects/app/src/pages/app/list/components/TypeTag.tsx @@ -45,7 +45,7 @@ const AppTypeTag = ({ type }: { type: AppTypeEnum }) => { py={0.5} pl={2} pr={3} - borderLeftRadius={'md'} + borderLeftRadius={'sm'} whiteSpace={'nowrap'} > diff --git a/projects/app/src/pages/app/list/index.tsx b/projects/app/src/pages/app/list/index.tsx index 920abea1e..0cae6e541 100644 --- a/projects/app/src/pages/app/list/index.tsx +++ b/projects/app/src/pages/app/list/index.tsx @@ -42,6 +42,7 @@ import MyBox from '@fastgpt/web/components/common/MyBox'; import LightRowTabs from '@fastgpt/web/components/common/Tabs/LightRowTabs'; import { useSystem } from '@fastgpt/web/hooks/useSystem'; import MyIcon from '@fastgpt/web/components/common/Icon'; +import TemplateMarketModal from './components/TemplateMarketModal'; const CreateModal = dynamic(() => import('./components/CreateModal')); const EditFolderModal = dynamic( @@ -77,6 +78,7 @@ const MyApps = () => { onClose: onCloseCreateHttpPlugin } = useDisclosure(); const [editFolder, setEditFolder] = useState(); + const [templateModalType, setTemplateModalType] = useState(); const { runAsync: onCreateFolder } = useRequest2(postCreateAppFolder, { onSuccess() { @@ -145,19 +147,19 @@ const MyApps = () => { { children: [ { icon: 'core/app/simpleBot', - label: appT('type.Simple bot'), - description: appT('type.Create simple bot tip'), + label: t('app:type.Simple bot'), + description: t('app:type.Create simple bot tip'), onClick: () => setCreateAppType(AppTypeEnum.simple) }, { icon: 'core/app/type/workflowFill', - label: appT('type.Workflow bot'), - description: appT('type.Create workflow tip'), + label: t('app:type.Workflow bot'), + description: t('app:type.Create workflow tip'), onClick: () => setCreateAppType(AppTypeEnum.workflow) }, { icon: 'core/app/type/pluginFill', - label: appT('type.Plugin'), - description: appT('type.Create one plugin tip'), + label: t('app:type.Plugin'), + description: t('app:type.Create one plugin tip'), onClick: () => setCreateAppType(AppTypeEnum.plugin) }, { icon: 'core/app/type/httpPluginFill', - label: appT('type.Http plugin'), - description: appT('type.Create http plugin tip'), + label: t('app:type.Http plugin'), + description: t('app:type.Create http plugin tip'), onClick: onOpenCreateHttpPlugin } ] }, + { + children: [ + { + icon: '/imgs/app/templateFill.svg', + label: t('app:template_market'), + description: t('app:template_market_description'), + onClick: () => setTemplateModalType('all') + } + ] + }, { children: [ { @@ -306,9 +318,19 @@ const MyApps = () => { /> )} {!!createAppType && ( - setCreateAppType(undefined)} /> + setCreateAppType(undefined)} + onOpenTemplateModal={setTemplateModalType} + /> )} {isOpenCreateHttpPlugin && } + {!!templateModalType && ( + setTemplateModalType(undefined)} + defaultType={templateModalType} + /> + )} ); }; diff --git a/projects/app/src/pages/login/components/RegisterForm.tsx b/projects/app/src/pages/login/components/RegisterForm.tsx index 06a084e50..1609ed99b 100644 --- a/projects/app/src/pages/login/components/RegisterForm.tsx +++ b/projects/app/src/pages/login/components/RegisterForm.tsx @@ -7,9 +7,10 @@ import { useSendCode } from '@/web/support/user/hooks/useSendCode'; import type { ResLogin } from '@/global/support/api/userRes'; import { useToast } from '@fastgpt/web/hooks/useToast'; import { postCreateApp } from '@/web/core/app/api'; -import { defaultAppTemplates } from '@/web/core/app/templates'; +import { emptyTemplates } from '@/web/core/app/templates'; import { useSystemStore } from '@/web/common/system/useSystemStore'; import { useTranslation } from 'next-i18next'; +import { AppTypeEnum } from '@fastgpt/global/core/app/constants'; interface Props { loginSuccess: (e: ResLogin) => void; setPageType: Dispatch<`${LoginPageTypeEnum}`>; @@ -68,13 +69,13 @@ const RegisterForm = ({ setPageType, loginSuccess }: Props) => { }); // auto register template app setTimeout(() => { - defaultAppTemplates.forEach((template) => { + Object.entries(emptyTemplates).map(([type, emptyTemplate]) => { postCreateApp({ - avatar: template.avatar, - name: t(template.name as any), - modules: template.modules, - edges: template.edges, - type: template.type + avatar: emptyTemplate.avatar, + name: t(emptyTemplate.name as any), + modules: emptyTemplate.nodes, + edges: emptyTemplate.edges, + type: type as AppTypeEnum }); }); }, 100); diff --git a/projects/app/src/service/common/system/index.ts b/projects/app/src/service/common/system/index.ts index 095e5fe93..dc1db5cb5 100644 --- a/projects/app/src/service/common/system/index.ts +++ b/projects/app/src/service/common/system/index.ts @@ -62,6 +62,8 @@ const defaultFeConfigs: FastGPTFeConfigsType = { docUrl: 'https://doc.fastgpt.in', openAPIDocUrl: 'https://doc.fastgpt.in/docs/development/openapi', systemPluginCourseUrl: 'https://fael3z0zfze.feishu.cn/wiki/ERZnw9R26iRRG0kXZRec6WL9nwh', + appTemplateCourse: + 'https://fael3z0zfze.feishu.cn/wiki/CX9wwMGyEi5TL6koiLYcg7U0nWb?fromScene=spaceOverview', systemTitle: 'FastGPT', concatMd: '项目开源地址: [FastGPT GitHub](https://github.com/labring/FastGPT)\n交流群: ![](https://oss.laf.run/htr4n1-images/fastgpt-qr-code.jpg)', diff --git a/projects/app/src/service/core/app/template.ts b/projects/app/src/service/core/app/template.ts new file mode 100644 index 000000000..4b79cc37d --- /dev/null +++ b/projects/app/src/service/core/app/template.ts @@ -0,0 +1,48 @@ +import { isProduction } from '@fastgpt/service/common/system/constants'; +import { readdirSync, readFileSync } from 'fs'; +import path from 'path'; + +// Get template from memory or file system +const loadTemplateMarketItems = async () => { + if (isProduction && global.appMarketTemplates) return global.appMarketTemplates; + + const templatesDir = path.join(process.cwd(), 'public', 'appMarketTemplates'); + const templateNames = readdirSync(templatesDir); + + global.appMarketTemplates = templateNames.map((name) => { + try { + const filePath = path.join(templatesDir, name, 'template.json'); + const fileContent = readFileSync(filePath, 'utf-8'); + const data = JSON.parse(fileContent); + return { + id: name, + ...data + }; + } catch (error) { + console.error(`Error fetching template ${name}:`, error); + return null; + } + }); + + global.appMarketTemplates.sort((a, b) => (b.weight ?? 0) - (a.weight ?? 0)); + + return global.appMarketTemplates; +}; + +export const getTemplateMarketItemDetail = async (id: string) => { + const templateMarketItems = await loadTemplateMarketItems(); + return templateMarketItems.find((item) => item.id === id); +}; + +export const getTemplateMarketItemList = async () => { + const templateMarketItems = await loadTemplateMarketItems(); + return templateMarketItems.map((item) => ({ + id: item.id, + name: item.name, + avatar: item.avatar, + intro: item.intro, + author: item.author, + tags: item.tags, + type: item.type + })); +}; diff --git a/projects/app/src/web/core/app/api/template.ts b/projects/app/src/web/core/app/api/template.ts new file mode 100644 index 000000000..7762f357f --- /dev/null +++ b/projects/app/src/web/core/app/api/template.ts @@ -0,0 +1,11 @@ +import { GET } from '@/web/common/api/request'; +import { + TemplateMarketItemType, + TemplateMarketListItemType +} from '@fastgpt/global/core/workflow/type'; + +export const getTemplateMarketItemList = () => + GET('/core/app/template/list'); + +export const getTemplateMarketItemDetail = (data: { templateId: string }) => + GET(`/core/app/template/detail`, data); diff --git a/projects/app/src/web/core/app/templates.ts b/projects/app/src/web/core/app/templates.ts index 01037dc97..38a8dbf85 100644 --- a/projects/app/src/web/core/app/templates.ts +++ b/projects/app/src/web/core/app/templates.ts @@ -2,6 +2,7 @@ import { AppItemType } from '@/types/app'; import { AppTypeEnum } from '@fastgpt/global/core/app/constants'; +import { AppSchema } from '@fastgpt/global/core/app/type'; import { NodeOutputKeyEnum, WorkflowIOValueTypeEnum @@ -11,23 +12,24 @@ import { FlowNodeOutputTypeEnum, FlowNodeTypeEnum } from '@fastgpt/global/core/workflow/node/constant'; +import { StoreEdgeItemType } from '@fastgpt/global/core/workflow/type/edge'; +import { StoreNodeItemType } from '@fastgpt/global/core/workflow/type/node'; import { i18nT } from '@fastgpt/web/i18n/utils'; -type TemplateType = (AppItemType & { - avatar: string; - intro: string; - type: AppTypeEnum; -})[]; - -// template -export const simpleBotTemplates: TemplateType = [ +export const emptyTemplates: Record< + AppTypeEnum.simple | AppTypeEnum.plugin | AppTypeEnum.workflow, { - id: 'simpleChat', + name: string; + avatar: string; + nodes: AppSchema['modules']; + edges: AppSchema['edges']; + chatConfig: AppSchema['chatConfig']; + } +> = { + [AppTypeEnum.simple]: { avatar: 'core/workflow/template/aiChat', name: i18nT('app:template.simple_robot'), - intro: '一个极其简单的 AI 应用,你可以绑定知识库或工具。', - type: AppTypeEnum.simple, - modules: [ + nodes: [ { nodeId: 'userGuide', name: '系统配置', @@ -251,773 +253,10 @@ export const simpleBotTemplates: TemplateType = [ } ] }, - { - id: 'chatGuide', - avatar: 'core/workflow/template/systemConfig', - name: '对话引导 + 变量', - intro: '可以在对话开始发送一段提示,或者让用户填写一些内容,作为本次对话的变量', - type: AppTypeEnum.simple, - modules: [ - { - nodeId: 'userGuide', - name: '系统配置', - intro: '可以配置应用的系统参数', - avatar: 'core/workflow/template/systemConfig', - flowNodeType: FlowNodeTypeEnum.systemConfig, - position: { - x: 496.57560693988853, - y: -490.7611729549753 - }, - version: '481', - inputs: [ - { - key: 'welcomeText', - renderTypeList: [FlowNodeInputTypeEnum.hidden], - valueType: WorkflowIOValueTypeEnum.string, - label: 'core.app.Welcome Text', - value: '你好,我可以为你翻译各种语言,请告诉我你需要翻译成什么语言?' - }, - { - key: 'variables', - renderTypeList: [FlowNodeInputTypeEnum.hidden], - valueType: WorkflowIOValueTypeEnum.any, - label: 'core.app.Chat Variable', - value: [ - { - id: 'myb3xk', - key: 'language', - label: '目标语言', - type: 'select', - required: true, - maxLen: 50, - enums: [ - { - value: '中文' - }, - { - value: '英文' - } - ] - } - ] - }, - { - key: 'questionGuide', - valueType: WorkflowIOValueTypeEnum.boolean, - renderTypeList: [FlowNodeInputTypeEnum.hidden], - label: 'core.app.Question Guide', - value: false - }, - { - 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: '448745', - name: '流程开始', - intro: '', - avatar: 'core/workflow/template/workflowStart', - 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: 'loOvhld2ZTKa', - name: 'AI 对话', - intro: 'AI 大模型对话', - avatar: 'core/workflow/template/aiChat', - flowNodeType: FlowNodeTypeEnum.chatNode, - showStatus: true, - position: { - x: 1097.7317280958762, - y: -244.16014496351386 - }, - version: '481', - inputs: [ - { - key: 'model', - renderTypeList: [ - FlowNodeInputTypeEnum.settingLLMModel, - FlowNodeInputTypeEnum.reference - ], - label: 'core.module.input.label.aiModel', - valueType: WorkflowIOValueTypeEnum.string, - value: 'gpt-4o-mini' - }, - { - key: 'temperature', - renderTypeList: [FlowNodeInputTypeEnum.hidden], - label: '', - value: 0, - valueType: WorkflowIOValueTypeEnum.number, - min: 0, - max: 10, - step: 1 - }, - { - key: 'maxToken', - renderTypeList: [FlowNodeInputTypeEnum.hidden], - label: '', - value: 2000, - 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: '请直接将我的问题翻译成{{$VARIABLE_NODE_ID.language$}},不需要回答问题。' - }, - { - 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: ['448745', 'userChatInput'] - }, - { - key: 'quoteQA', - renderTypeList: [FlowNodeInputTypeEnum.settingDatasetQuotePrompt], - label: '', - debugLabel: '知识库引用', - description: '', - valueType: WorkflowIOValueTypeEnum.datasetQuote - } - ], - 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 - } - ] - } - ], - edges: [ - { - source: '448745', - target: 'loOvhld2ZTKa', - sourceHandle: '448745-source-right', - targetHandle: 'loOvhld2ZTKa-target-left' - } - ] - }, - { - id: 'simpleDatasetChat', - avatar: 'core/workflow/template/datasetSearch', - name: '知识库+对话引导', - intro: '每次提问时进行一次知识库搜索,将搜索结果注入 LLM 模型进行参考回答', - type: AppTypeEnum.simple, - modules: [ - { - nodeId: 'userGuide', - name: '系统配置', - intro: '可以配置应用的系统参数', - avatar: 'core/workflow/template/systemConfig', - 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: false - }, - { - 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: 'core/workflow/template/workflowStart', - 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: 'core/workflow/template/aiChat', - flowNodeType: FlowNodeTypeEnum.chatNode, - showStatus: true, - position: { - x: 1638.509551404687, - y: -341.0428450861567 - }, - version: '481', - inputs: [ - { - key: 'model', - renderTypeList: [ - FlowNodeInputTypeEnum.settingLLMModel, - FlowNodeInputTypeEnum.reference - ], - label: 'core.module.input.label.aiModel', - valueType: WorkflowIOValueTypeEnum.string, - value: 'gpt-4o-mini' - }, - { - 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: ['iKBoX2vIzETU', '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: 'iKBoX2vIzETU', - name: '知识库搜索', - intro: '调用“语义检索”和“全文检索”能力,从“知识库”中查找可能与问题相关的参考内容', - avatar: 'core/workflow/template/datasetSearch', - flowNodeType: FlowNodeTypeEnum.datasetSearchNode, - showStatus: true, - position: { - x: 918.5901682164496, - y: -227.11542247619582 - }, - version: '481', - inputs: [ - { - key: 'datasets', - renderTypeList: [FlowNodeInputTypeEnum.selectDataset, FlowNodeInputTypeEnum.reference], - label: 'core.module.input.label.Select dataset', - value: [], - valueType: WorkflowIOValueTypeEnum.selectDataset, - list: [], - required: true - }, - { - key: 'similarity', - renderTypeList: [FlowNodeInputTypeEnum.selectDatasetParamsModal], - label: '', - value: 0.4, - valueType: WorkflowIOValueTypeEnum.number - }, - { - key: 'limit', - renderTypeList: [FlowNodeInputTypeEnum.hidden], - label: '', - value: 1500, - valueType: WorkflowIOValueTypeEnum.number - }, - { - key: 'searchMode', - renderTypeList: [FlowNodeInputTypeEnum.hidden], - label: '', - valueType: WorkflowIOValueTypeEnum.string, - value: 'embedding' - }, - { - key: 'usingReRank', - renderTypeList: [FlowNodeInputTypeEnum.hidden], - label: '', - valueType: WorkflowIOValueTypeEnum.boolean, - value: false - }, - { - key: 'datasetSearchUsingExtensionQuery', - renderTypeList: [FlowNodeInputTypeEnum.hidden], - label: '', - valueType: WorkflowIOValueTypeEnum.boolean, - value: true - }, - { - key: 'datasetSearchExtensionModel', - renderTypeList: [FlowNodeInputTypeEnum.hidden], - label: '', - valueType: WorkflowIOValueTypeEnum.string - }, - { - key: 'datasetSearchExtensionBg', - renderTypeList: [FlowNodeInputTypeEnum.hidden], - label: '', - valueType: WorkflowIOValueTypeEnum.string, - value: '' - }, - { - key: 'userChatInput', - renderTypeList: [FlowNodeInputTypeEnum.reference, FlowNodeInputTypeEnum.textarea], - valueType: WorkflowIOValueTypeEnum.string, - label: '用户问题', - required: true, - toolDescription: '需要检索的内容', - value: ['workflowStartNodeId', 'userChatInput'] - } - ], - outputs: [ - { - id: 'quoteQA', - key: 'quoteQA', - label: 'core.module.Dataset quote.label', - type: FlowNodeOutputTypeEnum.static, - valueType: WorkflowIOValueTypeEnum.datasetQuote, - description: '特殊数组格式,搜索结果为空时,返回空数组。' - } - ] - } - ], - edges: [ - { - source: 'workflowStartNodeId', - target: 'iKBoX2vIzETU', - sourceHandle: 'workflowStartNodeId-source-right', - targetHandle: 'iKBoX2vIzETU-target-left' - }, - { - source: 'iKBoX2vIzETU', - target: '7BdojPlukIQw', - sourceHandle: 'iKBoX2vIzETU-source-right', - targetHandle: '7BdojPlukIQw-target-left' - } - ] - }, - { - id: 'toolChat', - avatar: 'core/workflow/template/getTime', - name: '知道时间的机器人', - intro: '通过挂载时间插件,让模型获取当前最新时间', - type: AppTypeEnum.simple, - modules: [ - { - nodeId: 'userGuide', - name: '系统配置', - intro: '可以配置应用的系统参数', - avatar: 'core/workflow/template/systemConfig', - flowNodeType: FlowNodeTypeEnum.systemConfig, - position: { - x: 531.2422736065552, - y: -486.7611729549753 - }, - version: '481', - inputs: [], - outputs: [] - }, - { - nodeId: 'workflowStartNodeId', - name: '流程开始', - intro: '', - avatar: 'core/workflow/template/workflowStart', - 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: 'core/workflow/template/toolCall', - 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-4o-mini' - }, - { - 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: 'core/workflow/template/getTime', - 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-getTime' - } - ], - 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: 'workflow-default', + [AppTypeEnum.workflow]: { avatar: 'core/app/type/workflowFill', name: '空白工作流', - intro: '从零开始构建工作流', - type: AppTypeEnum.workflow, - modules: [ + nodes: [ { nodeId: 'userGuide', name: '系统配置', @@ -1115,1481 +354,10 @@ export const workflowTemplates: TemplateType = [ ], edges: [] }, - { - id: 'TranslateRobot', - avatar: '/imgs/app/templates/translate.svg', - name: '多轮翻译机器人', - intro: '通过4轮翻译,提高翻译英文的质量', - type: AppTypeEnum.workflow, - modules: [ - { - nodeId: 'userGuide', - name: '系统配置', - intro: '可以配置应用的系统参数', - avatar: 'core/workflow/template/systemConfig', - flowNodeType: 'userGuide', - position: { - x: 531.2422736065552, - y: -486.7611729549753 - }, - 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: 'core/workflow/template/workflowStart', - flowNodeType: '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', - type: 'static', - valueType: 'string' - } - ] - }, - { - nodeId: 'loOvhld2ZTKa', - name: '第一轮翻译', - intro: 'AI 大模型对话', - avatar: 'core/workflow/template/aiChat', - flowNodeType: 'chatNode', - showStatus: true, - position: { - x: 1748.8252410306534, - y: -245.08260685989214 - }, - version: '481', - inputs: [ - { - key: 'model', - renderTypeList: ['settingLLMModel', 'reference'], - label: 'core.module.input.label.aiModel', - valueType: 'string', - value: 'gpt-4o' - }, - { - 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: 'isResponseAnswerText', - renderTypeList: ['hidden'], - label: '', - value: true, - valueType: 'boolean' - }, - { - key: 'quoteTemplate', - renderTypeList: ['hidden'], - label: '', - valueType: 'string' - }, - { - key: 'quotePrompt', - renderTypeList: ['hidden'], - label: '', - valueType: 'string' - }, - { - key: 'systemPrompt', - renderTypeList: ['textarea', 'reference'], - max: 3000, - valueType: 'string', - label: 'core.ai.Prompt', - description: 'core.app.tip.chatNodeSystemPromptTip', - placeholder: 'core.app.tip.chatNodeSystemPromptTip', - 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: ['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, - toolDescription: '用户问题', - value: ['gBDvemE4FBhp', 'system_text'] - }, - { - key: 'quoteQA', - renderTypeList: ['settingDatasetQuotePrompt'], - label: '', - debugLabel: '知识库引用', - description: '', - valueType: 'datasetQuote' - } - ], - outputs: [ - { - id: 'history', - key: 'history', - required: true, - label: 'core.module.output.label.New context', - description: 'core.module.output.description.New context', - valueType: 'chatHistory', - type: 'static' - }, - { - id: 'answerText', - key: 'answerText', - required: true, - label: 'core.module.output.label.Ai response content', - description: 'core.module.output.description.Ai response content', - valueType: 'string', - type: 'static' - } - ] - }, - { - nodeId: 'w0oBbQ3YJHye', - name: '代码运行', - intro: '执行一段简单的脚本代码,通常用于进行复杂的数据处理。', - avatar: 'core/workflow/template/codeRun', - 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 - }, - customInputConfig: { - selectValueTypeList: [ - 'string', - 'number', - 'boolean', - 'object', - 'arrayString', - 'arrayNumber', - 'arrayBoolean', - 'arrayObject', - 'any', - 'chatHistory', - 'datasetQuote', - 'dynamic', - 'selectApp', - 'selectDataset' - ], - showDescription: false, - showDefaultValue: true - } - }, - { - key: 'codeType', - renderTypeList: ['hidden'], - label: '', - value: 'js' - }, - { - key: 'code', - renderTypeList: ['custom'], - label: '', - value: - "function main({data1}) {\n const codeBlocks = data1.match(/```[\\s\\S]*?```/g);\n\n if (codeBlocks && codeBlocks.length > 0) {\n const lastCodeBlock = codeBlocks[codeBlocks.length - 1];\n const cleanedCodeBlock = lastCodeBlock.replace(/```[a-zA-Z]*|```/g, '').trim();\n \n return {\n result: cleanedCodeBlock\n };\n }\n\n return {\n result: '未截取到代码块内容'\n };\n}\n" - }, - { - key: 'data1', - valueType: 'string', - label: 'data1', - renderTypeList: ['reference'], - description: '', - canEdit: true, - editField: { - key: true, - valueType: true - }, - value: ['loOvhld2ZTKa', 'answerText'] - } - ], - outputs: [ - { - id: 'system_addOutputParam', - key: 'system_addOutputParam', - type: 'dynamic', - valueType: 'dynamic', - label: '', - 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' - }, - { - id: 'gR0mkQpJ4Og8', - type: 'dynamic', - key: 'data2', - valueType: 'string', - label: 'data2' - } - ] - }, - { - nodeId: 'foO69L5FOmDQ', - name: '指定回复', - intro: - '该模块可以直接回复一段指定的内容。常用于引导、提示。非字符串内容传入时,会转成字符串进行输出。', - avatar: 'core/workflow/template/reply', - 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: ['bcqtxqxE2R6o', 'system_text'] - } - ], - outputs: [] - }, - { - nodeId: 'gBDvemE4FBhp', - name: '文本拼接', - intro: '可对固定或传入的文本进行加工后输出,非字符串类型数据最终会转成字符串类型。', - avatar: 'core/workflow/template/textConcat', - flowNodeType: 'textEditor', - position: { - x: 1031.371061396644, - y: 38.65839420088383 - }, - version: '486', - inputs: [ - { - key: 'system_addInputParam', - renderTypeList: ['addInputParam'], - valueType: 'dynamic', - label: '', - required: false, - description: '可以引用其他节点的输出,作为文本拼接的变量,通过 {{字段名}} 来引用变量', - customInputConfig: { - selectValueTypeList: [ - 'string', - 'number', - 'boolean', - 'object', - 'arrayString', - 'arrayNumber', - 'arrayBoolean', - 'arrayObject', - 'any', - 'chatHistory', - 'datasetQuote', - 'dynamic', - 'selectApp', - 'selectDataset' - ], - showDescription: false, - showDefaultValue: false - } - }, - { - key: 'system_textareaInput', - renderTypeList: ['textarea'], - valueType: 'string', - required: true, - label: '拼接文本', - placeholder: '可通过 {{字段名}} 来引用变量', - value: '原文:\n"""\n{{q}}\n"""' - }, - { - renderTypeList: ['reference'], - valueType: 'string', - canEdit: true, - key: 'q', - label: 'q', - customInputConfig: { - selectValueTypeList: [ - 'string', - 'number', - 'boolean', - 'object', - 'arrayString', - 'arrayNumber', - 'arrayBoolean', - 'arrayObject', - 'any', - 'chatHistory', - 'datasetQuote', - 'dynamic', - 'selectApp', - 'selectDataset' - ], - showDescription: false, - showDefaultValue: false - }, - required: true, - value: ['448745', 'userChatInput'] - } - ], - outputs: [ - { - id: 'system_text', - key: 'system_text', - label: '拼接结果', - type: 'static', - valueType: 'string' - } - ] - }, - { - nodeId: 'bcqtxqxE2R6o', - name: '合并输出结果', - intro: '可对固定或传入的文本进行加工后输出,非字符串类型数据最终会转成字符串类型。', - avatar: 'core/workflow/template/textConcat', - flowNodeType: 'textEditor', - position: { - x: 3113.6227559936665, - y: 12.909197647746709 - }, - version: '486', - inputs: [ - { - key: 'system_addInputParam', - renderTypeList: ['addInputParam'], - valueType: 'dynamic', - label: '', - required: false, - description: '可以引用其他节点的输出,作为文本拼接的变量,通过 {{字段名}} 来引用变量', - customInputConfig: { - selectValueTypeList: [ - 'string', - 'number', - 'boolean', - 'object', - 'arrayString', - 'arrayNumber', - 'arrayBoolean', - 'arrayObject', - 'any', - 'chatHistory', - 'datasetQuote', - 'dynamic', - 'selectApp', - 'selectDataset' - ], - showDescription: false, - showDefaultValue: false - } - }, - { - key: 'system_textareaInput', - renderTypeList: ['textarea'], - valueType: 'string', - required: true, - label: '拼接文本', - placeholder: '可通过 {{字段名}} 来引用变量', - value: '****** \n\n最终翻译结果如下: \n\n```\n{{result}}\n```' - }, - { - renderTypeList: ['reference'], - valueType: 'string', - canEdit: true, - key: 'result', - label: 'result', - customInputConfig: { - selectValueTypeList: [ - 'string', - 'number', - 'boolean', - 'object', - 'arrayString', - 'arrayNumber', - 'arrayBoolean', - 'arrayObject', - 'any', - 'chatHistory', - 'datasetQuote', - 'dynamic', - 'selectApp', - 'selectDataset' - ], - showDescription: false, - showDefaultValue: false - }, - required: true, - value: ['w0oBbQ3YJHye', 'qLUQfhG0ILRX'] - } - ], - outputs: [ - { - id: 'system_text', - key: 'system_text', - label: '拼接结果', - type: 'static', - valueType: 'string' - } - ] - } - ], - edges: [ - { - source: 'loOvhld2ZTKa', - target: 'w0oBbQ3YJHye', - sourceHandle: 'loOvhld2ZTKa-source-right', - targetHandle: 'w0oBbQ3YJHye-target-left' - }, - { - source: '448745', - target: 'gBDvemE4FBhp', - sourceHandle: '448745-source-right', - targetHandle: 'gBDvemE4FBhp-target-left' - }, - { - source: 'gBDvemE4FBhp', - target: 'loOvhld2ZTKa', - sourceHandle: 'gBDvemE4FBhp-source-right', - targetHandle: 'loOvhld2ZTKa-target-left' - }, - { - source: 'w0oBbQ3YJHye', - target: 'bcqtxqxE2R6o', - sourceHandle: 'w0oBbQ3YJHye-source-right', - targetHandle: 'bcqtxqxE2R6o-target-left' - }, - { - source: 'bcqtxqxE2R6o', - target: 'foO69L5FOmDQ', - sourceHandle: 'bcqtxqxE2R6o-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: 'core/workflow/template/systemConfig', - 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: 'core/workflow/template/workflowStart', - 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: 'core/workflow/template/toolCall', - 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: 'core/workflow/template/httpRequest', - 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' - }, - { - 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: 'core/workflow/template/codeRun', - 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: 'CQ', - avatar: 'core/workflow/template/questionClassify', - name: '问题分类 + 知识库', - intro: '先对用户的问题进行分类,再根据不同类型问题,执行不同的操作', - type: AppTypeEnum.workflow, - modules: [ - { - nodeId: 'userGuide', - name: '系统配置', - intro: '可以配置应用的系统参数', - avatar: 'core/workflow/template/systemConfig', - 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: 'core/workflow/template/workflowStart', - 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: 'core/workflow/template/aiChat', - 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-4o-mini' - }, - { - 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: 'core/workflow/template/questionClassify', - 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-4o-mini' - }, - { - 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' - }, - { - value: '其他问题', - key: 'agex' - } - ] - } - ], - outputs: [ - { - id: 'cqResult', - key: 'cqResult', - label: '分类结果', - valueType: WorkflowIOValueTypeEnum.string, - type: FlowNodeOutputTypeEnum.static - } - ] - }, - { - nodeId: '7kwgL1dVlwG6', - name: '指定回复', - intro: - '该模块可以直接回复一段指定的内容。常用于引导、提示。非字符串内容传入时,会转成字符串进行输出。', - avatar: 'core/workflow/template/reply', - flowNodeType: FlowNodeTypeEnum.answerNode, - position: { - x: 1874.9167551056487, - y: 434.98431875888207 - }, - version: '481', - inputs: [ - { - key: 'text', - renderTypeList: [FlowNodeInputTypeEnum.textarea, FlowNodeInputTypeEnum.reference], - valueType: WorkflowIOValueTypeEnum.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: ['rvbo634w3AYj', 'cqResult'] - } - ], - outputs: [] - }, - { - nodeId: 'MNMMMIjjWyMU', - name: '知识库搜索', - intro: '调用“语义检索”和“全文检索”能力,从“知识库”中查找可能与问题相关的参考内容', - avatar: 'core/workflow/template/datasetSearch', - flowNodeType: FlowNodeTypeEnum.datasetSearchNode, - showStatus: true, - position: { - x: 1851.010152279949, - y: -613.3555232387284 - }, - version: '481', - inputs: [ - { - key: 'datasets', - renderTypeList: [FlowNodeInputTypeEnum.selectDataset, FlowNodeInputTypeEnum.reference], - label: 'core.module.input.label.Select dataset', - value: [], - valueType: WorkflowIOValueTypeEnum.selectDataset, - list: [], - required: true - }, - { - key: 'similarity', - renderTypeList: [FlowNodeInputTypeEnum.selectDatasetParamsModal], - label: '', - value: 0.4, - valueType: WorkflowIOValueTypeEnum.number - }, - { - key: 'limit', - renderTypeList: [FlowNodeInputTypeEnum.hidden], - label: '', - value: 1500, - valueType: WorkflowIOValueTypeEnum.number - }, - { - key: 'searchMode', - renderTypeList: [FlowNodeInputTypeEnum.hidden], - label: '', - valueType: WorkflowIOValueTypeEnum.string, - value: 'embedding' - }, - { - key: 'usingReRank', - renderTypeList: [FlowNodeInputTypeEnum.hidden], - label: '', - valueType: WorkflowIOValueTypeEnum.boolean, - value: false - }, - { - key: 'datasetSearchUsingExtensionQuery', - renderTypeList: [FlowNodeInputTypeEnum.hidden], - label: '', - valueType: WorkflowIOValueTypeEnum.boolean, - value: true - }, - { - key: 'datasetSearchExtensionModel', - renderTypeList: [FlowNodeInputTypeEnum.hidden], - label: '', - valueType: WorkflowIOValueTypeEnum.string - }, - { - key: 'datasetSearchExtensionBg', - renderTypeList: [FlowNodeInputTypeEnum.hidden], - label: '', - valueType: WorkflowIOValueTypeEnum.string, - value: '' - }, - { - key: 'userChatInput', - renderTypeList: [FlowNodeInputTypeEnum.reference, FlowNodeInputTypeEnum.textarea], - valueType: WorkflowIOValueTypeEnum.string, - label: '用户问题', - required: true, - toolDescription: '需要检索的内容', - value: ['workflowStartNodeId', 'userChatInput'] - } - ], - outputs: [ - { - id: 'quoteQA', - key: 'quoteQA', - label: 'core.module.Dataset quote.label', - description: '特殊数组格式,搜索结果为空时,返回空数组。', - type: FlowNodeOutputTypeEnum.static, - valueType: WorkflowIOValueTypeEnum.datasetQuote - } - ] - } - ], - edges: [ - { - source: 'workflowStartNodeId', - target: 'rvbo634w3AYj', - sourceHandle: 'workflowStartNodeId-source-right', - targetHandle: 'rvbo634w3AYj-target-left' - }, - { - source: 'rvbo634w3AYj', - target: '7kwgL1dVlwG6', - sourceHandle: 'rvbo634w3AYj-source-agex', - targetHandle: '7kwgL1dVlwG6-target-left' - }, - { - source: 'rvbo634w3AYj', - target: 'MNMMMIjjWyMU', - sourceHandle: 'rvbo634w3AYj-source-wqre', - targetHandle: 'MNMMMIjjWyMU-target-left' - }, - { - source: 'MNMMMIjjWyMU', - target: '7BdojPlukIQw', - sourceHandle: 'MNMMMIjjWyMU-source-right', - targetHandle: '7BdojPlukIQw-target-left' - }, - { - source: 'rvbo634w3AYj', - target: '7kwgL1dVlwG6', - sourceHandle: 'rvbo634w3AYj-source-sdfa', - targetHandle: '7kwgL1dVlwG6-target-left' - } - ] - } -]; - -export const pluginTemplates: TemplateType = [ - { - id: 'plugin-simple', - avatar: 'core/workflow/template/aiChat', - name: '默认模板', - intro: '标准的插件初始模板', - type: AppTypeEnum.plugin, - modules: [ + [AppTypeEnum.plugin]: { + avatar: 'core/app/type/pluginFill', + name: '空白插件', + nodes: [ { nodeId: 'pluginInput', name: '自定义插件输入', @@ -2620,780 +388,5 @@ 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: 'core/workflow/template/workflowStart', - 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: 'core/workflow/template/httpRequest', - 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' - }, - { - 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' - } - ] - }, - { - id: 'dalle', - avatar: '/imgs/model/openai.svg', - name: 'Dalle3绘图', - intro: '通过请求Dalle3接口绘图,需要有 api key', - type: AppTypeEnum.plugin, - modules: [ - { - nodeId: 'pluginInput', - name: '自定义插件输入', - intro: '可以配置插件需要哪些输入,利用这些输入来运行插件', - avatar: 'core/workflow/template/workflowStart', - flowNodeType: 'pluginInput', - showStatus: false, - position: { - x: 412.7756423516722, - y: -99.80686112290361 - }, - version: '481', - inputs: [ - { - renderTypeList: ['reference'], - selectedTypeIndex: 0, - valueType: 'string', - canEdit: true, - key: '绘图提示词', - label: '绘图提示词', - description: '绘图提示词', - required: true, - toolDescription: '绘图提示词' - } - ], - outputs: [ - { - id: '绘图提示词', - valueType: 'string', - key: '绘图提示词', - label: '绘图提示词', - type: 'hidden' - } - ] - }, - { - nodeId: 'pluginOutput', - name: '自定义插件输出', - intro: '自定义配置外部输出,使用插件时,仅暴露自定义配置的输出', - avatar: 'core/workflow/template/pluginOutput', - flowNodeType: 'pluginOutput', - showStatus: false, - position: { - x: 1822.7195641525896, - y: -193.54601587659562 - }, - version: '481', - inputs: [ - { - renderTypeList: ['reference'], - valueType: 'string', - canEdit: true, - key: '图片访问链接', - label: '图片访问链接', - description: '', - value: ['tMvel910bnrJ', 'pJXgWoTpPoMy'] - }, - { - renderTypeList: ['reference'], - valueType: 'object', - canEdit: true, - key: 'error', - label: '错误信息', - description: '', - value: ['tMvel910bnrJ', 'error'] - } - ], - outputs: [] - }, - { - nodeId: 'tMvel910bnrJ', - name: 'HTTP 请求', - intro: '可以发出一个 HTTP 请求,实现更为复杂的操作(联网搜索、数据库查询等)', - avatar: 'core/workflow/template/httpRequest', - flowNodeType: 'httpRequest468', - showStatus: true, - position: { - x: 1044.8838211811253, - y: -414.7785530936485 - }, - version: '481', - inputs: [ - { - key: 'system_addInputParam', - renderTypeList: ['addInputParam'], - valueType: 'dynamic', - label: '', - required: false, - description: 'core.module.input.description.HTTP Dynamic Input', - customInputConfig: { - selectValueTypeList: [ - 'string', - 'number', - 'boolean', - 'object', - 'arrayString', - 'arrayNumber', - 'arrayBoolean', - 'arrayObject', - 'any', - 'chatHistory', - 'datasetQuote', - 'dynamic', - 'selectApp', - 'selectDataset' - ], - showDescription: false, - showDefaultValue: true - } - }, - { - 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}}/v1/images/generations' - }, - { - key: 'system_httpHeader', - renderTypeList: ['custom'], - valueType: 'any', - value: [ - { - key: 'Authorization', - type: 'string', - value: 'Bearer {{authorization}}' - } - ], - 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 - }, - { - renderTypeList: ['reference'], - valueType: 'string', - canEdit: true, - key: 'prompt', - label: 'prompt', - customInputConfig: { - selectValueTypeList: [ - 'string', - 'number', - 'boolean', - 'object', - 'arrayString', - 'arrayNumber', - 'arrayBoolean', - 'arrayObject', - 'any', - 'chatHistory', - 'datasetQuote', - 'dynamic', - 'selectApp', - 'selectDataset' - ], - showDescription: false, - showDefaultValue: true - }, - required: true, - value: ['pluginInput', '绘图提示词'] - } - ], - outputs: [ - { - 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' - }, - { - id: 'system_addOutputParam', - key: 'system_addOutputParam', - type: 'dynamic', - valueType: 'dynamic', - label: '', - customFieldConfig: { - selectValueTypeList: [ - 'string', - 'number', - 'boolean', - 'object', - 'arrayString', - 'arrayNumber', - 'arrayBoolean', - 'arrayObject', - 'any', - 'chatHistory', - 'datasetQuote', - 'dynamic', - 'selectApp', - 'selectDataset' - ], - showDescription: false, - showDefaultValue: false - } - }, - { - id: 'pJXgWoTpPoMy', - valueType: 'string', - type: 'dynamic', - key: 'data[0].url', - label: 'data[0].url' - } - ] - } - ], - edges: [ - { - source: 'pluginInput', - target: 'tMvel910bnrJ', - sourceHandle: 'pluginInput-source-right', - targetHandle: 'tMvel910bnrJ-target-left' - }, - { - source: 'tMvel910bnrJ', - target: 'pluginOutput', - sourceHandle: 'tMvel910bnrJ-source-right', - targetHandle: 'pluginOutput-target-left' - } - ] - }, - { - id: 'flux', - avatar: '/imgs/app/templates/flux.svg', - name: 'Flux 绘图', - intro: '通过请求 Flux 接口绘图,需要有 api key', - type: AppTypeEnum.plugin, - modules: [ - { - nodeId: 'pluginInput', - name: '自定义插件输入', - intro: '可以配置插件需要哪些输入,利用这些输入来运行插件', - avatar: 'core/workflow/template/workflowStart', - flowNodeType: 'pluginInput', - showStatus: false, - position: { - x: 351.2046235980429, - y: -77.41739975794749 - }, - version: '481', - inputs: [ - { - renderTypeList: ['reference'], - selectedTypeIndex: 0, - valueType: 'string', - canEdit: true, - key: '绘图提示词', - label: '绘图提示词', - description: '绘图提示词', - required: true, - toolDescription: '绘图提示词' - } - ], - outputs: [ - { - id: '绘图提示词', - valueType: 'string', - key: '绘图提示词', - label: '绘图提示词', - type: 'hidden' - } - ] - }, - { - nodeId: 'pluginOutput', - name: '自定义插件输出', - intro: '自定义配置外部输出,使用插件时,仅暴露自定义配置的输出', - avatar: 'core/workflow/template/pluginOutput', - flowNodeType: 'pluginOutput', - showStatus: false, - position: { - x: 1983.6911708285384, - y: -95.86447885674228 - }, - version: '481', - inputs: [ - { - renderTypeList: ['reference'], - valueType: 'string', - canEdit: true, - key: '图片访问链接', - label: '图片访问链接', - description: '', - value: ['tMvel910bnrJ', 'pJXgWoTpPoMy'] - }, - { - renderTypeList: ['reference'], - valueType: 'object', - canEdit: true, - key: 'error', - label: '错误信息', - description: '', - value: ['tMvel910bnrJ', 'error'] - } - ], - outputs: [] - }, - { - nodeId: 'tMvel910bnrJ', - name: 'HTTP 请求', - intro: '可以发出一个 HTTP 请求,实现更为复杂的操作(联网搜索、数据库查询等)', - avatar: 'core/workflow/template/httpRequest', - flowNodeType: 'httpRequest468', - showStatus: true, - position: { - x: 1138.1732435351091, - y: -416.6443415407282 - }, - version: '481', - inputs: [ - { - key: 'system_addInputParam', - renderTypeList: ['addInputParam'], - valueType: 'dynamic', - label: '', - required: false, - description: 'core.module.input.description.HTTP Dynamic Input', - customInputConfig: { - selectValueTypeList: [ - 'string', - 'number', - 'boolean', - 'object', - 'arrayString', - 'arrayNumber', - 'arrayBoolean', - 'arrayObject', - 'any', - 'chatHistory', - 'datasetQuote', - 'dynamic', - 'selectApp', - 'selectDataset' - ], - showDescription: false, - showDefaultValue: true - } - }, - { - 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://fal.run/fal-ai/flux-pro' - }, - { - key: 'system_httpHeader', - renderTypeList: ['custom'], - valueType: 'any', - value: [ - { - key: 'Authorization', - type: 'string', - value: 'Key {{apikey}}' - } - ], - 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 "prompt": "{{prompt}}",\n "image_size": "landscape_4_3",\n "num_inference_steps": 28,\n "guidance_scale": 3.5\n}', - label: '', - required: false - }, - { - renderTypeList: ['reference'], - valueType: 'string', - canEdit: true, - key: 'prompt', - label: 'prompt', - customInputConfig: { - selectValueTypeList: [ - 'string', - 'number', - 'boolean', - 'object', - 'arrayString', - 'arrayNumber', - 'arrayBoolean', - 'arrayObject', - 'any', - 'chatHistory', - 'datasetQuote', - 'dynamic', - 'selectApp', - 'selectDataset' - ], - showDescription: false, - showDefaultValue: true - }, - required: true, - value: ['pluginInput', '绘图提示词'] - } - ], - outputs: [ - { - 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' - }, - { - id: 'system_addOutputParam', - key: 'system_addOutputParam', - type: 'dynamic', - valueType: 'dynamic', - label: '', - customFieldConfig: { - selectValueTypeList: [ - 'string', - 'number', - 'boolean', - 'object', - 'arrayString', - 'arrayNumber', - 'arrayBoolean', - 'arrayObject', - 'any', - 'chatHistory', - 'datasetQuote', - 'dynamic', - 'selectApp', - 'selectDataset' - ], - showDescription: false, - showDefaultValue: false - } - }, - { - id: 'pJXgWoTpPoMy', - valueType: 'string', - type: 'dynamic', - key: 'images[0].url', - label: 'images[0].url' - } - ] - } - ], - edges: [ - { - source: 'pluginInput', - target: 'tMvel910bnrJ', - sourceHandle: 'pluginInput-source-right', - targetHandle: 'tMvel910bnrJ-target-left' - }, - { - source: 'tMvel910bnrJ', - target: 'pluginOutput', - sourceHandle: 'tMvel910bnrJ-source-right', - targetHandle: 'pluginOutput-target-left' - } - ] } -]; - -export const defaultAppTemplates = [ - simpleBotTemplates[0], - simpleBotTemplates[1], - workflowTemplates[0], - workflowTemplates[1] -]; +};