From 211061d1228b1e4098ad2474fca1dd0fc5ac6dc9 Mon Sep 17 00:00:00 2001 From: Archer <545436317@qq.com> Date: Tue, 12 Nov 2024 18:13:21 +0800 Subject: [PATCH] fix: null pointer (#3130) * fix: null pointer * perf: not input text * update doc url --- .../workflow/template/system/aiChat/index.ts | 3 +- .../template/system/assignedAnswer.ts | 2 +- .../template/system/classifyQuestion/index.ts | 2 +- .../template/system/contextExtract/index.ts | 2 +- .../template/system/customFeedback.ts | 2 +- .../workflow/template/system/datasetConcat.ts | 1 + .../workflow/template/system/datasetSearch.ts | 2 +- .../core/workflow/template/system/http468.ts | 2 +- .../workflow/template/system/ifElse/index.ts | 2 +- .../template/system/interactive/userSelect.ts | 1 + .../core/workflow/template/system/laf.ts | 2 +- .../workflow/template/system/loop/loop.ts | 1 + .../template/system/readFiles/index.tsx | 3 +- .../workflow/template/system/sandbox/index.ts | 2 +- .../workflow/template/system/textEditor.ts | 2 +- .../core/workflow/template/system/tools.ts | 2 +- .../template/system/variableUpdate/index.tsx | 1 + .../workflow/template/system/workflowStart.ts | 2 +- .../workflow/dispatch/agent/runTool/index.ts | 53 ++++++++++++------- .../core/ai/AISettingModal/index.tsx | 2 +- .../components/core/app/InputGuideConfig.tsx | 2 +- .../support/laf/LafAccountModal.tsx | 2 +- .../Publish/FeiShu/FeiShuEditModal.tsx | 5 +- .../components/Publish/FeiShu/index.tsx | 5 +- .../OffiAccount/OffiAccountEditModal.tsx | 5 +- .../components/Publish/OffiAccount/index.tsx | 5 +- .../CollectionCard/WebsiteConfig.tsx | 2 +- .../components/Import/diffSource/FileLink.tsx | 5 +- .../detail/components/InputDataModal.tsx | 4 +- 29 files changed, 80 insertions(+), 44 deletions(-) diff --git a/packages/global/core/workflow/template/system/aiChat/index.ts b/packages/global/core/workflow/template/system/aiChat/index.ts index 3ac36e6bb..a346371b2 100644 --- a/packages/global/core/workflow/template/system/aiChat/index.ts +++ b/packages/global/core/workflow/template/system/aiChat/index.ts @@ -17,7 +17,6 @@ import { Input_Template_History, Input_Template_System_Prompt, Input_Template_UserChatInput, - Input_Template_Text_Quote, Input_Template_File_Link_Prompt } from '../../input'; import { chatNodeSystemPromptTip, systemPromptTip } from '../../tip'; @@ -55,7 +54,7 @@ export const AiChatModule: FlowNodeTemplateType = { intro: i18nT('workflow:template.ai_chat_intro'), showStatus: true, isTool: true, - courseUrl: '/docs/workflow/modules/ai_chat/', + courseUrl: '/docs/guide/workbench/workflow/ai_chat/', version: '4813', inputs: [ Input_Template_SettingAiModel, diff --git a/packages/global/core/workflow/template/system/assignedAnswer.ts b/packages/global/core/workflow/template/system/assignedAnswer.ts index 14f344be4..31a8eada0 100644 --- a/packages/global/core/workflow/template/system/assignedAnswer.ts +++ b/packages/global/core/workflow/template/system/assignedAnswer.ts @@ -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/', + courseUrl: '/docs/guide/workbench/workflow/reply/', version: '481', isTool: true, inputs: [ diff --git a/packages/global/core/workflow/template/system/classifyQuestion/index.ts b/packages/global/core/workflow/template/system/classifyQuestion/index.ts index 8326d823a..3aefc9479 100644 --- a/packages/global/core/workflow/template/system/classifyQuestion/index.ts +++ b/packages/global/core/workflow/template/system/classifyQuestion/index.ts @@ -31,7 +31,7 @@ export const ClassifyQuestionModule: FlowNodeTemplateType = { intro: i18nT('workflow:intro_question_classification'), showStatus: true, version: '481', - courseUrl: '/docs/workflow/modules/question_classify/', + courseUrl: '/docs/guide/workbench/workflow/question_classify/', inputs: [ { ...Input_Template_SelectAIModel, diff --git a/packages/global/core/workflow/template/system/contextExtract/index.ts b/packages/global/core/workflow/template/system/contextExtract/index.ts index 5d0333c42..f94aa7e7e 100644 --- a/packages/global/core/workflow/template/system/contextExtract/index.ts +++ b/packages/global/core/workflow/template/system/contextExtract/index.ts @@ -26,7 +26,7 @@ export const ContextExtractModule: FlowNodeTemplateType = { intro: i18nT('workflow:intro_text_content_extraction'), showStatus: true, isTool: true, - courseUrl: '/docs/workflow/modules/content_extract/', + courseUrl: '/docs/guide/workbench/workflow/content_extract/', version: '481', inputs: [ { diff --git a/packages/global/core/workflow/template/system/customFeedback.ts b/packages/global/core/workflow/template/system/customFeedback.ts index f3d5dd9c3..c49f51b34 100644 --- a/packages/global/core/workflow/template/system/customFeedback.ts +++ b/packages/global/core/workflow/template/system/customFeedback.ts @@ -17,7 +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/', + courseUrl: '/docs/guide/workbench/workflow/custom_feedback/', version: '486', inputs: [ { diff --git a/packages/global/core/workflow/template/system/datasetConcat.ts b/packages/global/core/workflow/template/system/datasetConcat.ts index 904033a09..5a43b9a02 100644 --- a/packages/global/core/workflow/template/system/datasetConcat.ts +++ b/packages/global/core/workflow/template/system/datasetConcat.ts @@ -43,6 +43,7 @@ export const DatasetConcatModule: FlowNodeTemplateType = { showStatus: false, version: '486', + courseUrl: '/docs/guide/workbench/workflow/knowledge_base_search_merge/', inputs: [ { key: NodeInputKeyEnum.datasetMaxTokens, diff --git a/packages/global/core/workflow/template/system/datasetSearch.ts b/packages/global/core/workflow/template/system/datasetSearch.ts index d83cf2f82..476d10287 100644 --- a/packages/global/core/workflow/template/system/datasetSearch.ts +++ b/packages/global/core/workflow/template/system/datasetSearch.ts @@ -29,7 +29,7 @@ export const DatasetSearchModule: FlowNodeTemplateType = { intro: Dataset_SEARCH_DESC, showStatus: true, isTool: true, - courseUrl: '/docs/workflow/modules/dataset_search/', + courseUrl: '/docs/guide/workbench/workflow/dataset_search/', version: '481', inputs: [ { diff --git a/packages/global/core/workflow/template/system/http468.ts b/packages/global/core/workflow/template/system/http468.ts index 18df6f901..a1276dccd 100644 --- a/packages/global/core/workflow/template/system/http468.ts +++ b/packages/global/core/workflow/template/system/http468.ts @@ -27,7 +27,7 @@ export const HttpNode468: FlowNodeTemplateType = { intro: i18nT('workflow:intro_http_request'), showStatus: true, isTool: true, - courseUrl: '/docs/workflow/modules/http/', + courseUrl: '/docs/guide/workbench/workflow/http/', version: '481', inputs: [ { diff --git a/packages/global/core/workflow/template/system/ifElse/index.ts b/packages/global/core/workflow/template/system/ifElse/index.ts index b50e9989f..c20b3f331 100644 --- a/packages/global/core/workflow/template/system/ifElse/index.ts +++ b/packages/global/core/workflow/template/system/ifElse/index.ts @@ -23,7 +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/', + courseUrl: '/docs/guide/workbench/workflow/tfswitch/', version: '481', inputs: [ { diff --git a/packages/global/core/workflow/template/system/interactive/userSelect.ts b/packages/global/core/workflow/template/system/interactive/userSelect.ts index f8c170d78..753255c76 100644 --- a/packages/global/core/workflow/template/system/interactive/userSelect.ts +++ b/packages/global/core/workflow/template/system/interactive/userSelect.ts @@ -25,6 +25,7 @@ export const UserSelectNode: FlowNodeTemplateType = { intro: i18nT(`app:workflow.user_select_tip`), isTool: true, version: '489', + courseUrl: '/docs/guide/workbench/workflow/user-selection/', inputs: [ { key: NodeInputKeyEnum.description, diff --git a/packages/global/core/workflow/template/system/laf.ts b/packages/global/core/workflow/template/system/laf.ts index 61dadb191..f92fada21 100644 --- a/packages/global/core/workflow/template/system/laf.ts +++ b/packages/global/core/workflow/template/system/laf.ts @@ -32,7 +32,7 @@ export const LafModule: FlowNodeTemplateType = { intro: i18nT('workflow:intro_laf_function_call'), showStatus: true, isTool: true, - courseUrl: '/docs/workflow/modules/laf/', + courseUrl: '/docs/guide/workbench/workflow/laf/', version: '481', inputs: [ { diff --git a/packages/global/core/workflow/template/system/loop/loop.ts b/packages/global/core/workflow/template/system/loop/loop.ts index 2c12f73be..4b62c449d 100644 --- a/packages/global/core/workflow/template/system/loop/loop.ts +++ b/packages/global/core/workflow/template/system/loop/loop.ts @@ -30,6 +30,7 @@ export const LoopNode: FlowNodeTemplateType = { intro: i18nT('workflow:intro_loop'), showStatus: true, version: '4811', + courseUrl: '/docs/guide/workbench/workflow/loop/', inputs: [ { key: NodeInputKeyEnum.loopInputArray, diff --git a/packages/global/core/workflow/template/system/readFiles/index.tsx b/packages/global/core/workflow/template/system/readFiles/index.tsx index e4485fe97..30f373200 100644 --- a/packages/global/core/workflow/template/system/readFiles/index.tsx +++ b/packages/global/core/workflow/template/system/readFiles/index.tsx @@ -24,7 +24,8 @@ export const ReadFilesNode: FlowNodeTemplateType = { intro: i18nT('app:workflow.read_files_tip'), showStatus: true, version: '4812', - isTool: true, + isTool: false, + courseUrl: '/docs/guide/course/fileinput/', inputs: [ { key: NodeInputKeyEnum.fileUrlList, diff --git a/packages/global/core/workflow/template/system/sandbox/index.ts b/packages/global/core/workflow/template/system/sandbox/index.ts index b66ac4bcc..5325c5e3b 100644 --- a/packages/global/core/workflow/template/system/sandbox/index.ts +++ b/packages/global/core/workflow/template/system/sandbox/index.ts @@ -26,7 +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/', + courseUrl: '/docs/guide/workbench/workflow/sandbox/', version: '482', inputs: [ { diff --git a/packages/global/core/workflow/template/system/textEditor.ts b/packages/global/core/workflow/template/system/textEditor.ts index bd1c84afc..511f28ba2 100644 --- a/packages/global/core/workflow/template/system/textEditor.ts +++ b/packages/global/core/workflow/template/system/textEditor.ts @@ -23,7 +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/', + courseUrl: '/docs/guide/workbench/workflow/text_editor/', version: '4813', inputs: [ { diff --git a/packages/global/core/workflow/template/system/tools.ts b/packages/global/core/workflow/template/system/tools.ts index a5ed862ce..29406a193 100644 --- a/packages/global/core/workflow/template/system/tools.ts +++ b/packages/global/core/workflow/template/system/tools.ts @@ -32,7 +32,7 @@ export const ToolModule: FlowNodeTemplateType = { name: i18nT('workflow:template.tool_call'), intro: i18nT('workflow:template.tool_call_intro'), showStatus: true, - courseUrl: '/docs/workflow/modules/tool/', + courseUrl: '/docs/guide/workbench/workflow/tool/', version: '4813', inputs: [ { diff --git a/packages/global/core/workflow/template/system/variableUpdate/index.tsx b/packages/global/core/workflow/template/system/variableUpdate/index.tsx index 3ad693f67..79c479891 100644 --- a/packages/global/core/workflow/template/system/variableUpdate/index.tsx +++ b/packages/global/core/workflow/template/system/variableUpdate/index.tsx @@ -20,6 +20,7 @@ export const VariableUpdateNode: FlowNodeTemplateType = { showStatus: false, isTool: true, version: '481', + courseUrl: '/docs/guide/workbench/workflow/variable_update/', inputs: [ { key: NodeInputKeyEnum.updateList, diff --git a/packages/global/core/workflow/template/system/workflowStart.ts b/packages/global/core/workflow/template/system/workflowStart.ts index c2da4a372..42d08b824 100644 --- a/packages/global/core/workflow/template/system/workflowStart.ts +++ b/packages/global/core/workflow/template/system/workflowStart.ts @@ -30,7 +30,7 @@ export const WorkflowStart: FlowNodeTemplateType = { intro: '', forbidDelete: true, unique: true, - courseUrl: '/docs/workflow/modules/input/', + courseUrl: '/docs/guide/workbench/workflow/input/', version: '481', inputs: [{ ...Input_Template_UserChatInput, toolDescription: i18nT('workflow:user_question') }], outputs: [ diff --git a/packages/service/core/workflow/dispatch/agent/runTool/index.ts b/packages/service/core/workflow/dispatch/agent/runTool/index.ts index ef6e7aca2..e64043500 100644 --- a/packages/service/core/workflow/dispatch/agent/runTool/index.ts +++ b/packages/service/core/workflow/dispatch/agent/runTool/index.ts @@ -101,7 +101,8 @@ export const dispatchRunTools = async (props: DispatchToolModuleProps): Promise< maxFiles: chatConfig?.fileSelectConfig?.maxFiles || 20, teamId, fileLinks, - inputFiles: globalFiles + inputFiles: globalFiles, + hasReadFilesTool }); const concatenateSystemPrompt = [ @@ -184,7 +185,7 @@ export const dispatchRunTools = async (props: DispatchToolModuleProps): Promise< } const lastMessage = adaptMessages[adaptMessages.length - 1]; - if (typeof lastMessage.content === 'string') { + if (typeof lastMessage?.content === 'string') { lastMessage.content = replaceVariable(Prompt_Tool_Call, { question: lastMessage.content }); @@ -271,7 +272,8 @@ const getMultiInput = async ({ requestOrigin, maxFiles, teamId, - inputFiles + inputFiles, + hasReadFilesTool }: { histories: ChatItemType[]; fileLinks?: string[]; @@ -279,9 +281,10 @@ const getMultiInput = async ({ maxFiles: number; teamId: string; inputFiles: UserChatItemValueItemType['file'][]; + hasReadFilesTool: boolean; }) => { // Not file quote - if (!fileLinks) { + if (!fileLinks || hasReadFilesTool) { return { documentQuoteText: '', userFiles: inputFiles @@ -323,28 +326,40 @@ const toolCallMessagesAdapt = ({ }: { userInput: UserChatItemValueItemType[]; skip?: boolean; -}) => { +}): UserChatItemValueItemType[] => { if (skip) return userInput; const files = userInput.filter((item) => item.type === 'file'); if (files.length > 0) { - return userInput.map((item) => { - if (item.type === 'text') { - const filesCount = files.filter((file) => file.file?.type === 'file').length; - const imgCount = files.filter((file) => file.file?.type === 'image').length; - const text = item.text?.content || ''; + const filesCount = files.filter((file) => file.file?.type === 'file').length; + const imgCount = files.filter((file) => file.file?.type === 'image').length; - return { - ...item, - text: { - content: getMultiplePrompt({ fileCount: filesCount, imgCount, question: text }) - } - }; + if (userInput.some((item) => item.type === 'text')) { + return userInput.map((item) => { + if (item.type === 'text') { + const text = item.text?.content || ''; + + return { + ...item, + text: { + content: getMultiplePrompt({ fileCount: filesCount, imgCount, question: text }) + } + }; + } + return item; + }); + } + + // Every input is a file + return [ + { + type: ChatItemValueTypeEnum.text, + text: { + content: getMultiplePrompt({ fileCount: filesCount, imgCount, question: '' }) + } } - - return item; - }); + ]; } return userInput; diff --git a/projects/app/src/components/core/ai/AISettingModal/index.tsx b/projects/app/src/components/core/ai/AISettingModal/index.tsx index 73a134f06..2219faa94 100644 --- a/projects/app/src/components/core/ai/AISettingModal/index.tsx +++ b/projects/app/src/components/core/ai/AISettingModal/index.tsx @@ -82,7 +82,7 @@ const AIChatSettingsModal = ({ {t('common:core.ai.AI settings')} {feConfigs?.docUrl && ( {chatT('custom_input_guide_url')} window.open(getDocPath('/docs/course/chat_input_guide'))} + onClick={() => window.open(getDocPath('/docs/guide/course/chat_input_guide/'))} color={'primary.700'} alignItems={'center'} cursor={'pointer'} diff --git a/projects/app/src/components/support/laf/LafAccountModal.tsx b/projects/app/src/components/support/laf/LafAccountModal.tsx index cb5e25e4b..780081af3 100644 --- a/projects/app/src/components/support/laf/LafAccountModal.tsx +++ b/projects/app/src/components/support/laf/LafAccountModal.tsx @@ -101,7 +101,7 @@ const LafAccountModal = ({ {t('common:support.user.Laf account intro')} - + {t('common:support.user.Laf account course')} diff --git a/projects/app/src/pages/app/detail/components/Publish/FeiShu/FeiShuEditModal.tsx b/projects/app/src/pages/app/detail/components/Publish/FeiShu/FeiShuEditModal.tsx index 4bc10b272..dd04ccbda 100644 --- a/projects/app/src/pages/app/detail/components/Publish/FeiShu/FeiShuEditModal.tsx +++ b/projects/app/src/pages/app/detail/components/Publish/FeiShu/FeiShuEditModal.tsx @@ -90,7 +90,10 @@ const FeiShuEditModal = ({ {t('publish:feishu_api')} {feConfigs?.docUrl && ( { {feConfigs?.docUrl && ( {t('publish:official_account.params')} {feConfigs?.docUrl && ( { {feConfigs?.docUrl && ( { {t('common:core.dataset.website.Selector')} {feConfigs?.docUrl && ( - + {t('common:core.dataset.website.Selector Course')} )} diff --git a/projects/app/src/pages/dataset/detail/components/InputDataModal.tsx b/projects/app/src/pages/dataset/detail/components/InputDataModal.tsx index e77363a17..ca5d4b11e 100644 --- a/projects/app/src/pages/dataset/detail/components/InputDataModal.tsx +++ b/projects/app/src/pages/dataset/detail/components/InputDataModal.tsx @@ -99,7 +99,9 @@ const InputDataModal = ({ mr={'0.38rem'} color={'myGray.500'} ml={1} - onClick={() => window.open(getDocPath('/docs/course/dataset_engine'), '_blank')} + onClick={() => + window.open(getDocPath('/docs/guide/knowledge_base/dataset_engine/'), '_blank') + } _hover={{ color: 'primary.600', cursor: 'pointer'