mirror of
https://github.com/langgenius/dify.git
synced 2026-04-30 05:06:29 +08:00
Merge branch 'feat/rag-2' of https://github.com/langgenius/dify into feat/rag-2
This commit is contained in:
commit
8ab5c47737
@ -62,7 +62,7 @@ const WorkflowVariableBlockComponent = ({
|
|||||||
}
|
}
|
||||||
)()
|
)()
|
||||||
const [localWorkflowNodesMap, setLocalWorkflowNodesMap] = useState<WorkflowNodesMap>(workflowNodesMap)
|
const [localWorkflowNodesMap, setLocalWorkflowNodesMap] = useState<WorkflowNodesMap>(workflowNodesMap)
|
||||||
const node = localWorkflowNodesMap![variables[0]]
|
const node = localWorkflowNodesMap![variables[isRagVar ? 1 : 0]]
|
||||||
const isEnv = isENV(variables)
|
const isEnv = isENV(variables)
|
||||||
const isChatVar = isConversationVar(variables)
|
const isChatVar = isConversationVar(variables)
|
||||||
const isException = isExceptionVariable(varName, node?.type)
|
const isException = isExceptionVariable(varName, node?.type)
|
||||||
@ -76,6 +76,9 @@ const WorkflowVariableBlockComponent = ({
|
|||||||
if (conversationVariables)
|
if (conversationVariables)
|
||||||
variableValid = conversationVariables.some(v => v.variable === `${variables?.[0] ?? ''}.${variables?.[1] ?? ''}`)
|
variableValid = conversationVariables.some(v => v.variable === `${variables?.[0] ?? ''}.${variables?.[1] ?? ''}`)
|
||||||
}
|
}
|
||||||
|
else if (isRagVar) {
|
||||||
|
variableValid = !!node || (variables[0] === 'rag' && variables[1] === 'shared')
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
variableValid = !!node
|
variableValid = !!node
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,18 +27,18 @@ const VariableTag = ({
|
|||||||
availableNodes,
|
availableNodes,
|
||||||
}: VariableTagProps) => {
|
}: VariableTagProps) => {
|
||||||
const nodes = useNodes<CommonNodeType>()
|
const nodes = useNodes<CommonNodeType>()
|
||||||
|
const isRagVar = isRagVariableVar(valueSelector)
|
||||||
const node = useMemo(() => {
|
const node = useMemo(() => {
|
||||||
if (isSystemVar(valueSelector)) {
|
if (isSystemVar(valueSelector)) {
|
||||||
const startNode = availableNodes?.find(n => n.data.type === BlockEnum.Start)
|
const startNode = availableNodes?.find(n => n.data.type === BlockEnum.Start)
|
||||||
if (startNode)
|
if (startNode)
|
||||||
return startNode
|
return startNode
|
||||||
}
|
}
|
||||||
return getNodeInfoById(availableNodes || nodes, valueSelector[0])
|
return getNodeInfoById(availableNodes || nodes, isRagVar ? valueSelector[1] : valueSelector[0])
|
||||||
}, [nodes, valueSelector, availableNodes])
|
}, [nodes, valueSelector, availableNodes, isRagVar])
|
||||||
|
|
||||||
const isEnv = isENV(valueSelector)
|
const isEnv = isENV(valueSelector)
|
||||||
const isChatVar = isConversationVar(valueSelector)
|
const isChatVar = isConversationVar(valueSelector)
|
||||||
const isRagVar = isRagVariableVar(valueSelector)
|
|
||||||
const isValid = Boolean(node) || isEnv || isChatVar || isRagVar
|
const isValid = Boolean(node) || isEnv || isChatVar || isRagVar
|
||||||
|
|
||||||
const variableName = isSystemVar(valueSelector) ? valueSelector.slice(0).join('.') : valueSelector.slice(1).join('.')
|
const variableName = isSystemVar(valueSelector) ? valueSelector.slice(0).join('.') : valueSelector.slice(1).join('.')
|
||||||
|
|||||||
@ -390,8 +390,9 @@ const VarReferencePicker: FC<Props> = ({
|
|||||||
if (isEnv) return 'environment'
|
if (isEnv) return 'environment'
|
||||||
if (isChatVar) return 'conversation'
|
if (isChatVar) return 'conversation'
|
||||||
if (isLoopVar) return 'loop'
|
if (isLoopVar) return 'loop'
|
||||||
|
if (isRagVar) return 'rag'
|
||||||
return 'system'
|
return 'system'
|
||||||
}, [isEnv, isChatVar, isLoopVar])
|
}, [isEnv, isChatVar, isLoopVar, isRagVar])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={cn(className, !readonly && 'cursor-pointer')}>
|
<div className={cn(className, !readonly && 'cursor-pointer')}>
|
||||||
|
|||||||
@ -135,8 +135,9 @@ const Item: FC<ItemProps> = ({
|
|||||||
if (isEnv) return 'environment'
|
if (isEnv) return 'environment'
|
||||||
if (isChatVar) return 'conversation'
|
if (isChatVar) return 'conversation'
|
||||||
if (isLoopVar) return 'loop'
|
if (isLoopVar) return 'loop'
|
||||||
|
if (isRagVariable) return 'rag'
|
||||||
return 'system'
|
return 'system'
|
||||||
}, [isEnv, isChatVar, isSys, isLoopVar])
|
}, [isEnv, isChatVar, isSys, isLoopVar, isRagVariable])
|
||||||
return (
|
return (
|
||||||
<PortalToFollowElem
|
<PortalToFollowElem
|
||||||
open={open}
|
open={open}
|
||||||
@ -159,7 +160,7 @@ const Item: FC<ItemProps> = ({
|
|||||||
variableCategory={variableCategory}
|
variableCategory={variableCategory}
|
||||||
isExceptionVariable={isException}
|
isExceptionVariable={isException}
|
||||||
/>
|
/>
|
||||||
{!isEnv && !isChatVar && (
|
{!isEnv && !isChatVar && !isRagVariable && (
|
||||||
<div title={itemData.variable} className='system-sm-medium ml-1 w-0 grow truncate text-text-secondary'>{itemData.variable}</div>
|
<div title={itemData.variable} className='system-sm-medium ml-1 w-0 grow truncate text-text-secondary'>{itemData.variable}</div>
|
||||||
)}
|
)}
|
||||||
{isEnv && (
|
{isEnv && (
|
||||||
|
|||||||
@ -2,9 +2,11 @@ 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 } 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 { InputField } from '@/app/components/base/icons/src/vender/pipeline'
|
||||||
import {
|
import {
|
||||||
isConversationVar,
|
isConversationVar,
|
||||||
isENV,
|
isENV,
|
||||||
|
isRagVariableVar,
|
||||||
isSystemVar,
|
isSystemVar,
|
||||||
} from '../utils'
|
} from '../utils'
|
||||||
import { VarInInspectType } from '@/types/workflow'
|
import { VarInInspectType } from '@/types/workflow'
|
||||||
@ -13,6 +15,9 @@ export const useVarIcon = (variables: string[], variableCategory?: VarInInspectT
|
|||||||
if (variableCategory === 'loop')
|
if (variableCategory === 'loop')
|
||||||
return Loop
|
return Loop
|
||||||
|
|
||||||
|
if (variableCategory === 'rag' || isRagVariableVar(variables))
|
||||||
|
return InputField
|
||||||
|
|
||||||
if (isENV(variables) || variableCategory === VarInInspectType.environment || variableCategory === 'environment')
|
if (isENV(variables) || variableCategory === VarInInspectType.environment || variableCategory === 'environment')
|
||||||
return Env
|
return Env
|
||||||
|
|
||||||
@ -41,7 +46,11 @@ export const useVarColor = (variables: string[], isExceptionVariable?: boolean,
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const useVarName = (variables: string[], notShowFullPath?: boolean) => {
|
export const useVarName = (variables: string[], notShowFullPath?: boolean) => {
|
||||||
const variableFullPathName = variables.slice(1).join('.')
|
let variableFullPathName = variables.slice(1).join('.')
|
||||||
|
|
||||||
|
if (isRagVariableVar(variables))
|
||||||
|
variableFullPathName = variables.slice(2).join('.')
|
||||||
|
|
||||||
const variablesLength = variables.length
|
const variablesLength = variables.length
|
||||||
const varName = useMemo(() => {
|
const varName = useMemo(() => {
|
||||||
const isSystem = isSystemVar(variables)
|
const isSystem = isSystemVar(variables)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user