mirror of
https://github.com/langgenius/dify.git
synced 2025-11-13 09:53:04 +00:00
fix: in prompt editor show vars error
This commit is contained in:
parent
b9fa3f54e9
commit
c891eb28fc
@ -27,12 +27,13 @@ import { Variable02 } from '@/app/components/base/icons/src/vender/solid/develop
|
|||||||
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 { VarBlockIcon } from '@/app/components/workflow/block-icon'
|
import { VarBlockIcon } from '@/app/components/workflow/block-icon'
|
||||||
import { Line3 } from '@/app/components/base/icons/src/public/common'
|
import { Line3 } from '@/app/components/base/icons/src/public/common'
|
||||||
import { isConversationVar, isENV, isSystemVar } from '@/app/components/workflow/nodes/_base/components/variable/utils'
|
import { isConversationVar, isENV, isRagVariableVar, isSystemVar } from '@/app/components/workflow/nodes/_base/components/variable/utils'
|
||||||
import Tooltip from '@/app/components/base/tooltip'
|
import Tooltip from '@/app/components/base/tooltip'
|
||||||
import { isExceptionVariable } from '@/app/components/workflow/utils'
|
import { isExceptionVariable } from '@/app/components/workflow/utils'
|
||||||
import VarFullPathPanel from '@/app/components/workflow/nodes/_base/components/variable/var-full-path-panel'
|
import VarFullPathPanel from '@/app/components/workflow/nodes/_base/components/variable/var-full-path-panel'
|
||||||
import { Type } from '@/app/components/workflow/nodes/llm/types'
|
import { Type } from '@/app/components/workflow/nodes/llm/types'
|
||||||
import type { ValueSelector } from '@/app/components/workflow/types'
|
import type { ValueSelector } from '@/app/components/workflow/types'
|
||||||
|
import { InputField } from '@/app/components/base/icons/src/vender/pipeline'
|
||||||
|
|
||||||
type WorkflowVariableBlockComponentProps = {
|
type WorkflowVariableBlockComponentProps = {
|
||||||
nodeKey: string
|
nodeKey: string
|
||||||
@ -54,7 +55,8 @@ const WorkflowVariableBlockComponent = ({
|
|||||||
const [editor] = useLexicalComposerContext()
|
const [editor] = useLexicalComposerContext()
|
||||||
const [ref, isSelected] = useSelectOrDelete(nodeKey, DELETE_WORKFLOW_VARIABLE_BLOCK_COMMAND)
|
const [ref, isSelected] = useSelectOrDelete(nodeKey, DELETE_WORKFLOW_VARIABLE_BLOCK_COMMAND)
|
||||||
const variablesLength = variables.length
|
const variablesLength = variables.length
|
||||||
const isShowAPart = variablesLength > 2
|
const isRagVar = isRagVariableVar(variables)
|
||||||
|
const isShowAPart = variablesLength > 2 && !isRagVar
|
||||||
const varName = (
|
const varName = (
|
||||||
() => {
|
() => {
|
||||||
const isSystem = isSystemVar(variables)
|
const isSystem = isSystemVar(variables)
|
||||||
@ -113,7 +115,7 @@ const WorkflowVariableBlockComponent = ({
|
|||||||
className={cn(
|
className={cn(
|
||||||
'group/wrap relative mx-0.5 flex h-[18px] select-none items-center rounded-[5px] border pl-0.5 pr-[3px] hover:border-state-accent-solid hover:bg-state-accent-hover',
|
'group/wrap relative mx-0.5 flex h-[18px] select-none items-center rounded-[5px] border pl-0.5 pr-[3px] hover:border-state-accent-solid hover:bg-state-accent-hover',
|
||||||
isSelected ? ' border-state-accent-solid bg-state-accent-hover' : ' border-components-panel-border-subtle bg-components-badge-white-to-dark',
|
isSelected ? ' border-state-accent-solid bg-state-accent-hover' : ' border-components-panel-border-subtle bg-components-badge-white-to-dark',
|
||||||
!node && !isEnv && !isChatVar && '!border-state-destructive-solid !bg-state-destructive-hover',
|
!node && !isEnv && !isChatVar && !isRagVar && '!border-state-destructive-solid !bg-state-destructive-hover',
|
||||||
)}
|
)}
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
e.stopPropagation()
|
e.stopPropagation()
|
||||||
@ -121,7 +123,7 @@ const WorkflowVariableBlockComponent = ({
|
|||||||
}}
|
}}
|
||||||
ref={ref}
|
ref={ref}
|
||||||
>
|
>
|
||||||
{!isEnv && !isChatVar && (
|
{!isEnv && !isChatVar && !isRagVar && (
|
||||||
<div className='flex items-center'>
|
<div className='flex items-center'>
|
||||||
{
|
{
|
||||||
node?.type && (
|
node?.type && (
|
||||||
@ -146,17 +148,19 @@ const WorkflowVariableBlockComponent = ({
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
<div className='flex items-center text-text-accent'>
|
<div className='flex items-center text-text-accent'>
|
||||||
{!isEnv && !isChatVar && <Variable02 className={cn('h-3.5 w-3.5 shrink-0', isException && 'text-text-warning')} />}
|
{!isEnv && !isChatVar && !isRagVar && <Variable02 className={cn('h-3.5 w-3.5 shrink-0', isException && 'text-text-warning')} />}
|
||||||
{isEnv && <Env className='h-3.5 w-3.5 shrink-0 text-util-colors-violet-violet-600' />}
|
{isEnv && <Env className='h-3.5 w-3.5 shrink-0 text-util-colors-violet-violet-600' />}
|
||||||
{isChatVar && <BubbleX className='h-3.5 w-3.5 text-util-colors-teal-teal-700' />}
|
{isChatVar && <BubbleX className='h-3.5 w-3.5 text-util-colors-teal-teal-700' />}
|
||||||
|
{isRagVar && <InputField className='h-3.5 w-3.5 text-text-accent' />}
|
||||||
<div className={cn(
|
<div className={cn(
|
||||||
'ml-0.5 shrink-0 truncate text-xs font-medium',
|
'ml-0.5 shrink-0 truncate text-xs font-medium',
|
||||||
isEnv && 'text-util-colors-violet-violet-600',
|
isEnv && 'text-util-colors-violet-violet-600',
|
||||||
isChatVar && 'text-util-colors-teal-teal-700',
|
isChatVar && 'text-util-colors-teal-teal-700',
|
||||||
isException && 'text-text-warning',
|
isException && 'text-text-warning',
|
||||||
|
isRagVar && 'text-text-accent',
|
||||||
)} title={varName}>{varName}</div>
|
)} title={varName}>{varName}</div>
|
||||||
{
|
{
|
||||||
!node && !isEnv && !isChatVar && (
|
!node && !isEnv && !isChatVar && !isRagVar && (
|
||||||
<RiErrorWarningFill className='ml-0.5 h-3 w-3 text-text-destructive' />
|
<RiErrorWarningFill className='ml-0.5 h-3 w-3 text-text-destructive' />
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -164,7 +168,7 @@ const WorkflowVariableBlockComponent = ({
|
|||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|
||||||
if (!node && !isEnv && !isChatVar) {
|
if (!node && !isEnv && !isChatVar && !isRagVar) {
|
||||||
return (
|
return (
|
||||||
<Tooltip popupContent={t('workflow.errorMsg.invalidVariable')}>
|
<Tooltip popupContent={t('workflow.errorMsg.invalidVariable')}>
|
||||||
{Item}
|
{Item}
|
||||||
|
|||||||
@ -275,7 +275,7 @@ Thought: {{agent_scratchpad}}
|
|||||||
`,
|
`,
|
||||||
}
|
}
|
||||||
|
|
||||||
export const VAR_REGEX = /\{\{(#[a-zA-Z0-9_-]{1,50}(\.[a-zA-Z_]\w{0,29}){1,10}#)\}\}/gi
|
export const VAR_REGEX = /\{\{(#[a-zA-Z0-9_-]{1,50}(\.[a-zA-Z_]?\w{0,29}){1,10}(\.[a-zA-Z0-9_-]{1,50})?#)\}\}/gi
|
||||||
|
|
||||||
export const resetReg = () => VAR_REGEX.lastIndex = 0
|
export const resetReg = () => VAR_REGEX.lastIndex = 0
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user