mirror of
https://github.com/langgenius/dify.git
synced 2026-04-29 04:26:30 +08:00
add memory icon in editor block
This commit is contained in:
parent
55f146f527
commit
257e43e2c2
@ -63,7 +63,8 @@ const WorkflowVariableBlockComponent = ({
|
|||||||
const [localWorkflowNodesMap, setLocalWorkflowNodesMap] = useState<WorkflowNodesMap>(workflowNodesMap)
|
const [localWorkflowNodesMap, setLocalWorkflowNodesMap] = useState<WorkflowNodesMap>(workflowNodesMap)
|
||||||
const node = localWorkflowNodesMap![variables[0]]
|
const node = localWorkflowNodesMap![variables[0]]
|
||||||
const isEnv = isENV(variables)
|
const isEnv = isENV(variables)
|
||||||
const isChatVar = isConversationVar(variables)
|
const isChatVar = isConversationVar(variables) && conversationVariables?.some(v => v.variable === `${variables?.[0] ?? ''}.${variables?.[1] ?? ''}` && v.type !== 'memory')
|
||||||
|
const isMemoryVar = isConversationVar(variables) && conversationVariables?.some(v => v.variable === `${variables?.[0] ?? ''}.${variables?.[1] ?? ''}` && v.type === 'memory')
|
||||||
const isException = isExceptionVariable(varName, node?.type)
|
const isException = isExceptionVariable(varName, node?.type)
|
||||||
|
|
||||||
let variableValid = true
|
let variableValid = true
|
||||||
@ -129,6 +130,7 @@ const WorkflowVariableBlockComponent = ({
|
|||||||
handleVariableJump()
|
handleVariableJump()
|
||||||
}}
|
}}
|
||||||
isExceptionVariable={isException}
|
isExceptionVariable={isException}
|
||||||
|
isMemoryVariable={isMemoryVar}
|
||||||
errorMsg={!variableValid ? t('workflow.errorMsg.invalidVariable') : undefined}
|
errorMsg={!variableValid ? t('workflow.errorMsg.invalidVariable') : undefined}
|
||||||
isSelected={isSelected}
|
isSelected={isSelected}
|
||||||
ref={ref}
|
ref={ref}
|
||||||
|
|||||||
@ -7,13 +7,15 @@ export type VariableIconProps = {
|
|||||||
className?: string
|
className?: string
|
||||||
variables?: string[]
|
variables?: string[]
|
||||||
variableCategory?: VarInInspectType | string
|
variableCategory?: VarInInspectType | string
|
||||||
|
isMemoryVariable?: boolean
|
||||||
}
|
}
|
||||||
const VariableIcon = ({
|
const VariableIcon = ({
|
||||||
className,
|
className,
|
||||||
variables = [],
|
variables = [],
|
||||||
variableCategory,
|
variableCategory,
|
||||||
|
isMemoryVariable,
|
||||||
}: VariableIconProps) => {
|
}: VariableIconProps) => {
|
||||||
const VarIcon = useVarIcon(variables, variableCategory)
|
const VarIcon = useVarIcon(variables, variableCategory, isMemoryVariable)
|
||||||
|
|
||||||
return VarIcon && (
|
return VarIcon && (
|
||||||
<VarIcon
|
<VarIcon
|
||||||
|
|||||||
@ -21,6 +21,7 @@ const VariableLabel = ({
|
|||||||
errorMsg,
|
errorMsg,
|
||||||
onClick,
|
onClick,
|
||||||
isExceptionVariable,
|
isExceptionVariable,
|
||||||
|
isMemoryVariable,
|
||||||
ref,
|
ref,
|
||||||
notShowFullPath,
|
notShowFullPath,
|
||||||
rightSlot,
|
rightSlot,
|
||||||
@ -50,6 +51,7 @@ const VariableLabel = ({
|
|||||||
<VariableIcon
|
<VariableIcon
|
||||||
variables={variables}
|
variables={variables}
|
||||||
className={varColorClassName}
|
className={varColorClassName}
|
||||||
|
isMemoryVariable={isMemoryVariable}
|
||||||
/>
|
/>
|
||||||
<VariableName
|
<VariableName
|
||||||
variables={variables}
|
variables={variables}
|
||||||
|
|||||||
@ -1,7 +1,8 @@
|
|||||||
import { useMemo } from 'react'
|
import { useMemo } from 'react'
|
||||||
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, Memory } from '@/app/components/base/icons/src/vender/line/others'
|
||||||
import { Loop } from '@/app/components/base/icons/src/vender/workflow'
|
import { Loop } from '@/app/components/base/icons/src/vender/workflow'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
isConversationVar,
|
isConversationVar,
|
||||||
isENV,
|
isENV,
|
||||||
@ -9,13 +10,16 @@ import {
|
|||||||
} from '../utils'
|
} from '../utils'
|
||||||
import { VarInInspectType } from '@/types/workflow'
|
import { VarInInspectType } from '@/types/workflow'
|
||||||
|
|
||||||
export const useVarIcon = (variables: string[], variableCategory?: VarInInspectType | string) => {
|
export const useVarIcon = (variables: string[], variableCategory?: VarInInspectType | string, isMemoryVariable?: boolean) => {
|
||||||
if (variableCategory === 'loop')
|
if (variableCategory === 'loop')
|
||||||
return Loop
|
return Loop
|
||||||
|
|
||||||
if (isENV(variables) || variableCategory === VarInInspectType.environment || variableCategory === 'environment')
|
if (isENV(variables) || variableCategory === VarInInspectType.environment || variableCategory === 'environment')
|
||||||
return Env
|
return Env
|
||||||
|
|
||||||
|
if (isMemoryVariable)
|
||||||
|
return Memory
|
||||||
|
|
||||||
if (isConversationVar(variables) || variableCategory === VarInInspectType.conversation || variableCategory === 'conversation')
|
if (isConversationVar(variables) || variableCategory === VarInInspectType.conversation || variableCategory === 'conversation')
|
||||||
return BubbleX
|
return BubbleX
|
||||||
|
|
||||||
|
|||||||
@ -13,6 +13,7 @@ export type VariablePayload = {
|
|||||||
onClick?: (e: React.MouseEvent<HTMLDivElement>) => void
|
onClick?: (e: React.MouseEvent<HTMLDivElement>) => void
|
||||||
errorMsg?: string
|
errorMsg?: string
|
||||||
isExceptionVariable?: boolean
|
isExceptionVariable?: boolean
|
||||||
|
isMemoryVariable?: boolean
|
||||||
ref?: React.Ref<HTMLDivElement>
|
ref?: React.Ref<HTMLDivElement>
|
||||||
notShowFullPath?: boolean
|
notShowFullPath?: boolean
|
||||||
rightSlot?: ReactNode
|
rightSlot?: ReactNode
|
||||||
|
|||||||
@ -288,6 +288,7 @@ export enum VarType {
|
|||||||
arrayFile = 'array[file]',
|
arrayFile = 'array[file]',
|
||||||
any = 'any',
|
any = 'any',
|
||||||
arrayAny = 'array[any]',
|
arrayAny = 'array[any]',
|
||||||
|
memory = 'memory',
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum ValueType {
|
export enum ValueType {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user