Skip to content

Commit

Permalink
feat: add node course url config (#2897)
Browse files Browse the repository at this point in the history
* feat: add node course url config

* change plugin course url

* change default doc url

* change url store

* delete unused code
  • Loading branch information
newfish-cmyk authored and c121914yu committed Oct 14, 2024
1 parent 6af761a commit 6251887
Show file tree
Hide file tree
Showing 27 changed files with 49 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export const AiChatModule: FlowNodeTemplateType = {
intro: i18nT('workflow:template.ai_chat_intro'),
showStatus: true,
isTool: true,
courseUrl: '/docs/workflow/modules/ai_chat/',
version: '481',
inputs: [
Input_Template_SettingAiModel,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const AssignedAnswerModule: FlowNodeTemplateType = {
avatar: 'core/workflow/template/reply',
name: i18nT('workflow:assigned_reply'),
intro: i18nT('workflow:intro_assigned_reply'),

courseUrl: '/docs/workflow/modules/reply/',
version: '481',
isTool: true,
inputs: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export const ClassifyQuestionModule: FlowNodeTemplateType = {
intro: i18nT('workflow:intro_question_classification'),
showStatus: true,
version: '481',
courseUrl: '/docs/workflow/modules/question_classify/',
inputs: [
{
...Input_Template_SelectAIModel,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export const ContextExtractModule: FlowNodeTemplateType = {
intro: i18nT('workflow:intro_text_content_extraction'),
showStatus: true,
isTool: true,
courseUrl: '/docs/workflow/modules/content_extract/',
version: '481',
inputs: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export const CustomFeedbackNode: FlowNodeTemplateType = {
avatar: 'core/workflow/template/customFeedback',
name: i18nT('workflow:custom_feedback'),
intro: i18nT('workflow:intro_custom_feedback'),
courseUrl: '/docs/workflow/modules/custom_feedback/',
version: '486',
inputs: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export const DatasetSearchModule: FlowNodeTemplateType = {
intro: Dataset_SEARCH_DESC,
showStatus: true,
isTool: true,
courseUrl: '/docs/workflow/modules/dataset_search/',
version: '481',
inputs: [
{
Expand Down
1 change: 1 addition & 0 deletions packages/global/core/workflow/template/system/http468.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export const HttpNode468: FlowNodeTemplateType = {
intro: i18nT('workflow:intro_http_request'),
showStatus: true,
isTool: true,
courseUrl: '/docs/workflow/modules/http/',
version: '481',
inputs: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export const IfElseNode: FlowNodeTemplateType = {
name: i18nT('workflow:condition_checker'),
intro: i18nT('workflow:execute_different_branches_based_on_conditions'),
showStatus: true,
courseUrl: '/docs/workflow/modules/tfswitch/',
version: '481',
inputs: [
{
Expand Down
1 change: 1 addition & 0 deletions packages/global/core/workflow/template/system/laf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export const LafModule: FlowNodeTemplateType = {
intro: i18nT('workflow:intro_laf_function_call'),
showStatus: true,
isTool: true,
courseUrl: '/docs/workflow/modules/laf/',
version: '481',
inputs: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export const CodeNode: FlowNodeTemplateType = {
name: i18nT('workflow:code_execution'),
intro: i18nT('workflow:execute_a_simple_script_code_usually_for_complex_data_processing'),
showStatus: true,
courseUrl: '/docs/workflow/modules/sandbox/',
version: '482',
inputs: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export const TextEditorNode: FlowNodeTemplateType = {
avatar: 'core/workflow/template/textConcat',
name: i18nT('workflow:text_concatenation'),
intro: i18nT('workflow:intro_text_concatenation'),
courseUrl: '/docs/workflow/modules/text_editor/',
version: '486',
inputs: [
{
Expand Down
1 change: 1 addition & 0 deletions packages/global/core/workflow/template/system/tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export const ToolModule: FlowNodeTemplateType = {
name: i18nT('workflow:template.tool_call'),
intro: i18nT('workflow:template.tool_call_intro'),
showStatus: true,
courseUrl: '/docs/workflow/modules/input/',
version: '481',
inputs: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export const WorkflowStart: FlowNodeTemplateType = {
intro: '',
forbidDelete: true,
unique: true,
courseUrl: '/docs/workflow/modules/input/',
version: '481',
inputs: [{ ...Input_Template_UserChatInput, toolDescription: i18nT('workflow:user_question') }],
outputs: [
Expand Down
2 changes: 1 addition & 1 deletion packages/global/core/workflow/type/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export type WorkflowTemplateType = {
avatar: string;
intro?: string;
author?: string;
inputExplanationUrl?: string;
courseUrl?: string;
version: string;

showStatus?: boolean;
Expand Down
2 changes: 1 addition & 1 deletion packages/global/core/workflow/type/node.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ export type FlowNodeCommonType = {
avatar?: string;
name: string;
intro?: string; // template list intro
inputExplanationUrl?: string;
showStatus?: boolean; // chatting response step status
version: string;

Expand Down Expand Up @@ -69,6 +68,7 @@ export type FlowNodeTemplateType = FlowNodeCommonType & {
unique?: boolean;

diagram?: string; // diagram url
courseUrl?: string; // course url
};

export type NodeTemplateListItemType = {
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/src/Doc2X/FileImg2text/template.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"name": "Doc2X 图像(文件)识别",
"avatar": "plugins/doc2x",
"intro": "将上传的图片文件发送至Doc2X进行解析,返回带LaTeX公式的markdown格式的文本",
"inputExplanationUrl": "https://fael3z0zfze.feishu.cn/wiki/Rkc5witXWiJoi5kORd2cofh6nDg?fromScene=spaceOverview",
"courseUrl": "https://fael3z0zfze.feishu.cn/wiki/Rkc5witXWiJoi5kORd2cofh6nDg?fromScene=spaceOverview",
"showStatus": true,
"weight": 10,

Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/src/Doc2X/FilePDF2text/template.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"name": "Doc2X PDF文件(文件)识别",
"avatar": "plugins/doc2x",
"intro": "将上传的PDF文件发送至Doc2X进行解析,返回带LaTeX公式的markdown格式的文本",
"inputExplanationUrl": "https://fael3z0zfze.feishu.cn/wiki/Rkc5witXWiJoi5kORd2cofh6nDg?fromScene=spaceOverview",
"courseUrl": "https://fael3z0zfze.feishu.cn/wiki/Rkc5witXWiJoi5kORd2cofh6nDg?fromScene=spaceOverview",
"showStatus": true,
"weight": 10,

Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/src/Doc2X/URLImg2text/template.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"name": "Doc2X 图像(URL)识别",
"avatar": "plugins/doc2x",
"intro": "从URL下载图片并发送至Doc2X进行解析,返回带LaTeX公式的markdown格式的文本",
"inputExplanationUrl": "https://fael3z0zfze.feishu.cn/wiki/Rkc5witXWiJoi5kORd2cofh6nDg?fromScene=spaceOverview",
"courseUrl": "https://fael3z0zfze.feishu.cn/wiki/Rkc5witXWiJoi5kORd2cofh6nDg?fromScene=spaceOverview",
"showStatus": true,
"weight": 10,

Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/src/Doc2X/URLPDF2text/template.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"name": "Doc2X PDF文件(URL)识别",
"avatar": "plugins/doc2x",
"intro": "从URL下载PDF文件,并发送至Doc2X进行解析,返回带LaTeX公式的markdown格式的文本",
"inputExplanationUrl": "https://fael3z0zfze.feishu.cn/wiki/Rkc5witXWiJoi5kORd2cofh6nDg?fromScene=spaceOverview",
"courseUrl": "https://fael3z0zfze.feishu.cn/wiki/Rkc5witXWiJoi5kORd2cofh6nDg?fromScene=spaceOverview",
"showStatus": true,
"weight": 10,

Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/src/feishu/template.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"name": "飞书机器人 webhook",
"avatar": "/appMarketTemplates/plugin-feishu/avatar.svg",
"intro": "向飞书机器人发起 webhook 请求。",
"inputExplanationUrl": "https://open.feishu.cn/document/client-docs/bot-v3/add-custom-bot#f62e72d5",
"courseUrl": "https://open.feishu.cn/document/client-docs/bot-v3/add-custom-bot#f62e72d5",
"showStatus": false,
"weight": 10,

Expand Down
2 changes: 1 addition & 1 deletion packages/service/core/app/plugin/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export async function getChildAppPreviewNode({
avatar: app.avatar,
name: app.name,
intro: app.intro,
inputExplanationUrl: app.inputExplanationUrl,
courseUrl: app.courseUrl,
showStatus: app.showStatus,
isTool: true,
version: app.version,
Expand Down
1 change: 1 addition & 0 deletions packages/web/i18n/en/workflow.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"Code": "Code",
"Confirm_sync_node": "It will be updated to the latest node configuration and fields that do not exist in the template will be deleted (including all custom fields).\n\nIf the fields are complex, it is recommended that you copy a node first and then update the original node to facilitate parameter copying.",
"Node_variables": "Node variables",
"Node.Open_Node_Course": "Open node course",
"Quote_prompt_setting": "Quote prompt",
"Variable.Variable type": "Variable type",
"Variable_name": "Variable name",
Expand Down
1 change: 1 addition & 0 deletions packages/web/i18n/zh/workflow.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"Code": "代码",
"Confirm_sync_node": "将会更新至最新的节点配置,不存在模板中的字段将会被删除(包括所有自定义字段)。\n如果字段较为复杂,建议您先复制一份节点,再更新原来的节点,便于参数复制。",
"Node_variables": "节点变量",
"Node.Open_Node_Course": "查看节点教程",
"Quote_prompt_setting": "引用提示词配置",
"Variable.Variable type": "变量类型",
"Variable_name": "变量名",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -354,11 +354,11 @@ const RenderList = React.memo(function RenderList({
<HStack mb={4} spacing={1} fontSize={'sm'}>
<MyIcon name={'common/info'} w={'1.25rem'} />
<Box flex={1}>{t('app:tool_input_param_tip')}</Box>
{configTool.inputExplanationUrl && (
{configTool.courseUrl && (
<Box
cursor={'pointer'}
color={'primary.500'}
onClick={() => window.open(configTool.inputExplanationUrl, '_blank')}
onClick={() => window.open(configTool.courseUrl, '_blank')}
>
{t('app:workflow.Input guide')}
</Box>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,12 @@
import React from 'react';
import { Box, StackProps, HStack } from '@chakra-ui/react';
import { useTranslation } from 'next-i18next';

const IOTitle = ({
text,
inputExplanationUrl,
...props
}: { text?: 'Input' | 'Output' | string; inputExplanationUrl?: string } & StackProps) => {
const { t } = useTranslation();
import MyIcon from '@fastgpt/web/components/common/Icon';

const IOTitle = ({ text, ...props }: { text?: 'Input' | 'Output' | string } & StackProps) => {
return (
<HStack fontSize={'md'} alignItems={'center'} fontWeight={'medium'} mb={3} {...props}>
<Box w={'3px'} h={'14px'} borderRadius={'13px'} bg={'primary.600'} />
<Box color={'myGray.900'}>{text}</Box>
<Box flex={1} />

{inputExplanationUrl && (
<Box
cursor={'pointer'}
color={'primary.500'}
onClick={() => window.open(inputExplanationUrl, '_blank')}
>
{t('app:workflow.Input guide')}
</Box>
)}
</HStack>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,7 @@ const NodeSimple = ({
{filterHiddenInputs.length > 0 && (
<>
<Container>
<IOTitle
text={t('common:common.Input')}
inputExplanationUrl={data.inputExplanationUrl}
/>
<IOTitle text={t('common:common.Input')} />
<RenderInput nodeId={nodeId} flowInputList={commonInputs} />
</Container>
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import MyTooltip from '@fastgpt/web/components/common/MyTooltip';
import { useRequest2 } from '@fastgpt/web/hooks/useRequest';
import { useWorkflowUtils } from '../../hooks/useUtils';
import { WholeResponseContent } from '@/components/core/chat/components/WholeResponseModal';
import { useSystemStore } from '@/web/common/system/useSystemStore';
import { getDocPath } from '@/web/common/system/doc';

type Props = FlowNodeItemType & {
children?: React.ReactNode | React.ReactNode[] | string;
Expand Down Expand Up @@ -65,7 +67,6 @@ const NodeCard = (props: Props) => {
isFolded,
...customStyle
} = props;

const nodeList = useContextSelector(WorkflowContext, (v) => v.nodeList);
const setHoverNodeId = useContextSelector(WorkflowContext, (v) => v.setHoverNodeId);
const onUpdateNodeError = useContextSelector(WorkflowContext, (v) => v.onUpdateNodeError);
Expand Down Expand Up @@ -102,14 +103,6 @@ const NodeCard = (props: Props) => {
if (!node?.pluginId) return;
const template = await getPreviewPluginNode({ appId: node.pluginId });

// Focus update plugin latest inputExplanationUrl
onChangeNode({
nodeId,
type: 'attr',
key: 'inputExplanationUrl',
value: template.inputExplanationUrl
});

return template;
} else {
const template = moduleTemplatesFlat.find(
Expand Down Expand Up @@ -275,6 +268,24 @@ const NodeCard = (props: Props) => {
</Box>
</MyTooltip>
)}
{!!nodeTemplate?.diagram && node?.courseUrl && (
<Box bg={'myGray.300'} w={'1px'} h={'12px'} mx={1} />
)}
{node?.courseUrl && !hasNewVersion && (
<MyTooltip label={t('workflow:Node.Open_Node_Course')}>
<MyIcon
cursor={'pointer'}
name="book"
color={'primary.600'}
w={'18px'}
ml={1}
_hover={{
color: 'primary.800'
}}
onClick={() => window.open(getDocPath(node.courseUrl || ''), '_blank')}
/>
</MyTooltip>
)}
</Flex>
<NodeIntro nodeId={nodeId} intro={intro} />
</Box>
Expand All @@ -295,6 +306,7 @@ const NodeCard = (props: Props) => {
onOpenConfirmSync,
onClickSyncVersion,
nodeTemplate?.diagram,
node?.courseUrl,
intro,
menuForbid,
nodeList,
Expand Down

0 comments on commit 6251887

Please sign in to comment.