Skip to content

Commit 211061d

Browse files
committed
fix: null pointer (labring#3130)
* fix: null pointer * perf: not input text * update doc url
1 parent dc8aeef commit 211061d

File tree

29 files changed

+80
-44
lines changed

29 files changed

+80
-44
lines changed

packages/global/core/workflow/template/system/aiChat/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import {
1717
Input_Template_History,
1818
Input_Template_System_Prompt,
1919
Input_Template_UserChatInput,
20-
Input_Template_Text_Quote,
2120
Input_Template_File_Link_Prompt
2221
} from '../../input';
2322
import { chatNodeSystemPromptTip, systemPromptTip } from '../../tip';
@@ -55,7 +54,7 @@ export const AiChatModule: FlowNodeTemplateType = {
5554
intro: i18nT('workflow:template.ai_chat_intro'),
5655
showStatus: true,
5756
isTool: true,
58-
courseUrl: '/docs/workflow/modules/ai_chat/',
57+
courseUrl: '/docs/guide/workbench/workflow/ai_chat/',
5958
version: '4813',
6059
inputs: [
6160
Input_Template_SettingAiModel,

packages/global/core/workflow/template/system/assignedAnswer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export const AssignedAnswerModule: FlowNodeTemplateType = {
1717
avatar: 'core/workflow/template/reply',
1818
name: i18nT('workflow:assigned_reply'),
1919
intro: i18nT('workflow:intro_assigned_reply'),
20-
courseUrl: '/docs/workflow/modules/reply/',
20+
courseUrl: '/docs/guide/workbench/workflow/reply/',
2121
version: '481',
2222
isTool: true,
2323
inputs: [

packages/global/core/workflow/template/system/classifyQuestion/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export const ClassifyQuestionModule: FlowNodeTemplateType = {
3131
intro: i18nT('workflow:intro_question_classification'),
3232
showStatus: true,
3333
version: '481',
34-
courseUrl: '/docs/workflow/modules/question_classify/',
34+
courseUrl: '/docs/guide/workbench/workflow/question_classify/',
3535
inputs: [
3636
{
3737
...Input_Template_SelectAIModel,

packages/global/core/workflow/template/system/contextExtract/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export const ContextExtractModule: FlowNodeTemplateType = {
2626
intro: i18nT('workflow:intro_text_content_extraction'),
2727
showStatus: true,
2828
isTool: true,
29-
courseUrl: '/docs/workflow/modules/content_extract/',
29+
courseUrl: '/docs/guide/workbench/workflow/content_extract/',
3030
version: '481',
3131
inputs: [
3232
{

packages/global/core/workflow/template/system/customFeedback.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export const CustomFeedbackNode: FlowNodeTemplateType = {
1717
avatar: 'core/workflow/template/customFeedback',
1818
name: i18nT('workflow:custom_feedback'),
1919
intro: i18nT('workflow:intro_custom_feedback'),
20-
courseUrl: '/docs/workflow/modules/custom_feedback/',
20+
courseUrl: '/docs/guide/workbench/workflow/custom_feedback/',
2121
version: '486',
2222
inputs: [
2323
{

packages/global/core/workflow/template/system/datasetConcat.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export const DatasetConcatModule: FlowNodeTemplateType = {
4343

4444
showStatus: false,
4545
version: '486',
46+
courseUrl: '/docs/guide/workbench/workflow/knowledge_base_search_merge/',
4647
inputs: [
4748
{
4849
key: NodeInputKeyEnum.datasetMaxTokens,

packages/global/core/workflow/template/system/datasetSearch.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export const DatasetSearchModule: FlowNodeTemplateType = {
2929
intro: Dataset_SEARCH_DESC,
3030
showStatus: true,
3131
isTool: true,
32-
courseUrl: '/docs/workflow/modules/dataset_search/',
32+
courseUrl: '/docs/guide/workbench/workflow/dataset_search/',
3333
version: '481',
3434
inputs: [
3535
{

packages/global/core/workflow/template/system/http468.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export const HttpNode468: FlowNodeTemplateType = {
2727
intro: i18nT('workflow:intro_http_request'),
2828
showStatus: true,
2929
isTool: true,
30-
courseUrl: '/docs/workflow/modules/http/',
30+
courseUrl: '/docs/guide/workbench/workflow/http/',
3131
version: '481',
3232
inputs: [
3333
{

packages/global/core/workflow/template/system/ifElse/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export const IfElseNode: FlowNodeTemplateType = {
2323
name: i18nT('workflow:condition_checker'),
2424
intro: i18nT('workflow:execute_different_branches_based_on_conditions'),
2525
showStatus: true,
26-
courseUrl: '/docs/workflow/modules/tfswitch/',
26+
courseUrl: '/docs/guide/workbench/workflow/tfswitch/',
2727
version: '481',
2828
inputs: [
2929
{

packages/global/core/workflow/template/system/interactive/userSelect.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export const UserSelectNode: FlowNodeTemplateType = {
2525
intro: i18nT(`app:workflow.user_select_tip`),
2626
isTool: true,
2727
version: '489',
28+
courseUrl: '/docs/guide/workbench/workflow/user-selection/',
2829
inputs: [
2930
{
3031
key: NodeInputKeyEnum.description,

packages/global/core/workflow/template/system/laf.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export const LafModule: FlowNodeTemplateType = {
3232
intro: i18nT('workflow:intro_laf_function_call'),
3333
showStatus: true,
3434
isTool: true,
35-
courseUrl: '/docs/workflow/modules/laf/',
35+
courseUrl: '/docs/guide/workbench/workflow/laf/',
3636
version: '481',
3737
inputs: [
3838
{

packages/global/core/workflow/template/system/loop/loop.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export const LoopNode: FlowNodeTemplateType = {
3030
intro: i18nT('workflow:intro_loop'),
3131
showStatus: true,
3232
version: '4811',
33+
courseUrl: '/docs/guide/workbench/workflow/loop/',
3334
inputs: [
3435
{
3536
key: NodeInputKeyEnum.loopInputArray,

packages/global/core/workflow/template/system/readFiles/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ export const ReadFilesNode: FlowNodeTemplateType = {
2424
intro: i18nT('app:workflow.read_files_tip'),
2525
showStatus: true,
2626
version: '4812',
27-
isTool: true,
27+
isTool: false,
28+
courseUrl: '/docs/guide/course/fileinput/',
2829
inputs: [
2930
{
3031
key: NodeInputKeyEnum.fileUrlList,

packages/global/core/workflow/template/system/sandbox/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export const CodeNode: FlowNodeTemplateType = {
2626
name: i18nT('workflow:code_execution'),
2727
intro: i18nT('workflow:execute_a_simple_script_code_usually_for_complex_data_processing'),
2828
showStatus: true,
29-
courseUrl: '/docs/workflow/modules/sandbox/',
29+
courseUrl: '/docs/guide/workbench/workflow/sandbox/',
3030
version: '482',
3131
inputs: [
3232
{

packages/global/core/workflow/template/system/textEditor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export const TextEditorNode: FlowNodeTemplateType = {
2323
avatar: 'core/workflow/template/textConcat',
2424
name: i18nT('workflow:text_concatenation'),
2525
intro: i18nT('workflow:intro_text_concatenation'),
26-
courseUrl: '/docs/workflow/modules/text_editor/',
26+
courseUrl: '/docs/guide/workbench/workflow/text_editor/',
2727
version: '4813',
2828
inputs: [
2929
{

packages/global/core/workflow/template/system/tools.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export const ToolModule: FlowNodeTemplateType = {
3232
name: i18nT('workflow:template.tool_call'),
3333
intro: i18nT('workflow:template.tool_call_intro'),
3434
showStatus: true,
35-
courseUrl: '/docs/workflow/modules/tool/',
35+
courseUrl: '/docs/guide/workbench/workflow/tool/',
3636
version: '4813',
3737
inputs: [
3838
{

packages/global/core/workflow/template/system/variableUpdate/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export const VariableUpdateNode: FlowNodeTemplateType = {
2020
showStatus: false,
2121
isTool: true,
2222
version: '481',
23+
courseUrl: '/docs/guide/workbench/workflow/variable_update/',
2324
inputs: [
2425
{
2526
key: NodeInputKeyEnum.updateList,

packages/global/core/workflow/template/system/workflowStart.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export const WorkflowStart: FlowNodeTemplateType = {
3030
intro: '',
3131
forbidDelete: true,
3232
unique: true,
33-
courseUrl: '/docs/workflow/modules/input/',
33+
courseUrl: '/docs/guide/workbench/workflow/input/',
3434
version: '481',
3535
inputs: [{ ...Input_Template_UserChatInput, toolDescription: i18nT('workflow:user_question') }],
3636
outputs: [

packages/service/core/workflow/dispatch/agent/runTool/index.ts

Lines changed: 34 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ export const dispatchRunTools = async (props: DispatchToolModuleProps): Promise<
101101
maxFiles: chatConfig?.fileSelectConfig?.maxFiles || 20,
102102
teamId,
103103
fileLinks,
104-
inputFiles: globalFiles
104+
inputFiles: globalFiles,
105+
hasReadFilesTool
105106
});
106107

107108
const concatenateSystemPrompt = [
@@ -184,7 +185,7 @@ export const dispatchRunTools = async (props: DispatchToolModuleProps): Promise<
184185
}
185186

186187
const lastMessage = adaptMessages[adaptMessages.length - 1];
187-
if (typeof lastMessage.content === 'string') {
188+
if (typeof lastMessage?.content === 'string') {
188189
lastMessage.content = replaceVariable(Prompt_Tool_Call, {
189190
question: lastMessage.content
190191
});
@@ -271,17 +272,19 @@ const getMultiInput = async ({
271272
requestOrigin,
272273
maxFiles,
273274
teamId,
274-
inputFiles
275+
inputFiles,
276+
hasReadFilesTool
275277
}: {
276278
histories: ChatItemType[];
277279
fileLinks?: string[];
278280
requestOrigin?: string;
279281
maxFiles: number;
280282
teamId: string;
281283
inputFiles: UserChatItemValueItemType['file'][];
284+
hasReadFilesTool: boolean;
282285
}) => {
283286
// Not file quote
284-
if (!fileLinks) {
287+
if (!fileLinks || hasReadFilesTool) {
285288
return {
286289
documentQuoteText: '',
287290
userFiles: inputFiles
@@ -323,28 +326,40 @@ const toolCallMessagesAdapt = ({
323326
}: {
324327
userInput: UserChatItemValueItemType[];
325328
skip?: boolean;
326-
}) => {
329+
}): UserChatItemValueItemType[] => {
327330
if (skip) return userInput;
328331

329332
const files = userInput.filter((item) => item.type === 'file');
330333

331334
if (files.length > 0) {
332-
return userInput.map((item) => {
333-
if (item.type === 'text') {
334-
const filesCount = files.filter((file) => file.file?.type === 'file').length;
335-
const imgCount = files.filter((file) => file.file?.type === 'image').length;
336-
const text = item.text?.content || '';
335+
const filesCount = files.filter((file) => file.file?.type === 'file').length;
336+
const imgCount = files.filter((file) => file.file?.type === 'image').length;
337337

338-
return {
339-
...item,
340-
text: {
341-
content: getMultiplePrompt({ fileCount: filesCount, imgCount, question: text })
342-
}
343-
};
344-
}
338+
if (userInput.some((item) => item.type === 'text')) {
339+
return userInput.map((item) => {
340+
if (item.type === 'text') {
341+
const text = item.text?.content || '';
345342

346-
return item;
347-
});
343+
return {
344+
...item,
345+
text: {
346+
content: getMultiplePrompt({ fileCount: filesCount, imgCount, question: text })
347+
}
348+
};
349+
}
350+
return item;
351+
});
352+
}
353+
354+
// Every input is a file
355+
return [
356+
{
357+
type: ChatItemValueTypeEnum.text,
358+
text: {
359+
content: getMultiplePrompt({ fileCount: filesCount, imgCount, question: '' })
360+
}
361+
}
362+
];
348363
}
349364

350365
return userInput;

projects/app/src/components/core/ai/AISettingModal/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ const AIChatSettingsModal = ({
8282
{t('common:core.ai.AI settings')}
8383
{feConfigs?.docUrl && (
8484
<Link
85-
href={getDocPath('/docs/course/ai_settings/')}
85+
href={getDocPath('/docs/guide/course/ai_settings/')}
8686
target={'_blank'}
8787
ml={1}
8888
textDecoration={'underline'}

projects/app/src/components/core/app/InputGuideConfig.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ const InputGuideConfig = ({
146146
<Flex mt={8} alignItems={'center'}>
147147
<FormLabel>{chatT('custom_input_guide_url')}</FormLabel>
148148
<Flex
149-
onClick={() => window.open(getDocPath('/docs/course/chat_input_guide'))}
149+
onClick={() => window.open(getDocPath('/docs/guide/course/chat_input_guide/'))}
150150
color={'primary.700'}
151151
alignItems={'center'}
152152
cursor={'pointer'}

projects/app/src/components/support/laf/LafAccountModal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ const LafAccountModal = ({
101101
<Box fontSize={'sm'} color={'myGray.500'}>
102102
<Box>{t('common:support.user.Laf account intro')}</Box>
103103
<Box textDecoration={'underline'}>
104-
<Link href={getDocPath('/docs/workflow/modules/laf/')} isExternal>
104+
<Link href={getDocPath('/docs/guide/workbench/workflow/laf/')} isExternal>
105105
{t('common:support.user.Laf account course')}
106106
</Link>
107107
</Box>

projects/app/src/pages/app/detail/components/Publish/FeiShu/FeiShuEditModal.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,10 @@ const FeiShuEditModal = ({
9090
<Box color="myGray.600">{t('publish:feishu_api')}</Box>
9191
{feConfigs?.docUrl && (
9292
<Link
93-
href={feConfigs.openAPIDocUrl || getDocPath('/docs/course/feishu')}
93+
href={
94+
feConfigs.openAPIDocUrl ||
95+
getDocPath('/docs/use-cases/external-integration/feishu/')
96+
}
9497
target={'_blank'}
9598
ml={2}
9699
color={'primary.500'}

projects/app/src/pages/app/detail/components/Publish/FeiShu/index.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,10 @@ const FeiShu = ({ appId }: { appId: string }) => {
7373
</Box>
7474
{feConfigs?.docUrl && (
7575
<Link
76-
href={feConfigs.openAPIDocUrl || getDocPath('/docs/course/feishu')}
76+
href={
77+
feConfigs.openAPIDocUrl ||
78+
getDocPath('/docs/use-cases/external-integration/feishu/')
79+
}
7780
target={'_blank'}
7881
color={'primary.500'}
7982
fontSize={'sm'}

projects/app/src/pages/app/detail/components/Publish/OffiAccount/OffiAccountEditModal.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,10 @@ const OffiAccountEditModal = ({
9696
<Box color="myGray.600">{t('publish:official_account.params')}</Box>
9797
{feConfigs?.docUrl && (
9898
<Link
99-
href={feConfigs.openAPIDocUrl || getDocPath('/docs/course/official_account')}
99+
href={
100+
feConfigs.openAPIDocUrl ||
101+
getDocPath('/docs/use-cases/external-integration/official_account/')
102+
}
100103
target={'_blank'}
101104
ml={2}
102105
color={'primary.500'}

projects/app/src/pages/app/detail/components/Publish/OffiAccount/index.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,10 @@ const OffiAccount = ({ appId }: { appId: string }) => {
7575

7676
{feConfigs?.docUrl && (
7777
<Link
78-
href={feConfigs.openAPIDocUrl || getDocPath('/docs/course/official_account')}
78+
href={
79+
feConfigs.openAPIDocUrl ||
80+
getDocPath('/docs/use-cases/external-integration/official_account/')
81+
}
7982
target={'_blank'}
8083
ml={2}
8184
color={'primary.500'}

projects/app/src/pages/dataset/detail/components/CollectionCard/WebsiteConfig.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ const WebsiteConfigModal = ({
5454
{t('common:core.dataset.website.Config Description')}
5555
{feConfigs?.docUrl && (
5656
<Link
57-
href={getDocPath('/docs/course/websync')}
57+
href={getDocPath('/docs/guide/knowledge_base/websync/')}
5858
target="_blank"
5959
textDecoration={'underline'}
6060
fontWeight={'bold'}

projects/app/src/pages/dataset/detail/components/Import/diffSource/FileLink.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,10 @@ const CustomLinkImport = () => {
8080
{t('common:core.dataset.website.Selector')}
8181
<Box color={'myGray.500'} fontSize={'sm'}>
8282
{feConfigs?.docUrl && (
83-
<Link href={getDocPath('/docs/course/websync/#选择器如何使用')} target="_blank">
83+
<Link
84+
href={getDocPath('/docs/guide/knowledge_base/websync/#选择器如何使用')}
85+
target="_blank"
86+
>
8487
{t('common:core.dataset.website.Selector Course')}
8588
</Link>
8689
)}

projects/app/src/pages/dataset/detail/components/InputDataModal.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,9 @@ const InputDataModal = ({
9999
mr={'0.38rem'}
100100
color={'myGray.500'}
101101
ml={1}
102-
onClick={() => window.open(getDocPath('/docs/course/dataset_engine'), '_blank')}
102+
onClick={() =>
103+
window.open(getDocPath('/docs/guide/knowledge_base/dataset_engine/'), '_blank')
104+
}
103105
_hover={{
104106
color: 'primary.600',
105107
cursor: 'pointer'

0 commit comments

Comments
 (0)