mirror of
https://github.com/langgenius/dify.git
synced 2025-11-08 15:31:02 +00:00
fix: node default
This commit is contained in:
parent
2613a380b6
commit
66176c4d71
@ -0,0 +1,58 @@
|
|||||||
|
import { useState } from 'react'
|
||||||
|
import { RiEditLine } from '@remixicon/react'
|
||||||
|
import cn from '@/utils/classnames'
|
||||||
|
import SegmentedControl from '@/app/components/base/segmented-control'
|
||||||
|
import { VariableX } from '@/app/components/base/icons/src/vender/workflow'
|
||||||
|
import type { LabelProps } from '../label'
|
||||||
|
import Label from '../label'
|
||||||
|
|
||||||
|
type VariableOrConstantInputFieldProps = {
|
||||||
|
label: string
|
||||||
|
labelOptions?: Omit<LabelProps, 'htmlFor' | 'label'>
|
||||||
|
className?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
const VariableOrConstantInputField = ({
|
||||||
|
className,
|
||||||
|
label,
|
||||||
|
labelOptions,
|
||||||
|
}: VariableOrConstantInputFieldProps) => {
|
||||||
|
const [variableType, setVariableType] = useState('variable')
|
||||||
|
|
||||||
|
const options = [
|
||||||
|
{
|
||||||
|
Icon: VariableX,
|
||||||
|
text: '',
|
||||||
|
value: 'variable',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Icon: RiEditLine,
|
||||||
|
text: '',
|
||||||
|
value: 'constant',
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
const handleVariableOrConstantChange = (value: string) => {
|
||||||
|
setVariableType(value)
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className={cn('flex flex-col gap-y-0.5', className)}>
|
||||||
|
<Label
|
||||||
|
htmlFor={'variable-or-constant'}
|
||||||
|
label={label}
|
||||||
|
{...(labelOptions ?? {})}
|
||||||
|
/>
|
||||||
|
<div className='flex items-center'>
|
||||||
|
<SegmentedControl
|
||||||
|
className='mr-1 shrink-0'
|
||||||
|
value={variableType}
|
||||||
|
onChange={handleVariableOrConstantChange}
|
||||||
|
options={options as any}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default VariableOrConstantInputField
|
||||||
239
web/app/components/base/form/form-scenarios/node-panel/field.tsx
Normal file
239
web/app/components/base/form/form-scenarios/node-panel/field.tsx
Normal file
@ -0,0 +1,239 @@
|
|||||||
|
import React from 'react'
|
||||||
|
import { type InputFieldConfiguration, InputFieldType } from './types'
|
||||||
|
import { withForm } from '../..'
|
||||||
|
import { useStore } from '@tanstack/react-form'
|
||||||
|
|
||||||
|
type InputFieldProps<T> = {
|
||||||
|
initialData?: T
|
||||||
|
config: InputFieldConfiguration<T>
|
||||||
|
}
|
||||||
|
|
||||||
|
const NodePanelField = <T,>({
|
||||||
|
initialData,
|
||||||
|
config,
|
||||||
|
}: InputFieldProps<T>) => withForm({
|
||||||
|
defaultValues: initialData,
|
||||||
|
render: function Render({
|
||||||
|
form,
|
||||||
|
}) {
|
||||||
|
const {
|
||||||
|
type,
|
||||||
|
label,
|
||||||
|
placeholder,
|
||||||
|
variable,
|
||||||
|
tooltip,
|
||||||
|
showConditions,
|
||||||
|
max,
|
||||||
|
min,
|
||||||
|
required,
|
||||||
|
showOptional,
|
||||||
|
supportFile,
|
||||||
|
description,
|
||||||
|
options,
|
||||||
|
listeners,
|
||||||
|
popupProps,
|
||||||
|
} = config
|
||||||
|
|
||||||
|
const isAllConditionsMet = useStore(form.store, (state) => {
|
||||||
|
const fieldValues = state.values
|
||||||
|
return showConditions.every((condition) => {
|
||||||
|
const { variable, value } = condition
|
||||||
|
const fieldValue = fieldValues[variable as keyof typeof fieldValues]
|
||||||
|
return fieldValue === value
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
if (!isAllConditionsMet)
|
||||||
|
return <></>
|
||||||
|
|
||||||
|
if (type === InputFieldType.textInput) {
|
||||||
|
return (
|
||||||
|
<form.AppField
|
||||||
|
name={variable}
|
||||||
|
children={field => (
|
||||||
|
<field.TextField
|
||||||
|
label={label}
|
||||||
|
labelOptions={{
|
||||||
|
tooltip,
|
||||||
|
isRequired: required,
|
||||||
|
showOptional,
|
||||||
|
}}
|
||||||
|
placeholder={placeholder}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (type === InputFieldType.numberInput) {
|
||||||
|
return (
|
||||||
|
<form.AppField
|
||||||
|
name={variable}
|
||||||
|
children={field => (
|
||||||
|
<field.NumberInputField
|
||||||
|
label={label}
|
||||||
|
labelOptions={{
|
||||||
|
tooltip,
|
||||||
|
isRequired: required,
|
||||||
|
showOptional,
|
||||||
|
}}
|
||||||
|
placeholder={placeholder}
|
||||||
|
max={max}
|
||||||
|
min={min}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (type === InputFieldType.numberSlider) {
|
||||||
|
return (
|
||||||
|
<form.AppField
|
||||||
|
name={variable}
|
||||||
|
children={field => (
|
||||||
|
<field.NumberSliderField
|
||||||
|
label={label}
|
||||||
|
labelOptions={{
|
||||||
|
tooltip,
|
||||||
|
isRequired: required,
|
||||||
|
showOptional,
|
||||||
|
}}
|
||||||
|
description={description}
|
||||||
|
max={max}
|
||||||
|
min={min}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (type === InputFieldType.checkbox) {
|
||||||
|
return (
|
||||||
|
<form.AppField
|
||||||
|
name={variable}
|
||||||
|
children={field => (
|
||||||
|
<field.CheckboxField
|
||||||
|
label={label}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (type === InputFieldType.select) {
|
||||||
|
return (
|
||||||
|
<form.AppField
|
||||||
|
name={variable}
|
||||||
|
children={field => (
|
||||||
|
<field.SelectField
|
||||||
|
label={label}
|
||||||
|
labelOptions={{
|
||||||
|
tooltip,
|
||||||
|
isRequired: required,
|
||||||
|
showOptional,
|
||||||
|
}}
|
||||||
|
options={options!}
|
||||||
|
popupProps={popupProps}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (type === InputFieldType.inputTypeSelect) {
|
||||||
|
return (
|
||||||
|
<form.AppField
|
||||||
|
name={variable}
|
||||||
|
listeners={listeners}
|
||||||
|
children={field => (
|
||||||
|
<field.InputTypeSelectField
|
||||||
|
label={label}
|
||||||
|
labelOptions={{
|
||||||
|
tooltip,
|
||||||
|
isRequired: required,
|
||||||
|
showOptional,
|
||||||
|
}}
|
||||||
|
supportFile={!!supportFile}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (type === InputFieldType.uploadMethod) {
|
||||||
|
return (
|
||||||
|
<form.AppField
|
||||||
|
name={variable}
|
||||||
|
children={field => (
|
||||||
|
<field.UploadMethodField
|
||||||
|
label={label}
|
||||||
|
labelOptions={{
|
||||||
|
tooltip,
|
||||||
|
isRequired: required,
|
||||||
|
showOptional,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (type === InputFieldType.fileTypes) {
|
||||||
|
return (
|
||||||
|
<form.AppField
|
||||||
|
name={variable}
|
||||||
|
children={field => (
|
||||||
|
<field.FileTypesField
|
||||||
|
label={label}
|
||||||
|
labelOptions={{
|
||||||
|
tooltip,
|
||||||
|
isRequired: required,
|
||||||
|
showOptional,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (type === InputFieldType.options) {
|
||||||
|
return (
|
||||||
|
<form.AppField
|
||||||
|
name={variable}
|
||||||
|
children={field => (
|
||||||
|
<field.OptionsField
|
||||||
|
label={label}
|
||||||
|
labelOptions={{
|
||||||
|
tooltip,
|
||||||
|
isRequired: required,
|
||||||
|
showOptional,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (type === InputFieldType.variableOrConstant) {
|
||||||
|
return (
|
||||||
|
<form.AppField
|
||||||
|
name={variable}
|
||||||
|
children={field => (
|
||||||
|
<field.VariableOrConstantInputField
|
||||||
|
label={label}
|
||||||
|
labelOptions={{
|
||||||
|
tooltip,
|
||||||
|
isRequired: required,
|
||||||
|
showOptional,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
return <></>
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
export default NodePanelField
|
||||||
@ -0,0 +1,40 @@
|
|||||||
|
import type { DeepKeys, FieldListeners } from '@tanstack/react-form'
|
||||||
|
import type { NumberConfiguration, SelectConfiguration, ShowCondition } from '../base/types'
|
||||||
|
|
||||||
|
export enum InputFieldType {
|
||||||
|
textInput = 'textInput',
|
||||||
|
numberInput = 'numberInput',
|
||||||
|
numberSlider = 'numberSlider',
|
||||||
|
checkbox = 'checkbox',
|
||||||
|
options = 'options',
|
||||||
|
select = 'select',
|
||||||
|
inputTypeSelect = 'inputTypeSelect',
|
||||||
|
uploadMethod = 'uploadMethod',
|
||||||
|
fileTypes = 'fileTypes',
|
||||||
|
variableOrConstant = 'variableOrConstant',
|
||||||
|
}
|
||||||
|
|
||||||
|
export type InputTypeSelectConfiguration = {
|
||||||
|
supportFile: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
export type NumberSliderConfiguration = {
|
||||||
|
description: string
|
||||||
|
max?: number
|
||||||
|
min?: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export type InputFieldConfiguration<T> = {
|
||||||
|
label: string
|
||||||
|
variable: DeepKeys<T> // Variable name
|
||||||
|
maxLength?: number // Max length for text input
|
||||||
|
placeholder?: string
|
||||||
|
required: boolean
|
||||||
|
showOptional?: boolean // show optional label
|
||||||
|
showConditions: ShowCondition<T>[] // Show this field only when all conditions are met
|
||||||
|
type: InputFieldType
|
||||||
|
tooltip?: string // Tooltip for this field
|
||||||
|
listeners?: FieldListeners<T, DeepKeys<T>> // Listener for this field
|
||||||
|
} & NumberConfiguration & Partial<InputTypeSelectConfiguration>
|
||||||
|
& Partial<NumberSliderConfiguration>
|
||||||
|
& Partial<SelectConfiguration>
|
||||||
@ -2,6 +2,7 @@ import { useMemo } from 'react'
|
|||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import { useGetLanguage } from '@/context/i18n'
|
import { useGetLanguage } from '@/context/i18n'
|
||||||
import knowledgeBaseDefault from '@/app/components/workflow/nodes/knowledge-base/default'
|
import knowledgeBaseDefault from '@/app/components/workflow/nodes/knowledge-base/default'
|
||||||
|
import dataSourceDefault from '@/app/components/workflow/nodes/data-source/default'
|
||||||
import { WORKFLOW_COMMON_NODES } from '@/app/components/workflow/constants/node'
|
import { WORKFLOW_COMMON_NODES } from '@/app/components/workflow/constants/node'
|
||||||
import type { AvailableNodesMetaData } from '@/app/components/workflow/hooks-store/store'
|
import type { AvailableNodesMetaData } from '@/app/components/workflow/hooks-store/store'
|
||||||
|
|
||||||
@ -12,6 +13,7 @@ export const useAvailableNodesMetaData = () => {
|
|||||||
const mergedNodesMetaData = useMemo(() => [
|
const mergedNodesMetaData = useMemo(() => [
|
||||||
...WORKFLOW_COMMON_NODES,
|
...WORKFLOW_COMMON_NODES,
|
||||||
knowledgeBaseDefault,
|
knowledgeBaseDefault,
|
||||||
|
dataSourceDefault,
|
||||||
], [])
|
], [])
|
||||||
|
|
||||||
const prefixLink = useMemo(() => {
|
const prefixLink = useMemo(() => {
|
||||||
@ -22,21 +24,27 @@ export const useAvailableNodesMetaData = () => {
|
|||||||
}, [language])
|
}, [language])
|
||||||
|
|
||||||
const availableNodesMetaData = useMemo(() => mergedNodesMetaData.map((node) => {
|
const availableNodesMetaData = useMemo(() => mergedNodesMetaData.map((node) => {
|
||||||
|
const { metaData } = node
|
||||||
|
const title = t(`workflow.blocks.${metaData.type}`)
|
||||||
|
const description = t(`workflow.blocksAbout.${metaData.type}`)
|
||||||
return {
|
return {
|
||||||
...node,
|
...node,
|
||||||
|
metaData: {
|
||||||
|
...metaData,
|
||||||
|
title,
|
||||||
|
description,
|
||||||
|
helpLinkUri: `${prefixLink}${metaData.helpLinkUri}`,
|
||||||
|
},
|
||||||
defaultValue: {
|
defaultValue: {
|
||||||
...node.defaultValue,
|
...node.defaultValue,
|
||||||
type: node.type,
|
type: metaData.type,
|
||||||
|
title,
|
||||||
},
|
},
|
||||||
title: t(`workflow.blocks.${node.type}`),
|
|
||||||
description: t(`workflow.blocksAbout.${node.type}`),
|
|
||||||
helpLinkUri: `${prefixLink}${node.helpLinkUri}`,
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}), [mergedNodesMetaData, t, prefixLink])
|
}), [mergedNodesMetaData, t, prefixLink])
|
||||||
|
|
||||||
const availableNodesMetaDataMap = useMemo(() => availableNodesMetaData.reduce((acc, node) => {
|
const availableNodesMetaDataMap = useMemo(() => availableNodesMetaData.reduce((acc, node) => {
|
||||||
acc![node.type] = node
|
acc![node.metaData.type] = node
|
||||||
return acc
|
return acc
|
||||||
}, {} as AvailableNodesMetaData['nodesMap']), [availableNodesMetaData])
|
}, {} as AvailableNodesMetaData['nodesMap']), [availableNodesMetaData])
|
||||||
|
|
||||||
|
|||||||
@ -3,21 +3,38 @@ import {
|
|||||||
WorkflowContextProvider,
|
WorkflowContextProvider,
|
||||||
} from '@/app/components/workflow/context'
|
} from '@/app/components/workflow/context'
|
||||||
import type { InjectWorkflowStoreSliceFn } from '@/app/components/workflow/store'
|
import type { InjectWorkflowStoreSliceFn } from '@/app/components/workflow/store'
|
||||||
|
import { generateNewNode } from '@/app/components/workflow/utils'
|
||||||
|
import dataSourceNodeDefault from '@/app/components/workflow/nodes/data-source/default'
|
||||||
|
import {
|
||||||
|
NODE_WIDTH_X_OFFSET,
|
||||||
|
START_INITIAL_POSITION,
|
||||||
|
} from '@/app/components/workflow/constants'
|
||||||
import { createRagPipelineSliceSlice } from './store'
|
import { createRagPipelineSliceSlice } from './store'
|
||||||
import RagPipelineMain from './components/rag-pipeline-main'
|
import RagPipelineMain from './components/rag-pipeline-main'
|
||||||
|
|
||||||
const RagPipeline = () => {
|
const RagPipeline = () => {
|
||||||
|
const { newNode: DataSourceNode } = generateNewNode({
|
||||||
|
data: {
|
||||||
|
type: dataSourceNodeDefault.metaData.type,
|
||||||
|
title: 'data-source',
|
||||||
|
...dataSourceNodeDefault.defaultValue,
|
||||||
|
},
|
||||||
|
position: {
|
||||||
|
x: START_INITIAL_POSITION.x + NODE_WIDTH_X_OFFSET,
|
||||||
|
y: START_INITIAL_POSITION.y,
|
||||||
|
},
|
||||||
|
} as any)
|
||||||
return (
|
return (
|
||||||
<WorkflowContextProvider
|
<WorkflowContextProvider
|
||||||
injectWorkflowStoreSliceFn={createRagPipelineSliceSlice as InjectWorkflowStoreSliceFn}
|
injectWorkflowStoreSliceFn={createRagPipelineSliceSlice as InjectWorkflowStoreSliceFn}
|
||||||
>
|
>
|
||||||
<WorkflowWithDefaultContext
|
<WorkflowWithDefaultContext
|
||||||
edges={[]}
|
edges={[]}
|
||||||
nodes={[]}
|
nodes={[DataSourceNode]}
|
||||||
>
|
>
|
||||||
<RagPipelineMain
|
<RagPipelineMain
|
||||||
edges={[]}
|
edges={[]}
|
||||||
nodes={[]}
|
nodes={[DataSourceNode]}
|
||||||
/>
|
/>
|
||||||
</WorkflowWithDefaultContext>
|
</WorkflowWithDefaultContext>
|
||||||
</WorkflowContextProvider>
|
</WorkflowContextProvider>
|
||||||
|
|||||||
@ -31,21 +31,27 @@ export const useAvailableNodesMetaData = () => {
|
|||||||
}, [language])
|
}, [language])
|
||||||
|
|
||||||
const availableNodesMetaData = useMemo(() => mergedNodesMetaData.map((node) => {
|
const availableNodesMetaData = useMemo(() => mergedNodesMetaData.map((node) => {
|
||||||
|
const { metaData } = node
|
||||||
|
const title = t(`workflow.blocks.${metaData.type}`)
|
||||||
|
const description = t(`workflow.blocksAbout.${metaData.type}`)
|
||||||
return {
|
return {
|
||||||
...node,
|
...node,
|
||||||
|
metaData: {
|
||||||
|
...metaData,
|
||||||
|
title,
|
||||||
|
description,
|
||||||
|
helpLinkUri: `${prefixLink}${metaData.helpLinkUri}`,
|
||||||
|
},
|
||||||
defaultValue: {
|
defaultValue: {
|
||||||
...node.defaultValue,
|
...node.defaultValue,
|
||||||
type: node.type,
|
type: metaData.type,
|
||||||
|
title,
|
||||||
},
|
},
|
||||||
title: t(`workflow.blocks.${node.type}`),
|
|
||||||
description: t(`workflow.blocksAbout.${node.type}`),
|
|
||||||
helpLinkUri: `${prefixLink}${node.helpLinkUri}`,
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}), [mergedNodesMetaData, t, prefixLink])
|
}), [mergedNodesMetaData, t, prefixLink])
|
||||||
|
|
||||||
const availableNodesMetaDataMap = useMemo(() => availableNodesMetaData.reduce((acc, node) => {
|
const availableNodesMetaDataMap = useMemo(() => availableNodesMetaData.reduce((acc, node) => {
|
||||||
acc![node.type] = node
|
acc![node.metaData.type] = node
|
||||||
return acc
|
return acc
|
||||||
}, {} as AvailableNodesMetaData['nodesMap']), [availableNodesMetaData])
|
}, {} as AvailableNodesMetaData['nodesMap']), [availableNodesMetaData])
|
||||||
|
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
import { useTranslation } from 'react-i18next'
|
||||||
import { generateNewNode } from '@/app/components/workflow/utils'
|
import { generateNewNode } from '@/app/components/workflow/utils'
|
||||||
import {
|
import {
|
||||||
NODE_WIDTH_X_OFFSET,
|
NODE_WIDTH_X_OFFSET,
|
||||||
@ -11,9 +12,14 @@ import answerDefault from '@/app/components/workflow/nodes/answer/default'
|
|||||||
|
|
||||||
export const useWorkflowTemplate = () => {
|
export const useWorkflowTemplate = () => {
|
||||||
const isChatMode = useIsChatMode()
|
const isChatMode = useIsChatMode()
|
||||||
|
const { t } = useTranslation()
|
||||||
|
|
||||||
const { newNode: startNode } = generateNewNode({
|
const { newNode: startNode } = generateNewNode({
|
||||||
data: startDefault.defaultValue as StartNodeType,
|
data: {
|
||||||
|
...startDefault.defaultValue as StartNodeType,
|
||||||
|
type: startDefault.metaData.type,
|
||||||
|
title: t(`workflow.blocks.${startDefault.metaData.type}`),
|
||||||
|
},
|
||||||
position: START_INITIAL_POSITION,
|
position: START_INITIAL_POSITION,
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -27,6 +33,8 @@ export const useWorkflowTemplate = () => {
|
|||||||
query_prompt_template: '{{#sys.query#}}',
|
query_prompt_template: '{{#sys.query#}}',
|
||||||
},
|
},
|
||||||
selected: true,
|
selected: true,
|
||||||
|
type: llmDefault.metaData.type,
|
||||||
|
title: t(`workflow.blocks.${llmDefault.metaData.type}`),
|
||||||
},
|
},
|
||||||
position: {
|
position: {
|
||||||
x: START_INITIAL_POSITION.x + NODE_WIDTH_X_OFFSET,
|
x: START_INITIAL_POSITION.x + NODE_WIDTH_X_OFFSET,
|
||||||
@ -39,6 +47,8 @@ export const useWorkflowTemplate = () => {
|
|||||||
data: {
|
data: {
|
||||||
...answerDefault.defaultValue,
|
...answerDefault.defaultValue,
|
||||||
answer: `{{#${llmNode.id}.text#}}`,
|
answer: `{{#${llmNode.id}.text#}}`,
|
||||||
|
type: answerDefault.metaData.type,
|
||||||
|
title: t(`workflow.blocks.${answerDefault.metaData.type}`),
|
||||||
},
|
},
|
||||||
position: {
|
position: {
|
||||||
x: START_INITIAL_POSITION.x + NODE_WIDTH_X_OFFSET * 2,
|
x: START_INITIAL_POSITION.x + NODE_WIDTH_X_OFFSET * 2,
|
||||||
|
|||||||
@ -19,7 +19,7 @@ export const useAvailableBlocks = (nodeType?: BlockEnum, inContainer?: boolean)
|
|||||||
const {
|
const {
|
||||||
nodes: availableNodes,
|
nodes: availableNodes,
|
||||||
} = useNodesMetaData()
|
} = useNodesMetaData()
|
||||||
const availableNodesType = useMemo(() => availableNodes.map(node => node.type), [availableNodes])
|
const availableNodesType = useMemo(() => availableNodes.map(node => node.metaData.type), [availableNodes])
|
||||||
const availablePrevBlocks = useMemo(() => {
|
const availablePrevBlocks = useMemo(() => {
|
||||||
if (!nodeType || nodeType === BlockEnum.Start)
|
if (!nodeType || nodeType === BlockEnum.Start)
|
||||||
return []
|
return []
|
||||||
|
|||||||
@ -685,7 +685,6 @@ export const useNodesInteractions = () => {
|
|||||||
const nodesWithSameType = nodes.filter(node => node.data.type === nodeType)
|
const nodesWithSameType = nodes.filter(node => node.data.type === nodeType)
|
||||||
const {
|
const {
|
||||||
defaultValue,
|
defaultValue,
|
||||||
title,
|
|
||||||
} = nodesMetaDataMap![nodeType]
|
} = nodesMetaDataMap![nodeType]
|
||||||
const {
|
const {
|
||||||
newNode,
|
newNode,
|
||||||
@ -695,7 +694,7 @@ export const useNodesInteractions = () => {
|
|||||||
type: getNodeCustomTypeByNodeDataType(nodeType),
|
type: getNodeCustomTypeByNodeDataType(nodeType),
|
||||||
data: {
|
data: {
|
||||||
...(defaultValue as any),
|
...(defaultValue as any),
|
||||||
title: nodesWithSameType.length > 0 ? `${title} ${nodesWithSameType.length + 1}` : title,
|
title: nodesWithSameType.length > 0 ? `${defaultValue.title} ${nodesWithSameType.length + 1}` : defaultValue.title,
|
||||||
...(toolDefaultValue || {}),
|
...(toolDefaultValue || {}),
|
||||||
selected: true,
|
selected: true,
|
||||||
_showAddVariablePopup: (nodeType === BlockEnum.VariableAssigner || nodeType === BlockEnum.VariableAggregator) && !!prevNodeId,
|
_showAddVariablePopup: (nodeType === BlockEnum.VariableAssigner || nodeType === BlockEnum.VariableAggregator) && !!prevNodeId,
|
||||||
@ -1121,7 +1120,6 @@ export const useNodesInteractions = () => {
|
|||||||
const nodesWithSameType = nodes.filter(node => node.data.type === nodeType)
|
const nodesWithSameType = nodes.filter(node => node.data.type === nodeType)
|
||||||
const {
|
const {
|
||||||
defaultValue,
|
defaultValue,
|
||||||
title,
|
|
||||||
} = nodesMetaDataMap![nodeType]
|
} = nodesMetaDataMap![nodeType]
|
||||||
const {
|
const {
|
||||||
newNode: newCurrentNode,
|
newNode: newCurrentNode,
|
||||||
@ -1131,7 +1129,7 @@ export const useNodesInteractions = () => {
|
|||||||
type: getNodeCustomTypeByNodeDataType(nodeType),
|
type: getNodeCustomTypeByNodeDataType(nodeType),
|
||||||
data: {
|
data: {
|
||||||
...(defaultValue as any),
|
...(defaultValue as any),
|
||||||
title: nodesWithSameType.length > 0 ? `${title} ${nodesWithSameType.length + 1}` : title,
|
title: nodesWithSameType.length > 0 ? `${defaultValue.title} ${nodesWithSameType.length + 1}` : defaultValue.title,
|
||||||
...(toolDefaultValue || {}),
|
...(toolDefaultValue || {}),
|
||||||
_connectedSourceHandleIds: [],
|
_connectedSourceHandleIds: [],
|
||||||
_connectedTargetHandleIds: [],
|
_connectedTargetHandleIds: [],
|
||||||
|
|||||||
@ -55,7 +55,7 @@ const PanelOperatorPopup = ({
|
|||||||
const edge = edges.find(edge => edge.target === id)
|
const edge = edges.find(edge => edge.target === id)
|
||||||
const author = useMemo(() => {
|
const author = useMemo(() => {
|
||||||
if (data.type !== BlockEnum.Tool)
|
if (data.type !== BlockEnum.Tool)
|
||||||
return nodesExtraData![data.type].author
|
return nodesExtraData![data.type].metaData.author
|
||||||
|
|
||||||
if (data.provider_type === CollectionType.builtIn)
|
if (data.provider_type === CollectionType.builtIn)
|
||||||
return buildInTools.find(toolWithProvider => canFindTool(toolWithProvider.id, data.provider_id))?.author
|
return buildInTools.find(toolWithProvider => canFindTool(toolWithProvider.id, data.provider_id))?.author
|
||||||
@ -68,7 +68,7 @@ const PanelOperatorPopup = ({
|
|||||||
|
|
||||||
const about = useMemo(() => {
|
const about = useMemo(() => {
|
||||||
if (data.type !== BlockEnum.Tool)
|
if (data.type !== BlockEnum.Tool)
|
||||||
return nodesExtraData![data.type].description
|
return nodesExtraData![data.type].metaData.description
|
||||||
|
|
||||||
if (data.provider_type === CollectionType.builtIn)
|
if (data.provider_type === CollectionType.builtIn)
|
||||||
return buildInTools.find(toolWithProvider => canFindTool(toolWithProvider.id, data.provider_id))?.description[language]
|
return buildInTools.find(toolWithProvider => canFindTool(toolWithProvider.id, data.provider_id))?.description[language]
|
||||||
|
|||||||
@ -6,7 +6,7 @@ export const useNodeHelpLink = (nodeType: BlockEnum) => {
|
|||||||
const availableNodesMetaData = useNodesMetaData()
|
const availableNodesMetaData = useNodesMetaData()
|
||||||
|
|
||||||
const link = useMemo(() => {
|
const link = useMemo(() => {
|
||||||
const result = availableNodesMetaData?.nodesMap?.[nodeType]?.helpLinkUri || ''
|
const result = availableNodesMetaData?.nodesMap?.[nodeType]?.metaData.helpLinkUri || ''
|
||||||
|
|
||||||
return result
|
return result
|
||||||
}, [availableNodesMetaData, nodeType])
|
}, [availableNodesMetaData, nodeType])
|
||||||
|
|||||||
@ -6,13 +6,13 @@ import { renderI18nObject } from '@/i18n'
|
|||||||
import { genNodeMetaData } from '@/app/components/workflow/utils'
|
import { genNodeMetaData } from '@/app/components/workflow/utils'
|
||||||
import { BlockEnum } from '@/app/components/workflow/types'
|
import { BlockEnum } from '@/app/components/workflow/types'
|
||||||
|
|
||||||
|
const metaData = genNodeMetaData({
|
||||||
|
sort: 3,
|
||||||
|
type: BlockEnum.Agent,
|
||||||
|
})
|
||||||
const nodeDefault: NodeDefault<AgentNodeType> = {
|
const nodeDefault: NodeDefault<AgentNodeType> = {
|
||||||
...genNodeMetaData({
|
metaData,
|
||||||
sort: 3,
|
defaultValue: {},
|
||||||
type: BlockEnum.Agent,
|
|
||||||
}),
|
|
||||||
defaultValue: {
|
|
||||||
},
|
|
||||||
checkValid(payload, t, moreDataForCheckValid: {
|
checkValid(payload, t, moreDataForCheckValid: {
|
||||||
strategyProvider?: StrategyPluginDetail,
|
strategyProvider?: StrategyPluginDetail,
|
||||||
strategy?: StrategyDetail
|
strategy?: StrategyDetail
|
||||||
|
|||||||
@ -3,11 +3,12 @@ import type { AnswerNodeType } from './types'
|
|||||||
import { genNodeMetaData } from '@/app/components/workflow/utils'
|
import { genNodeMetaData } from '@/app/components/workflow/utils'
|
||||||
import { BlockEnum } from '@/app/components/workflow/types'
|
import { BlockEnum } from '@/app/components/workflow/types'
|
||||||
|
|
||||||
|
const metaData = genNodeMetaData({
|
||||||
|
sort: 2.1,
|
||||||
|
type: BlockEnum.Answer,
|
||||||
|
})
|
||||||
const nodeDefault: NodeDefault<AnswerNodeType> = {
|
const nodeDefault: NodeDefault<AnswerNodeType> = {
|
||||||
...genNodeMetaData({
|
metaData,
|
||||||
sort: 2.1,
|
|
||||||
type: BlockEnum.Answer,
|
|
||||||
}),
|
|
||||||
defaultValue: {
|
defaultValue: {
|
||||||
variables: [],
|
variables: [],
|
||||||
answer: '',
|
answer: '',
|
||||||
|
|||||||
@ -5,13 +5,14 @@ import { BlockEnum } from '@/app/components/workflow/types'
|
|||||||
import { BlockClassificationEnum } from '@/app/components/workflow/block-selector/types'
|
import { BlockClassificationEnum } from '@/app/components/workflow/block-selector/types'
|
||||||
const i18nPrefix = 'workflow.errorMsg'
|
const i18nPrefix = 'workflow.errorMsg'
|
||||||
|
|
||||||
|
const metaData = genNodeMetaData({
|
||||||
|
classification: BlockClassificationEnum.Transform,
|
||||||
|
sort: 5,
|
||||||
|
type: BlockEnum.Assigner,
|
||||||
|
helpLinkUri: 'variable-assigner',
|
||||||
|
})
|
||||||
const nodeDefault: NodeDefault<AssignerNodeType> = {
|
const nodeDefault: NodeDefault<AssignerNodeType> = {
|
||||||
...genNodeMetaData({
|
metaData,
|
||||||
classification: BlockClassificationEnum.Transform,
|
|
||||||
sort: 5,
|
|
||||||
type: BlockEnum.Assigner,
|
|
||||||
helpLinkUri: 'variable-assigner',
|
|
||||||
}),
|
|
||||||
defaultValue: {
|
defaultValue: {
|
||||||
version: '2',
|
version: '2',
|
||||||
items: [],
|
items: [],
|
||||||
|
|||||||
@ -6,12 +6,13 @@ import { BlockClassificationEnum } from '@/app/components/workflow/block-selecto
|
|||||||
|
|
||||||
const i18nPrefix = 'workflow.errorMsg'
|
const i18nPrefix = 'workflow.errorMsg'
|
||||||
|
|
||||||
|
const metaData = genNodeMetaData({
|
||||||
|
classification: BlockClassificationEnum.Transform,
|
||||||
|
sort: 1,
|
||||||
|
type: BlockEnum.Code,
|
||||||
|
})
|
||||||
const nodeDefault: NodeDefault<CodeNodeType> = {
|
const nodeDefault: NodeDefault<CodeNodeType> = {
|
||||||
...genNodeMetaData({
|
metaData,
|
||||||
classification: BlockClassificationEnum.Transform,
|
|
||||||
sort: 1,
|
|
||||||
type: BlockEnum.Code,
|
|
||||||
}),
|
|
||||||
defaultValue: {
|
defaultValue: {
|
||||||
code: '',
|
code: '',
|
||||||
code_language: CodeLanguage.python3,
|
code_language: CodeLanguage.python3,
|
||||||
|
|||||||
@ -3,13 +3,13 @@ import type { DataSourceNodeType } from './types'
|
|||||||
import { genNodeMetaData } from '@/app/components/workflow/utils'
|
import { genNodeMetaData } from '@/app/components/workflow/utils'
|
||||||
import { BlockEnum } from '@/app/components/workflow/types'
|
import { BlockEnum } from '@/app/components/workflow/types'
|
||||||
|
|
||||||
|
const metaData = genNodeMetaData({
|
||||||
|
sort: -1,
|
||||||
|
type: BlockEnum.DataSource,
|
||||||
|
})
|
||||||
const nodeDefault: NodeDefault<DataSourceNodeType> = {
|
const nodeDefault: NodeDefault<DataSourceNodeType> = {
|
||||||
...genNodeMetaData({
|
metaData,
|
||||||
sort: -1,
|
defaultValue: {},
|
||||||
type: BlockEnum.DataSource,
|
|
||||||
}),
|
|
||||||
defaultValue: {
|
|
||||||
},
|
|
||||||
checkValid() {
|
checkValid() {
|
||||||
return {
|
return {
|
||||||
isValid: true,
|
isValid: true,
|
||||||
|
|||||||
@ -2,11 +2,15 @@ import type { FC } from 'react'
|
|||||||
import { memo } from 'react'
|
import { memo } from 'react'
|
||||||
import type { DataSourceNodeType } from './types'
|
import type { DataSourceNodeType } from './types'
|
||||||
import type { NodePanelProps } from '@/app/components/workflow/types'
|
import type { NodePanelProps } from '@/app/components/workflow/types'
|
||||||
|
import VariableOrConstantInputField from '@/app/components/base/form/components/field/variable-or-constant-input'
|
||||||
|
|
||||||
const Panel: FC<NodePanelProps<DataSourceNodeType>> = () => {
|
const Panel: FC<NodePanelProps<DataSourceNodeType>> = () => {
|
||||||
return (
|
return (
|
||||||
<div className='mb-2 mt-2 space-y-4 px-4'>
|
<div className='mb-2 mt-2 space-y-4 px-4'>
|
||||||
datasource
|
datasource
|
||||||
|
<VariableOrConstantInputField
|
||||||
|
label='Parent maximum chunk length'
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,13 +5,14 @@ import { BlockEnum } from '@/app/components/workflow/types'
|
|||||||
import { BlockClassificationEnum } from '@/app/components/workflow/block-selector/types'
|
import { BlockClassificationEnum } from '@/app/components/workflow/block-selector/types'
|
||||||
const i18nPrefix = 'workflow.errorMsg'
|
const i18nPrefix = 'workflow.errorMsg'
|
||||||
|
|
||||||
|
const metaData = genNodeMetaData({
|
||||||
|
classification: BlockClassificationEnum.Transform,
|
||||||
|
sort: 4,
|
||||||
|
type: BlockEnum.DocExtractor,
|
||||||
|
helpLinkUri: 'doc-extractor',
|
||||||
|
})
|
||||||
const nodeDefault: NodeDefault<DocExtractorNodeType> = {
|
const nodeDefault: NodeDefault<DocExtractorNodeType> = {
|
||||||
...genNodeMetaData({
|
metaData,
|
||||||
classification: BlockClassificationEnum.Transform,
|
|
||||||
sort: 4,
|
|
||||||
type: BlockEnum.DocExtractor,
|
|
||||||
helpLinkUri: 'doc-extractor',
|
|
||||||
}),
|
|
||||||
defaultValue: {
|
defaultValue: {
|
||||||
variable_selector: [],
|
variable_selector: [],
|
||||||
is_array_file: false,
|
is_array_file: false,
|
||||||
|
|||||||
@ -3,11 +3,12 @@ import type { EndNodeType } from './types'
|
|||||||
import { genNodeMetaData } from '@/app/components/workflow/utils'
|
import { genNodeMetaData } from '@/app/components/workflow/utils'
|
||||||
import { BlockEnum } from '@/app/components/workflow/types'
|
import { BlockEnum } from '@/app/components/workflow/types'
|
||||||
|
|
||||||
|
const metaData = genNodeMetaData({
|
||||||
|
sort: 2.1,
|
||||||
|
type: BlockEnum.End,
|
||||||
|
})
|
||||||
const nodeDefault: NodeDefault<EndNodeType> = {
|
const nodeDefault: NodeDefault<EndNodeType> = {
|
||||||
...genNodeMetaData({
|
metaData,
|
||||||
sort: 2.1,
|
|
||||||
type: BlockEnum.End,
|
|
||||||
}),
|
|
||||||
defaultValue: {
|
defaultValue: {
|
||||||
outputs: [],
|
outputs: [],
|
||||||
},
|
},
|
||||||
|
|||||||
@ -5,12 +5,13 @@ import { genNodeMetaData } from '@/app/components/workflow/utils'
|
|||||||
import { BlockEnum } from '@/app/components/workflow/types'
|
import { BlockEnum } from '@/app/components/workflow/types'
|
||||||
import { BlockClassificationEnum } from '@/app/components/workflow/block-selector/types'
|
import { BlockClassificationEnum } from '@/app/components/workflow/block-selector/types'
|
||||||
|
|
||||||
|
const metaData = genNodeMetaData({
|
||||||
|
classification: BlockClassificationEnum.Utilities,
|
||||||
|
sort: 1,
|
||||||
|
type: BlockEnum.HttpRequest,
|
||||||
|
})
|
||||||
const nodeDefault: NodeDefault<HttpNodeType> = {
|
const nodeDefault: NodeDefault<HttpNodeType> = {
|
||||||
...genNodeMetaData({
|
metaData,
|
||||||
classification: BlockClassificationEnum.Utilities,
|
|
||||||
sort: 1,
|
|
||||||
type: BlockEnum.HttpRequest,
|
|
||||||
}),
|
|
||||||
defaultValue: {
|
defaultValue: {
|
||||||
variables: [],
|
variables: [],
|
||||||
method: Method.get,
|
method: Method.get,
|
||||||
|
|||||||
@ -6,13 +6,14 @@ import { BlockEnum } from '@/app/components/workflow/types'
|
|||||||
import { BlockClassificationEnum } from '@/app/components/workflow/block-selector/types'
|
import { BlockClassificationEnum } from '@/app/components/workflow/block-selector/types'
|
||||||
const i18nPrefix = 'workflow.errorMsg'
|
const i18nPrefix = 'workflow.errorMsg'
|
||||||
|
|
||||||
|
const metaData = genNodeMetaData({
|
||||||
|
classification: BlockClassificationEnum.Logic,
|
||||||
|
sort: 1,
|
||||||
|
type: BlockEnum.IfElse,
|
||||||
|
helpLinkUri: 'ifelse',
|
||||||
|
})
|
||||||
const nodeDefault: NodeDefault<IfElseNodeType> = {
|
const nodeDefault: NodeDefault<IfElseNodeType> = {
|
||||||
...genNodeMetaData({
|
metaData,
|
||||||
classification: BlockClassificationEnum.Logic,
|
|
||||||
sort: 1,
|
|
||||||
type: BlockEnum.IfElse,
|
|
||||||
helpLinkUri: 'ifelse',
|
|
||||||
}),
|
|
||||||
defaultValue: {
|
defaultValue: {
|
||||||
_targetBranches: [
|
_targetBranches: [
|
||||||
{
|
{
|
||||||
|
|||||||
@ -3,11 +3,12 @@ import type { IterationStartNodeType } from './types'
|
|||||||
import { genNodeMetaData } from '@/app/components/workflow/utils'
|
import { genNodeMetaData } from '@/app/components/workflow/utils'
|
||||||
import { BlockEnum } from '@/app/components/workflow/types'
|
import { BlockEnum } from '@/app/components/workflow/types'
|
||||||
|
|
||||||
|
const metaData = genNodeMetaData({
|
||||||
|
sort: -1,
|
||||||
|
type: BlockEnum.IterationStart,
|
||||||
|
})
|
||||||
const nodeDefault: NodeDefault<IterationStartNodeType> = {
|
const nodeDefault: NodeDefault<IterationStartNodeType> = {
|
||||||
...genNodeMetaData({
|
metaData,
|
||||||
sort: -1,
|
|
||||||
type: BlockEnum.IterationStart,
|
|
||||||
}),
|
|
||||||
defaultValue: {},
|
defaultValue: {},
|
||||||
checkValid() {
|
checkValid() {
|
||||||
return {
|
return {
|
||||||
|
|||||||
@ -6,12 +6,13 @@ import { BlockEnum } from '@/app/components/workflow/types'
|
|||||||
import { BlockClassificationEnum } from '@/app/components/workflow/block-selector/types'
|
import { BlockClassificationEnum } from '@/app/components/workflow/block-selector/types'
|
||||||
const i18nPrefix = 'workflow'
|
const i18nPrefix = 'workflow'
|
||||||
|
|
||||||
|
const metaData = genNodeMetaData({
|
||||||
|
classification: BlockClassificationEnum.Logic,
|
||||||
|
sort: 2,
|
||||||
|
type: BlockEnum.Iteration,
|
||||||
|
})
|
||||||
const nodeDefault: NodeDefault<IterationNodeType> = {
|
const nodeDefault: NodeDefault<IterationNodeType> = {
|
||||||
...genNodeMetaData({
|
metaData,
|
||||||
classification: BlockClassificationEnum.Logic,
|
|
||||||
sort: 2,
|
|
||||||
type: BlockEnum.Iteration,
|
|
||||||
}),
|
|
||||||
defaultValue: {
|
defaultValue: {
|
||||||
start_node_id: '',
|
start_node_id: '',
|
||||||
iterator_selector: [],
|
iterator_selector: [],
|
||||||
|
|||||||
@ -129,6 +129,7 @@ export const useNodeIterationInteractions = () => {
|
|||||||
_connectedTargetHandleIds: [],
|
_connectedTargetHandleIds: [],
|
||||||
title: nodesWithSameType.length > 0 ? `${t(`workflow.blocks.${childNodeType}`)} ${nodesWithSameType.length + 1}` : t(`workflow.blocks.${childNodeType}`),
|
title: nodesWithSameType.length > 0 ? `${t(`workflow.blocks.${childNodeType}`)} ${nodesWithSameType.length + 1}` : t(`workflow.blocks.${childNodeType}`),
|
||||||
iteration_id: newNodeId,
|
iteration_id: newNodeId,
|
||||||
|
type: childNodeType,
|
||||||
},
|
},
|
||||||
position: child.position,
|
position: child.position,
|
||||||
positionAbsolute: child.positionAbsolute,
|
positionAbsolute: child.positionAbsolute,
|
||||||
|
|||||||
@ -3,13 +3,13 @@ import type { KnowledgeBaseNodeType } from './types'
|
|||||||
import { genNodeMetaData } from '@/app/components/workflow/utils'
|
import { genNodeMetaData } from '@/app/components/workflow/utils'
|
||||||
import { BlockEnum } from '@/app/components/workflow/types'
|
import { BlockEnum } from '@/app/components/workflow/types'
|
||||||
|
|
||||||
|
const metaData = genNodeMetaData({
|
||||||
|
sort: 3.1,
|
||||||
|
type: BlockEnum.KnowledgeBase,
|
||||||
|
})
|
||||||
const nodeDefault: NodeDefault<KnowledgeBaseNodeType> = {
|
const nodeDefault: NodeDefault<KnowledgeBaseNodeType> = {
|
||||||
...genNodeMetaData({
|
metaData,
|
||||||
sort: 3.1,
|
defaultValue: {},
|
||||||
type: BlockEnum.KnowledgeBase,
|
|
||||||
}),
|
|
||||||
defaultValue: {
|
|
||||||
},
|
|
||||||
checkValid() {
|
checkValid() {
|
||||||
return {
|
return {
|
||||||
isValid: true,
|
isValid: true,
|
||||||
|
|||||||
@ -7,11 +7,12 @@ import { genNodeMetaData } from '@/app/components/workflow/utils'
|
|||||||
import { BlockEnum } from '@/app/components/workflow/types'
|
import { BlockEnum } from '@/app/components/workflow/types'
|
||||||
const i18nPrefix = 'workflow'
|
const i18nPrefix = 'workflow'
|
||||||
|
|
||||||
|
const metaData = genNodeMetaData({
|
||||||
|
sort: 2,
|
||||||
|
type: BlockEnum.KnowledgeRetrieval,
|
||||||
|
})
|
||||||
const nodeDefault: NodeDefault<KnowledgeRetrievalNodeType> = {
|
const nodeDefault: NodeDefault<KnowledgeRetrievalNodeType> = {
|
||||||
...genNodeMetaData({
|
metaData,
|
||||||
sort: 2,
|
|
||||||
type: BlockEnum.KnowledgeRetrieval,
|
|
||||||
}),
|
|
||||||
defaultValue: {
|
defaultValue: {
|
||||||
query_variable_selector: [],
|
query_variable_selector: [],
|
||||||
dataset_ids: [],
|
dataset_ids: [],
|
||||||
|
|||||||
@ -7,12 +7,13 @@ import { BlockEnum } from '@/app/components/workflow/types'
|
|||||||
import { BlockClassificationEnum } from '@/app/components/workflow/block-selector/types'
|
import { BlockClassificationEnum } from '@/app/components/workflow/block-selector/types'
|
||||||
const i18nPrefix = 'workflow.errorMsg'
|
const i18nPrefix = 'workflow.errorMsg'
|
||||||
|
|
||||||
|
const metaData = genNodeMetaData({
|
||||||
|
classification: BlockClassificationEnum.Utilities,
|
||||||
|
sort: 2,
|
||||||
|
type: BlockEnum.ListFilter,
|
||||||
|
})
|
||||||
const nodeDefault: NodeDefault<ListFilterNodeType> = {
|
const nodeDefault: NodeDefault<ListFilterNodeType> = {
|
||||||
...genNodeMetaData({
|
metaData,
|
||||||
classification: BlockClassificationEnum.Utilities,
|
|
||||||
sort: 2,
|
|
||||||
type: BlockEnum.ListFilter,
|
|
||||||
}),
|
|
||||||
defaultValue: {
|
defaultValue: {
|
||||||
variable: [],
|
variable: [],
|
||||||
filter_by: {
|
filter_by: {
|
||||||
|
|||||||
@ -6,11 +6,12 @@ import { BlockEnum } from '@/app/components/workflow/types'
|
|||||||
|
|
||||||
const i18nPrefix = 'workflow.errorMsg'
|
const i18nPrefix = 'workflow.errorMsg'
|
||||||
|
|
||||||
|
const metaData = genNodeMetaData({
|
||||||
|
sort: 1,
|
||||||
|
type: BlockEnum.LLM,
|
||||||
|
})
|
||||||
const nodeDefault: NodeDefault<LLMNodeType> = {
|
const nodeDefault: NodeDefault<LLMNodeType> = {
|
||||||
...genNodeMetaData({
|
metaData,
|
||||||
sort: 1,
|
|
||||||
type: BlockEnum.LLM,
|
|
||||||
}),
|
|
||||||
defaultValue: {
|
defaultValue: {
|
||||||
model: {
|
model: {
|
||||||
provider: '',
|
provider: '',
|
||||||
|
|||||||
@ -6,12 +6,13 @@ import { genNodeMetaData } from '@/app/components/workflow/utils'
|
|||||||
import { BlockEnum } from '@/app/components/workflow/types'
|
import { BlockEnum } from '@/app/components/workflow/types'
|
||||||
import { BlockClassificationEnum } from '@/app/components/workflow/block-selector/types'
|
import { BlockClassificationEnum } from '@/app/components/workflow/block-selector/types'
|
||||||
|
|
||||||
|
const metaData = genNodeMetaData({
|
||||||
|
classification: BlockClassificationEnum.Logic,
|
||||||
|
sort: 2,
|
||||||
|
type: BlockEnum.LoopEnd,
|
||||||
|
})
|
||||||
const nodeDefault: NodeDefault<SimpleNodeType> = {
|
const nodeDefault: NodeDefault<SimpleNodeType> = {
|
||||||
...genNodeMetaData({
|
metaData,
|
||||||
classification: BlockClassificationEnum.Logic,
|
|
||||||
sort: 2,
|
|
||||||
type: BlockEnum.LoopEnd,
|
|
||||||
}),
|
|
||||||
defaultValue: {},
|
defaultValue: {},
|
||||||
checkValid() {
|
checkValid() {
|
||||||
return {
|
return {
|
||||||
|
|||||||
@ -3,11 +3,12 @@ import type { LoopStartNodeType } from './types'
|
|||||||
import { genNodeMetaData } from '@/app/components/workflow/utils'
|
import { genNodeMetaData } from '@/app/components/workflow/utils'
|
||||||
import { BlockEnum } from '@/app/components/workflow/types'
|
import { BlockEnum } from '@/app/components/workflow/types'
|
||||||
|
|
||||||
|
const metaData = genNodeMetaData({
|
||||||
|
sort: -1,
|
||||||
|
type: BlockEnum.LoopStart,
|
||||||
|
})
|
||||||
const nodeDefault: NodeDefault<LoopStartNodeType> = {
|
const nodeDefault: NodeDefault<LoopStartNodeType> = {
|
||||||
...genNodeMetaData({
|
metaData,
|
||||||
sort: -1,
|
|
||||||
type: BlockEnum.LoopStart,
|
|
||||||
}),
|
|
||||||
defaultValue: {},
|
defaultValue: {},
|
||||||
checkValid() {
|
checkValid() {
|
||||||
return {
|
return {
|
||||||
|
|||||||
@ -8,13 +8,14 @@ import { BlockEnum } from '@/app/components/workflow/types'
|
|||||||
import { BlockClassificationEnum } from '@/app/components/workflow/block-selector/types'
|
import { BlockClassificationEnum } from '@/app/components/workflow/block-selector/types'
|
||||||
const i18nPrefix = 'workflow.errorMsg'
|
const i18nPrefix = 'workflow.errorMsg'
|
||||||
|
|
||||||
|
const metaData = genNodeMetaData({
|
||||||
|
classification: BlockClassificationEnum.Logic,
|
||||||
|
sort: 3,
|
||||||
|
type: BlockEnum.Loop,
|
||||||
|
author: 'AICT-Team',
|
||||||
|
})
|
||||||
const nodeDefault: NodeDefault<LoopNodeType> = {
|
const nodeDefault: NodeDefault<LoopNodeType> = {
|
||||||
...genNodeMetaData({
|
metaData,
|
||||||
classification: BlockClassificationEnum.Logic,
|
|
||||||
sort: 3,
|
|
||||||
type: BlockEnum.Loop,
|
|
||||||
// author: 'AICT-Team',
|
|
||||||
}),
|
|
||||||
defaultValue: {
|
defaultValue: {
|
||||||
start_node_id: '',
|
start_node_id: '',
|
||||||
break_conditions: [],
|
break_conditions: [],
|
||||||
|
|||||||
@ -116,7 +116,6 @@ export const useNodeLoopInteractions = () => {
|
|||||||
const childNodeType = child.data.type as BlockEnum
|
const childNodeType = child.data.type as BlockEnum
|
||||||
const {
|
const {
|
||||||
defaultValue,
|
defaultValue,
|
||||||
title,
|
|
||||||
} = nodesMetaDataMap![childNodeType]
|
} = nodesMetaDataMap![childNodeType]
|
||||||
const nodesWithSameType = nodes.filter(node => node.data.type === childNodeType)
|
const nodesWithSameType = nodes.filter(node => node.data.type === childNodeType)
|
||||||
const { newNode } = generateNewNode({
|
const { newNode } = generateNewNode({
|
||||||
@ -128,7 +127,7 @@ export const useNodeLoopInteractions = () => {
|
|||||||
_isBundled: false,
|
_isBundled: false,
|
||||||
_connectedSourceHandleIds: [],
|
_connectedSourceHandleIds: [],
|
||||||
_connectedTargetHandleIds: [],
|
_connectedTargetHandleIds: [],
|
||||||
title: nodesWithSameType.length > 0 ? `${title} ${nodesWithSameType.length + 1}` : title,
|
title: nodesWithSameType.length > 0 ? `${defaultValue.title} ${nodesWithSameType.length + 1}` : defaultValue.title,
|
||||||
loop_id: newNodeId,
|
loop_id: newNodeId,
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|||||||
@ -5,12 +5,13 @@ import { BlockEnum } from '@/app/components/workflow/types'
|
|||||||
import { BlockClassificationEnum } from '@/app/components/workflow/block-selector/types'
|
import { BlockClassificationEnum } from '@/app/components/workflow/block-selector/types'
|
||||||
const i18nPrefix = 'workflow'
|
const i18nPrefix = 'workflow'
|
||||||
|
|
||||||
|
const metaData = genNodeMetaData({
|
||||||
|
classification: BlockClassificationEnum.Transform,
|
||||||
|
sort: 6,
|
||||||
|
type: BlockEnum.ParameterExtractor,
|
||||||
|
})
|
||||||
const nodeDefault: NodeDefault<ParameterExtractorNodeType> = {
|
const nodeDefault: NodeDefault<ParameterExtractorNodeType> = {
|
||||||
...genNodeMetaData({
|
metaData,
|
||||||
classification: BlockClassificationEnum.Transform,
|
|
||||||
sort: 6,
|
|
||||||
type: BlockEnum.ParameterExtractor,
|
|
||||||
}),
|
|
||||||
defaultValue: {
|
defaultValue: {
|
||||||
query: [],
|
query: [],
|
||||||
model: {
|
model: {
|
||||||
|
|||||||
@ -6,12 +6,13 @@ import { BlockClassificationEnum } from '@/app/components/workflow/block-selecto
|
|||||||
|
|
||||||
const i18nPrefix = 'workflow'
|
const i18nPrefix = 'workflow'
|
||||||
|
|
||||||
|
const metaData = genNodeMetaData({
|
||||||
|
classification: BlockClassificationEnum.QuestionUnderstand,
|
||||||
|
sort: 1,
|
||||||
|
type: BlockEnum.QuestionClassifier,
|
||||||
|
})
|
||||||
const nodeDefault: NodeDefault<QuestionClassifierNodeType> = {
|
const nodeDefault: NodeDefault<QuestionClassifierNodeType> = {
|
||||||
...genNodeMetaData({
|
metaData,
|
||||||
classification: BlockClassificationEnum.QuestionUnderstand,
|
|
||||||
sort: 1,
|
|
||||||
type: BlockEnum.QuestionClassifier,
|
|
||||||
}),
|
|
||||||
defaultValue: {
|
defaultValue: {
|
||||||
query_variable_selector: [],
|
query_variable_selector: [],
|
||||||
model: {
|
model: {
|
||||||
|
|||||||
@ -3,11 +3,12 @@ import type { StartNodeType } from './types'
|
|||||||
import { genNodeMetaData } from '@/app/components/workflow/utils'
|
import { genNodeMetaData } from '@/app/components/workflow/utils'
|
||||||
import { BlockEnum } from '@/app/components/workflow/types'
|
import { BlockEnum } from '@/app/components/workflow/types'
|
||||||
|
|
||||||
|
const metaData = genNodeMetaData({
|
||||||
|
sort: 0.1,
|
||||||
|
type: BlockEnum.Start,
|
||||||
|
})
|
||||||
const nodeDefault: NodeDefault<StartNodeType> = {
|
const nodeDefault: NodeDefault<StartNodeType> = {
|
||||||
...genNodeMetaData({
|
metaData,
|
||||||
sort: 0.1,
|
|
||||||
type: BlockEnum.Start,
|
|
||||||
}),
|
|
||||||
defaultValue: {
|
defaultValue: {
|
||||||
variables: [],
|
variables: [],
|
||||||
},
|
},
|
||||||
|
|||||||
@ -5,13 +5,14 @@ import { BlockEnum } from '@/app/components/workflow/types'
|
|||||||
import { BlockClassificationEnum } from '@/app/components/workflow/block-selector/types'
|
import { BlockClassificationEnum } from '@/app/components/workflow/block-selector/types'
|
||||||
const i18nPrefix = 'workflow.errorMsg'
|
const i18nPrefix = 'workflow.errorMsg'
|
||||||
|
|
||||||
|
const metaData = genNodeMetaData({
|
||||||
|
classification: BlockClassificationEnum.Transform,
|
||||||
|
sort: 2,
|
||||||
|
type: BlockEnum.TemplateTransform,
|
||||||
|
helpLinkUri: 'template',
|
||||||
|
})
|
||||||
const nodeDefault: NodeDefault<TemplateTransformNodeType> = {
|
const nodeDefault: NodeDefault<TemplateTransformNodeType> = {
|
||||||
...genNodeMetaData({
|
metaData,
|
||||||
classification: BlockClassificationEnum.Transform,
|
|
||||||
sort: 2,
|
|
||||||
type: BlockEnum.TemplateTransform,
|
|
||||||
helpLinkUri: 'template',
|
|
||||||
}),
|
|
||||||
defaultValue: {
|
defaultValue: {
|
||||||
template: '',
|
template: '',
|
||||||
variables: [],
|
variables: [],
|
||||||
|
|||||||
@ -6,12 +6,13 @@ import { BlockEnum } from '@/app/components/workflow/types'
|
|||||||
|
|
||||||
const i18nPrefix = 'workflow.errorMsg'
|
const i18nPrefix = 'workflow.errorMsg'
|
||||||
|
|
||||||
|
const metaData = genNodeMetaData({
|
||||||
|
sort: -1,
|
||||||
|
type: BlockEnum.Tool,
|
||||||
|
helpLinkUri: 'tools',
|
||||||
|
})
|
||||||
const nodeDefault: NodeDefault<ToolNodeType> = {
|
const nodeDefault: NodeDefault<ToolNodeType> = {
|
||||||
...genNodeMetaData({
|
metaData,
|
||||||
sort: -1,
|
|
||||||
type: BlockEnum.Tool,
|
|
||||||
helpLinkUri: 'tools',
|
|
||||||
}),
|
|
||||||
defaultValue: {
|
defaultValue: {
|
||||||
tool_parameters: {},
|
tool_parameters: {},
|
||||||
tool_configurations: {},
|
tool_configurations: {},
|
||||||
|
|||||||
@ -6,12 +6,13 @@ import { BlockClassificationEnum } from '@/app/components/workflow/block-selecto
|
|||||||
|
|
||||||
const i18nPrefix = 'workflow'
|
const i18nPrefix = 'workflow'
|
||||||
|
|
||||||
|
const metaData = genNodeMetaData({
|
||||||
|
classification: BlockClassificationEnum.Transform,
|
||||||
|
sort: 3,
|
||||||
|
type: BlockEnum.VariableAggregator,
|
||||||
|
})
|
||||||
const nodeDefault: NodeDefault<VariableAssignerNodeType> = {
|
const nodeDefault: NodeDefault<VariableAssignerNodeType> = {
|
||||||
...genNodeMetaData({
|
metaData,
|
||||||
classification: BlockClassificationEnum.Transform,
|
|
||||||
sort: 3,
|
|
||||||
type: BlockEnum.VariableAggregator,
|
|
||||||
}),
|
|
||||||
defaultValue: {
|
defaultValue: {
|
||||||
output_type: VarType.any,
|
output_type: VarType.any,
|
||||||
variables: [],
|
variables: [],
|
||||||
|
|||||||
@ -59,13 +59,12 @@ const AddBlock = ({
|
|||||||
const nodesWithSameType = nodes.filter(node => node.data.type === type)
|
const nodesWithSameType = nodes.filter(node => node.data.type === type)
|
||||||
const {
|
const {
|
||||||
defaultValue,
|
defaultValue,
|
||||||
title,
|
|
||||||
} = nodesMetaDataMap![type]
|
} = nodesMetaDataMap![type]
|
||||||
const { newNode } = generateNewNode({
|
const { newNode } = generateNewNode({
|
||||||
type: getNodeCustomTypeByNodeDataType(type),
|
type: getNodeCustomTypeByNodeDataType(type),
|
||||||
data: {
|
data: {
|
||||||
...(defaultValue as any),
|
...(defaultValue as any),
|
||||||
title: nodesWithSameType.length > 0 ? `${title} ${nodesWithSameType.length + 1}` : title,
|
title: nodesWithSameType.length > 0 ? `${defaultValue.title} ${nodesWithSameType.length + 1}` : defaultValue.title,
|
||||||
...(toolDefaultValue || {}),
|
...(toolDefaultValue || {}),
|
||||||
_isCandidate: true,
|
_isCandidate: true,
|
||||||
},
|
},
|
||||||
|
|||||||
@ -292,13 +292,15 @@ export type NodeOutPutVar = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export type NodeDefault<T = {}> = {
|
export type NodeDefault<T = {}> = {
|
||||||
classification: BlockClassificationEnum
|
metaData: {
|
||||||
sort: number
|
classification: BlockClassificationEnum
|
||||||
type: BlockEnum
|
sort: number
|
||||||
title: string
|
type: BlockEnum
|
||||||
author: string
|
title: string
|
||||||
description?: string
|
author: string
|
||||||
helpLinkUri?: string
|
description?: string
|
||||||
|
helpLinkUri?: string
|
||||||
|
}
|
||||||
defaultValue: Partial<T>
|
defaultValue: Partial<T>
|
||||||
checkValid: (payload: T, t: any, moreDataForCheckValid?: any) => { isValid: boolean; errorMessage?: string }
|
checkValid: (payload: T, t: any, moreDataForCheckValid?: any) => { isValid: boolean; errorMessage?: string }
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user