fix: null pointer (#3130)

* fix: null pointer

* perf: not input text

* update doc url
This commit is contained in:
Archer
2024-11-12 18:13:21 +08:00
committed by archer
parent dc8aeefa2a
commit 211061d122
29 changed files with 80 additions and 44 deletions

View File

@@ -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,

View File

@@ -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: [

View File

@@ -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,

View File

@@ -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: [
{

View File

@@ -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: [
{

View File

@@ -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,

View File

@@ -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: [
{

View File

@@ -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: [
{

View File

@@ -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: [
{

View File

@@ -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,

View File

@@ -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: [
{

View File

@@ -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,

View File

@@ -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,

View File

@@ -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: [
{

View File

@@ -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: [
{

View File

@@ -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: [
{

View File

@@ -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,

View File

@@ -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: [

View File

@@ -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,16 +326,18 @@ 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;
if (userInput.some((item) => item.type === 'text')) {
return userInput.map((item) => {
if (item.type === 'text') {
const text = item.text?.content || '';
return {
@@ -342,10 +347,20 @@ const toolCallMessagesAdapt = ({
}
};
}
return item;
});
}
// Every input is a file
return [
{
type: ChatItemValueTypeEnum.text,
text: {
content: getMultiplePrompt({ fileCount: filesCount, imgCount, question: '' })
}
}
];
}
return userInput;
};

View File

@@ -82,7 +82,7 @@ const AIChatSettingsModal = ({
{t('common:core.ai.AI settings')}
{feConfigs?.docUrl && (
<Link
href={getDocPath('/docs/course/ai_settings/')}
href={getDocPath('/docs/guide/course/ai_settings/')}
target={'_blank'}
ml={1}
textDecoration={'underline'}

View File

@@ -146,7 +146,7 @@ const InputGuideConfig = ({
<Flex mt={8} alignItems={'center'}>
<FormLabel>{chatT('custom_input_guide_url')}</FormLabel>
<Flex
onClick={() => 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'}

View File

@@ -101,7 +101,7 @@ const LafAccountModal = ({
<Box fontSize={'sm'} color={'myGray.500'}>
<Box>{t('common:support.user.Laf account intro')}</Box>
<Box textDecoration={'underline'}>
<Link href={getDocPath('/docs/workflow/modules/laf/')} isExternal>
<Link href={getDocPath('/docs/guide/workbench/workflow/laf/')} isExternal>
{t('common:support.user.Laf account course')}
</Link>
</Box>

View File

@@ -90,7 +90,10 @@ const FeiShuEditModal = ({
<Box color="myGray.600">{t('publish:feishu_api')}</Box>
{feConfigs?.docUrl && (
<Link
href={feConfigs.openAPIDocUrl || getDocPath('/docs/course/feishu')}
href={
feConfigs.openAPIDocUrl ||
getDocPath('/docs/use-cases/external-integration/feishu/')
}
target={'_blank'}
ml={2}
color={'primary.500'}

View File

@@ -73,7 +73,10 @@ const FeiShu = ({ appId }: { appId: string }) => {
</Box>
{feConfigs?.docUrl && (
<Link
href={feConfigs.openAPIDocUrl || getDocPath('/docs/course/feishu')}
href={
feConfigs.openAPIDocUrl ||
getDocPath('/docs/use-cases/external-integration/feishu/')
}
target={'_blank'}
color={'primary.500'}
fontSize={'sm'}

View File

@@ -96,7 +96,10 @@ const OffiAccountEditModal = ({
<Box color="myGray.600">{t('publish:official_account.params')}</Box>
{feConfigs?.docUrl && (
<Link
href={feConfigs.openAPIDocUrl || getDocPath('/docs/course/official_account')}
href={
feConfigs.openAPIDocUrl ||
getDocPath('/docs/use-cases/external-integration/official_account/')
}
target={'_blank'}
ml={2}
color={'primary.500'}

View File

@@ -75,7 +75,10 @@ const OffiAccount = ({ appId }: { appId: string }) => {
{feConfigs?.docUrl && (
<Link
href={feConfigs.openAPIDocUrl || getDocPath('/docs/course/official_account')}
href={
feConfigs.openAPIDocUrl ||
getDocPath('/docs/use-cases/external-integration/official_account/')
}
target={'_blank'}
ml={2}
color={'primary.500'}

View File

@@ -54,7 +54,7 @@ const WebsiteConfigModal = ({
{t('common:core.dataset.website.Config Description')}
{feConfigs?.docUrl && (
<Link
href={getDocPath('/docs/course/websync')}
href={getDocPath('/docs/guide/knowledge_base/websync/')}
target="_blank"
textDecoration={'underline'}
fontWeight={'bold'}

View File

@@ -80,7 +80,10 @@ const CustomLinkImport = () => {
{t('common:core.dataset.website.Selector')}
<Box color={'myGray.500'} fontSize={'sm'}>
{feConfigs?.docUrl && (
<Link href={getDocPath('/docs/course/websync/#选择器如何使用')} target="_blank">
<Link
href={getDocPath('/docs/guide/knowledge_base/websync/#选择器如何使用')}
target="_blank"
>
{t('common:core.dataset.website.Selector Course')}
</Link>
)}

View File

@@ -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'