mirror of
http://112.124.100.131/huang.ze/ebiz-dify-ai.git
synced 2025-12-09 19:06:51 +08:00
FEAT: NEW WORKFLOW ENGINE (#3160)
Co-authored-by: Joel <iamjoel007@gmail.com> Co-authored-by: Yeuoly <admin@srmxy.cn> Co-authored-by: JzoNg <jzongcode@gmail.com> Co-authored-by: StyleZhang <jasonapring2015@outlook.com> Co-authored-by: jyong <jyong@dify.ai> Co-authored-by: nite-knite <nkCoding@gmail.com> Co-authored-by: jyong <718720800@qq.com>
This commit is contained in:
15
web/utils/app-redirection.ts
Normal file
15
web/utils/app-redirection.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
export const getRedirection = (
|
||||
isCurrentWorkspaceManager: boolean,
|
||||
app: any,
|
||||
redirectionFunc: (href: string) => void,
|
||||
) => {
|
||||
if (!isCurrentWorkspaceManager) {
|
||||
redirectionFunc(`/app/${app.id}/overview`)
|
||||
}
|
||||
else {
|
||||
if (app.mode === 'workflow' || app.mode === 'advanced-chat')
|
||||
redirectionFunc(`/app/${app.id}/workflow`)
|
||||
else
|
||||
redirectionFunc(`/app/${app.id}/configuration`)
|
||||
}
|
||||
}
|
||||
@@ -18,9 +18,9 @@ export const userInputsFormToPromptVariables = (useInputs: UserInputFormItem[] |
|
||||
if (item.external_data_tool)
|
||||
return [item.external_data_tool.type, item.external_data_tool]
|
||||
|
||||
return ['select', item.select]
|
||||
return ['select', item.select || {}]
|
||||
})()
|
||||
const is_context_var = dataset_query_variable === content.variable
|
||||
const is_context_var = dataset_query_variable === content?.variable
|
||||
|
||||
if (type === 'string' || type === 'paragraph') {
|
||||
promptVariables.push({
|
||||
@@ -33,6 +33,15 @@ export const userInputsFormToPromptVariables = (useInputs: UserInputFormItem[] |
|
||||
is_context_var,
|
||||
})
|
||||
}
|
||||
else if (type === 'number') {
|
||||
promptVariables.push({
|
||||
key: content.variable,
|
||||
name: content.label,
|
||||
required: content.required,
|
||||
type,
|
||||
options: [],
|
||||
})
|
||||
}
|
||||
else if (type === 'select') {
|
||||
promptVariables.push({
|
||||
key: content.variable,
|
||||
@@ -78,6 +87,17 @@ export const promptVariablesToUserInputsForm = (promptVariables: PromptVariable[
|
||||
default: '',
|
||||
},
|
||||
} as any)
|
||||
return
|
||||
}
|
||||
if (item.type === 'number') {
|
||||
userInputs.push({
|
||||
number: {
|
||||
label: item.name,
|
||||
variable: item.key,
|
||||
required: item.required !== false, // default true
|
||||
default: '',
|
||||
},
|
||||
} as any)
|
||||
}
|
||||
else if (item.type === 'select') {
|
||||
userInputs.push({
|
||||
@@ -105,5 +125,6 @@ export const promptVariablesToUserInputsForm = (promptVariables: PromptVariable[
|
||||
} as any)
|
||||
}
|
||||
})
|
||||
|
||||
return userInputs
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { MAX_VAR_KEY_LENGHT, VAR_ITEM_TEMPLATE, getMaxVarNameLength } from '@/config'
|
||||
import { MAX_VAR_KEY_LENGHT, VAR_ITEM_TEMPLATE, VAR_ITEM_TEMPLATE_IN_WORKFLOW, getMaxVarNameLength } from '@/config'
|
||||
import { CONTEXT_PLACEHOLDER_TEXT, HISTORY_PLACEHOLDER_TEXT, PRE_PROMPT_PLACEHOLDER_TEXT, QUERY_PLACEHOLDER_TEXT } from '@/app/components/base/prompt-editor/constants'
|
||||
import { InputVarType } from '@/app/components/workflow/types'
|
||||
|
||||
const otherAllowedRegex = /^[a-zA-Z0-9_]+$/
|
||||
|
||||
@@ -21,7 +22,25 @@ export const getNewVar = (key: string, type: string) => {
|
||||
}
|
||||
}
|
||||
|
||||
const checkKey = (key: string, canBeEmpty?: boolean) => {
|
||||
export const getNewVarInWorkflow = (key: string, type = InputVarType.textInput) => {
|
||||
const { max_length, ...rest } = VAR_ITEM_TEMPLATE_IN_WORKFLOW
|
||||
if (type !== InputVarType.textInput) {
|
||||
return {
|
||||
...rest,
|
||||
type,
|
||||
variable: key,
|
||||
label: key.slice(0, getMaxVarNameLength(key)),
|
||||
}
|
||||
}
|
||||
return {
|
||||
...VAR_ITEM_TEMPLATE_IN_WORKFLOW,
|
||||
type,
|
||||
variable: key,
|
||||
label: key.slice(0, getMaxVarNameLength(key)),
|
||||
}
|
||||
}
|
||||
|
||||
export const checkKey = (key: string, canBeEmpty?: boolean) => {
|
||||
if (key.length === 0 && !canBeEmpty)
|
||||
return 'canNoBeEmpty'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user