feat: var type to inner

pull/21398/head
Joel 11 months ago
parent c9a4c66b07
commit 0bf0c7dbe8

@ -4,7 +4,7 @@ import { useNodes } from 'reactflow'
import { useTranslation } from 'react-i18next' import { useTranslation } from 'react-i18next'
import NodeVariableItem from '../variable-assigner/components/node-variable-item' import NodeVariableItem from '../variable-assigner/components/node-variable-item'
import type { AssignerNodeType } from './types' import type { AssignerNodeType } from './types'
import { isConversationVar, isENV, isSystemVar } from '@/app/components/workflow/nodes/_base/components/variable/utils' import { isSystemVar } from '@/app/components/workflow/nodes/_base/components/variable/utils'
import { BlockEnum, type Node, type NodeProps } from '@/app/components/workflow/types' import { BlockEnum, type Node, type NodeProps } from '@/app/components/workflow/types'
const i18nPrefix = 'workflow.nodes.assigner' const i18nPrefix = 'workflow.nodes.assigner'
@ -38,18 +38,13 @@ const NodeComponent: FC<NodeProps<AssignerNodeType>> = ({
if (!variable || variable.length === 0) if (!variable || variable.length === 0)
return null return null
const isSystem = isSystemVar(variable) const isSystem = isSystemVar(variable)
const isEnv = isENV(variable)
const isChatVar = isConversationVar(variable)
const node = isSystem ? nodes.find(node => node.data.type === BlockEnum.Start) : nodes.find(node => node.id === variable[0]) const node = isSystem ? nodes.find(node => node.data.type === BlockEnum.Start) : nodes.find(node => node.id === variable[0])
const varName = isSystem ? `sys.${variable[variable.length - 1]}` : variable.slice(1).join('.')
return ( return (
<NodeVariableItem <NodeVariableItem
key={index} key={index}
node={node as Node} node={node as Node}
isEnv={isEnv} variable={variable}
isChatVar={isChatVar}
writeMode={value.operation} writeMode={value.operation}
varName={varName}
className='bg-workflow-block-parma-bg' className='bg-workflow-block-parma-bg'
/> />
) )
@ -63,19 +58,13 @@ const NodeComponent: FC<NodeProps<AssignerNodeType>> = ({
if (!variable || variable.length === 0) if (!variable || variable.length === 0)
return null return null
const isSystem = isSystemVar(variable) const isSystem = isSystemVar(variable)
const isEnv = isENV(variable)
const isChatVar = isConversationVar(variable)
const node = isSystem ? nodes.find(node => node.data.type === BlockEnum.Start) : nodes.find(node => node.id === variable[0]) const node = isSystem ? nodes.find(node => node.data.type === BlockEnum.Start) : nodes.find(node => node.id === variable[0])
const varName = isSystem ? `sys.${variable[variable.length - 1]}` : variable.slice(1).join('.')
return ( return (
<div className='relative flex flex-col items-start gap-0.5 self-stretch px-3 py-1'> <div className='relative flex flex-col items-start gap-0.5 self-stretch px-3 py-1'>
<NodeVariableItem <NodeVariableItem
node={node as Node} node={node as Node}
isEnv={isEnv} variable={variable}
isChatVar={isChatVar}
varName={varName}
writeMode={writeMode} writeMode={writeMode}
className='bg-workflow-block-parma-bg' className='bg-workflow-block-parma-bg'
/> />

@ -4,7 +4,7 @@ import { useNodes } from 'reactflow'
import { useTranslation } from 'react-i18next' import { useTranslation } from 'react-i18next'
import NodeVariableItem from '../variable-assigner/components/node-variable-item' import NodeVariableItem from '../variable-assigner/components/node-variable-item'
import type { DocExtractorNodeType } from './types' import type { DocExtractorNodeType } from './types'
import { isConversationVar, isENV, isSystemVar } from '@/app/components/workflow/nodes/_base/components/variable/utils' import { isSystemVar } from '@/app/components/workflow/nodes/_base/components/variable/utils'
import { BlockEnum, type Node, type NodeProps } from '@/app/components/workflow/types' import { BlockEnum, type Node, type NodeProps } from '@/app/components/workflow/types'
const i18nPrefix = 'workflow.nodes.docExtractor' const i18nPrefix = 'workflow.nodes.docExtractor'
@ -21,18 +21,13 @@ const NodeComponent: FC<NodeProps<DocExtractorNodeType>> = ({
return null return null
const isSystem = isSystemVar(variable) const isSystem = isSystemVar(variable)
const isEnv = isENV(variable)
const isChatVar = isConversationVar(variable)
const node = isSystem ? nodes.find(node => node.data.type === BlockEnum.Start) : nodes.find(node => node.id === variable[0]) const node = isSystem ? nodes.find(node => node.data.type === BlockEnum.Start) : nodes.find(node => node.id === variable[0])
const varName = isSystem ? `sys.${variable[variable.length - 1]}` : variable.slice(1).join('.')
return ( return (
<div className='relative px-3'> <div className='relative px-3'>
<div className='system-2xs-medium-uppercase mb-1 text-text-tertiary'>{t(`${i18nPrefix}.inputVar`)}</div> <div className='system-2xs-medium-uppercase mb-1 text-text-tertiary'>{t(`${i18nPrefix}.inputVar`)}</div>
<NodeVariableItem <NodeVariableItem
node={node as Node} node={node as Node}
isEnv={isEnv} variable={variable}
isChatVar={isChatVar}
varName={varName}
className='bg-workflow-block-parma-bg' className='bg-workflow-block-parma-bg'
/> />
</div> </div>

@ -4,7 +4,7 @@ import { useNodes } from 'reactflow'
import { useTranslation } from 'react-i18next' import { useTranslation } from 'react-i18next'
import NodeVariableItem from '../variable-assigner/components/node-variable-item' import NodeVariableItem from '../variable-assigner/components/node-variable-item'
import type { ListFilterNodeType } from './types' import type { ListFilterNodeType } from './types'
import { isConversationVar, isENV, isSystemVar } from '@/app/components/workflow/nodes/_base/components/variable/utils' import { isSystemVar } from '@/app/components/workflow/nodes/_base/components/variable/utils'
import { BlockEnum, type Node, type NodeProps } from '@/app/components/workflow/types' import { BlockEnum, type Node, type NodeProps } from '@/app/components/workflow/types'
const i18nPrefix = 'workflow.nodes.listFilter' const i18nPrefix = 'workflow.nodes.listFilter'
@ -21,18 +21,13 @@ const NodeComponent: FC<NodeProps<ListFilterNodeType>> = ({
return null return null
const isSystem = isSystemVar(variable) const isSystem = isSystemVar(variable)
const isEnv = isENV(variable)
const isChatVar = isConversationVar(variable)
const node = isSystem ? nodes.find(node => node.data.type === BlockEnum.Start) : nodes.find(node => node.id === variable[0]) const node = isSystem ? nodes.find(node => node.data.type === BlockEnum.Start) : nodes.find(node => node.id === variable[0])
const varName = isSystem ? `sys.${variable[variable.length - 1]}` : variable.slice(1).join('.')
return ( return (
<div className='relative px-3'> <div className='relative px-3'>
<div className='system-2xs-medium-uppercase mb-1 text-text-tertiary'>{t(`${i18nPrefix}.inputVar`)}</div> <div className='system-2xs-medium-uppercase mb-1 text-text-tertiary'>{t(`${i18nPrefix}.inputVar`)}</div>
<NodeVariableItem <NodeVariableItem
node={node as Node} node={node as Node}
isEnv={isEnv} variable={variable}
isChatVar={isChatVar}
varName={varName}
className='bg-workflow-block-parma-bg' className='bg-workflow-block-parma-bg'
/> />
</div> </div>

@ -19,7 +19,7 @@ import {
import { filterVar } from '../utils' import { filterVar } from '../utils'
import AddVariable from './add-variable' import AddVariable from './add-variable'
import NodeVariableItem from './node-variable-item' import NodeVariableItem from './node-variable-item'
import { isConversationVar, isENV, isSystemVar } from '@/app/components/workflow/nodes/_base/components/variable/utils' import { isSystemVar } from '@/app/components/workflow/nodes/_base/components/variable/utils'
import cn from '@/utils/classnames' import cn from '@/utils/classnames'
import { isExceptionVariable } from '@/app/components/workflow/utils' import { isExceptionVariable } from '@/app/components/workflow/utils'
@ -124,9 +124,6 @@ const NodeGroupItem = ({
{ {
!!item.variables.length && item.variables.map((variable = [], index) => { !!item.variables.length && item.variables.map((variable = [], index) => {
const isSystem = isSystemVar(variable) const isSystem = isSystemVar(variable)
const isEnv = isENV(variable)
const isChatVar = isConversationVar(variable)
const node = isSystem ? nodes.find(node => node.data.type === BlockEnum.Start) : nodes.find(node => node.id === variable[0]) const node = isSystem ? nodes.find(node => node.data.type === BlockEnum.Start) : nodes.find(node => node.id === variable[0])
const varName = isSystem ? `sys.${variable[variable.length - 1]}` : variable.slice(1).join('.') const varName = isSystem ? `sys.${variable[variable.length - 1]}` : variable.slice(1).join('.')
const isException = isExceptionVariable(varName, node?.data.type) const isException = isExceptionVariable(varName, node?.data.type)
@ -134,11 +131,9 @@ const NodeGroupItem = ({
return ( return (
<NodeVariableItem <NodeVariableItem
key={index} key={index}
isEnv={isEnv} variable={variable}
isChatVar={isChatVar}
isException={isException} isException={isException}
node={node as Node} node={node as Node}
varName={varName}
showBorder={showSelectedBorder || showSelectionBorder} showBorder={showSelectedBorder || showSelectionBorder}
/> />
) )

@ -9,13 +9,13 @@ import { Line3 } from '@/app/components/base/icons/src/public/common'
import { Variable02 } from '@/app/components/base/icons/src/vender/solid/development' import { Variable02 } from '@/app/components/base/icons/src/vender/solid/development'
import { BubbleX, Env } from '@/app/components/base/icons/src/vender/line/others' import { BubbleX, Env } from '@/app/components/base/icons/src/vender/line/others'
import Badge from '@/app/components/base/badge' import Badge from '@/app/components/base/badge'
import type { Node } from '@/app/components/workflow/types' import type { Node, ValueSelector } from '@/app/components/workflow/types'
import { isConversationVar, isENV, isRagVariableVar, isSystemVar } from '@/app/components/workflow/nodes/_base/components/variable/utils'
import { InputField } from '@/app/components/base/icons/src/vender/pipeline'
type NodeVariableItemProps = { type NodeVariableItemProps = {
isEnv: boolean
isChatVar: boolean
node: Node node: Node
varName: string variable: ValueSelector
writeMode?: string writeMode?: string
showBorder?: boolean showBorder?: boolean
className?: string className?: string
@ -25,10 +25,8 @@ type NodeVariableItemProps = {
const i18nPrefix = 'workflow.nodes.assigner' const i18nPrefix = 'workflow.nodes.assigner'
const NodeVariableItem = ({ const NodeVariableItem = ({
isEnv,
isChatVar,
node, node,
varName, variable,
writeMode, writeMode,
showBorder, showBorder,
className, className,
@ -36,6 +34,12 @@ const NodeVariableItem = ({
}: NodeVariableItemProps) => { }: NodeVariableItemProps) => {
const { t } = useTranslation() const { t } = useTranslation()
const isSystem = isSystemVar(variable)
const isEnv = isENV(variable)
const isChatVar = isConversationVar(variable)
const isRagVar = isRagVariableVar(variable)
const varName = isSystem ? `sys.${variable[variable.length - 1]}` : variable.slice(1).join('.')
const VariableIcon = useMemo(() => { const VariableIcon = useMemo(() => {
if (isEnv) { if (isEnv) {
return ( return (
@ -49,6 +53,12 @@ const NodeVariableItem = ({
) )
} }
if(isRagVar) {
return (
<InputField className='h-3.5 w-3.5 shrink-0 text-text-accent' />
)
}
return ( return (
<Variable02 <Variable02
className={cn( className={cn(
@ -57,7 +67,7 @@ const NodeVariableItem = ({
)} )}
/> />
) )
}, [isEnv, isChatVar, isException]) }, [isEnv, isChatVar, isRagVar, isException])
const VariableName = useMemo(() => { const VariableName = useMemo(() => {
return ( return (

Loading…
Cancel
Save