mirror of
https://github.com/langgenius/dify.git
synced 2026-08-28 22:36:52 +08:00
feat: handle sys var to run
This commit is contained in:
parent
31b6383697
commit
601e888fde
@ -152,7 +152,12 @@ const formatItem = (item: any, isChatMode: boolean, filterVar: (payload: Var, se
|
|||||||
export const toNodeOutputVars = (nodes: any[], isChatMode: boolean, filterVar = (_payload: Var, _selector: ValueSelector) => true): NodeOutPutVar[] => {
|
export const toNodeOutputVars = (nodes: any[], isChatMode: boolean, filterVar = (_payload: Var, _selector: ValueSelector) => true): NodeOutPutVar[] => {
|
||||||
const res = nodes
|
const res = nodes
|
||||||
.filter(node => SUPPORT_OUTPUT_VARS_NODE.includes(node.data.type))
|
.filter(node => SUPPORT_OUTPUT_VARS_NODE.includes(node.data.type))
|
||||||
.map(node => formatItem(node, isChatMode, filterVar))
|
.map((node) => {
|
||||||
|
return {
|
||||||
|
...formatItem(node, isChatMode, filterVar),
|
||||||
|
isStartNode: node.data.type === BlockEnum.Start,
|
||||||
|
}
|
||||||
|
})
|
||||||
.filter(item => item.vars.length > 0)
|
.filter(item => item.vars.length > 0)
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|||||||
@ -62,9 +62,12 @@ const useOneStepRun = <T>({
|
|||||||
const allOutputVars = toNodeOutputVars(getBeforeNodesInSameBranch(id), isChatMode)
|
const allOutputVars = toNodeOutputVars(getBeforeNodesInSameBranch(id), isChatMode)
|
||||||
const getVar = (valueSelector: ValueSelector): Var | undefined => {
|
const getVar = (valueSelector: ValueSelector): Var | undefined => {
|
||||||
let res: Var | undefined
|
let res: Var | undefined
|
||||||
const targetVar = allOutputVars.find(v => v.nodeId === valueSelector[0])
|
const isSystem = valueSelector[0] === 'sys'
|
||||||
|
const targetVar = isSystem ? allOutputVars.find(item => !!item.isStartNode) : allOutputVars.find(v => v.nodeId === valueSelector[0])
|
||||||
if (!targetVar)
|
if (!targetVar)
|
||||||
return undefined
|
return undefined
|
||||||
|
if (isSystem)
|
||||||
|
return targetVar.vars.find(item => item.variable.split('.')[1] === valueSelector[1])
|
||||||
|
|
||||||
let curr: any = targetVar.vars
|
let curr: any = targetVar.vars
|
||||||
valueSelector.slice(1).forEach((key, i) => {
|
valueSelector.slice(1).forEach((key, i) => {
|
||||||
|
|||||||
@ -160,7 +160,7 @@ const Panel: FC<NodePanelProps<HttpNodeType>> = ({
|
|||||||
/>
|
/>
|
||||||
<VarItem
|
<VarItem
|
||||||
name='headers'
|
name='headers'
|
||||||
type='sting'
|
type='object'
|
||||||
description={t(`${i18nPrefix}.outputVars.headers`)}
|
description={t(`${i18nPrefix}.outputVars.headers`)}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@ -157,6 +157,7 @@ export type NodeOutPutVar = {
|
|||||||
nodeId: string
|
nodeId: string
|
||||||
title: string
|
title: string
|
||||||
vars: Var[]
|
vars: Var[]
|
||||||
|
isStartNode?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export type Block = {
|
export type Block = {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user