fix: null pointer (#3130)
* fix: null pointer * perf: not input text * update doc url
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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: [
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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: [
|
||||
{
|
||||
|
||||
@@ -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: [
|
||||
{
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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: [
|
||||
{
|
||||
|
||||
@@ -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: [
|
||||
{
|
||||
|
||||
@@ -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: [
|
||||
{
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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: [
|
||||
{
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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: [
|
||||
{
|
||||
|
||||
@@ -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: [
|
||||
{
|
||||
|
||||
@@ -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: [
|
||||
{
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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: [
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user