mirror of
https://github.com/langgenius/dify.git
synced 2026-04-30 21:58:00 +08:00
add check valid for human input
This commit is contained in:
parent
ef41325ad1
commit
d21cf87bb6
@ -1,5 +1,6 @@
|
|||||||
import type { NodeDefault, Var } from '../../types'
|
import type { NodeDefault, Var } from '../../types'
|
||||||
import type { HumanInputNodeType } from './types'
|
import type { HumanInputNodeType } from './types'
|
||||||
|
import { splitByOutputVar } from '@/app/components/base/chat/chat/answer/human-input-content/utils'
|
||||||
import { BlockClassificationEnum } from '@/app/components/workflow/block-selector/types'
|
import { BlockClassificationEnum } from '@/app/components/workflow/block-selector/types'
|
||||||
import { BlockEnum, VarType } from '@/app/components/workflow/types'
|
import { BlockEnum, VarType } from '@/app/components/workflow/types'
|
||||||
import { genNodeMetaData } from '@/app/components/workflow/utils'
|
import { genNodeMetaData } from '@/app/components/workflow/utils'
|
||||||
@ -21,6 +22,12 @@ const buildOutputVars = (variables: string[]): Var[] => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const checkInputFields = (formContent: string): boolean => {
|
||||||
|
const outputVarRegex = /\{\{#\$output\.[^#]+#\}\}/
|
||||||
|
const contentList = splitByOutputVar(formContent)
|
||||||
|
return contentList.filter(content => outputVarRegex.test(content)).length > 0
|
||||||
|
}
|
||||||
|
|
||||||
const nodeDefault: NodeDefault<HumanInputNodeType> = {
|
const nodeDefault: NodeDefault<HumanInputNodeType> = {
|
||||||
metaData,
|
metaData,
|
||||||
defaultValue: {
|
defaultValue: {
|
||||||
@ -39,6 +46,12 @@ const nodeDefault: NodeDefault<HumanInputNodeType> = {
|
|||||||
if (!errorMessages && payload.delivery_methods.length > 0 && !payload.delivery_methods.some(method => method.enabled))
|
if (!errorMessages && payload.delivery_methods.length > 0 && !payload.delivery_methods.some(method => method.enabled))
|
||||||
errorMessages = t(`${i18nPrefix}.noDeliveryMethodEnabled`, { ns: 'workflow' })
|
errorMessages = t(`${i18nPrefix}.noDeliveryMethodEnabled`, { ns: 'workflow' })
|
||||||
|
|
||||||
|
if (!errorMessages && !payload.form_content.trim())
|
||||||
|
errorMessages = t(`${i18nPrefix}.noFormContent`, { ns: 'workflow' })
|
||||||
|
|
||||||
|
if (!errorMessages && !checkInputFields(payload.form_content))
|
||||||
|
errorMessages = t(`${i18nPrefix}.noFormContentInputField`, { ns: 'workflow' })
|
||||||
|
|
||||||
if (!errorMessages && !payload.user_actions.length)
|
if (!errorMessages && !payload.user_actions.length)
|
||||||
errorMessages = t(`${i18nPrefix}.noUserActions`, { ns: 'workflow' })
|
errorMessages = t(`${i18nPrefix}.noUserActions`, { ns: 'workflow' })
|
||||||
|
|
||||||
|
|||||||
@ -558,6 +558,8 @@
|
|||||||
"nodes.humanInput.editor.previewTip": "In preview mode, action buttons are not functional.",
|
"nodes.humanInput.editor.previewTip": "In preview mode, action buttons are not functional.",
|
||||||
"nodes.humanInput.errorMsg.noDeliveryMethod": "Please select at least one delivery method",
|
"nodes.humanInput.errorMsg.noDeliveryMethod": "Please select at least one delivery method",
|
||||||
"nodes.humanInput.errorMsg.noDeliveryMethodEnabled": "Please enable at least one delivery method",
|
"nodes.humanInput.errorMsg.noDeliveryMethodEnabled": "Please enable at least one delivery method",
|
||||||
|
"nodes.humanInput.errorMsg.noFormContent": "Please add form content",
|
||||||
|
"nodes.humanInput.errorMsg.noFormContentInputField": "Please add at least one input field in form content",
|
||||||
"nodes.humanInput.errorMsg.noUserActions": "Please add at least one user action",
|
"nodes.humanInput.errorMsg.noUserActions": "Please add at least one user action",
|
||||||
"nodes.humanInput.formContent.hotkeyTip": "Press <Key/> to insert variable, <CtrlKey/><Key/> to insert input field",
|
"nodes.humanInput.formContent.hotkeyTip": "Press <Key/> to insert variable, <CtrlKey/><Key/> to insert input field",
|
||||||
"nodes.humanInput.formContent.preview": "Preview",
|
"nodes.humanInput.formContent.preview": "Preview",
|
||||||
|
|||||||
@ -558,6 +558,8 @@
|
|||||||
"nodes.humanInput.editor.previewTip": "在预览模式下,操作按钮无法使用。",
|
"nodes.humanInput.editor.previewTip": "在预览模式下,操作按钮无法使用。",
|
||||||
"nodes.humanInput.errorMsg.noDeliveryMethod": "请至少选择一种提交方式",
|
"nodes.humanInput.errorMsg.noDeliveryMethod": "请至少选择一种提交方式",
|
||||||
"nodes.humanInput.errorMsg.noDeliveryMethodEnabled": "请至少启用一种提交方式",
|
"nodes.humanInput.errorMsg.noDeliveryMethodEnabled": "请至少启用一种提交方式",
|
||||||
|
"nodes.humanInput.errorMsg.noFormContent": "请添加表单内容",
|
||||||
|
"nodes.humanInput.errorMsg.noFormContentInputField": "请在表单内容中添加至少一个输入字段",
|
||||||
"nodes.humanInput.errorMsg.noUserActions": "请添加至少一个用户操作",
|
"nodes.humanInput.errorMsg.noUserActions": "请添加至少一个用户操作",
|
||||||
"nodes.humanInput.formContent.hotkeyTip": "按 <Key/> 插入变量,按 <CtrlKey/><Key/> 插入输入字段",
|
"nodes.humanInput.formContent.hotkeyTip": "按 <Key/> 插入变量,按 <CtrlKey/><Key/> 插入输入字段",
|
||||||
"nodes.humanInput.formContent.preview": "预览",
|
"nodes.humanInput.formContent.preview": "预览",
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user