mirror of
https://github.com/langgenius/dify.git
synced 2026-05-04 17:38:04 +08:00
feat: handle system var
This commit is contained in:
@ -39,6 +39,17 @@ const formatItem = (item: any, isChatMode: boolean): NodeOutPutVar => {
|
|||||||
type: inputVarTypeToVarType(v.type),
|
type: inputVarTypeToVarType(v.type),
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
if (isChatMode) {
|
||||||
|
res.vars.push({
|
||||||
|
variable: 'sys.query',
|
||||||
|
type: VarType.string,
|
||||||
|
})
|
||||||
|
|
||||||
|
res.vars.push({
|
||||||
|
variable: 'sys.files',
|
||||||
|
type: VarType.arrayFile,
|
||||||
|
})
|
||||||
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -20,6 +20,7 @@ const Panel: FC<NodePanelProps<StartNodeType>> = ({
|
|||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const readOnly = false
|
const readOnly = false
|
||||||
const {
|
const {
|
||||||
|
isChatMode,
|
||||||
inputs,
|
inputs,
|
||||||
isShowAddVarModal,
|
isShowAddVarModal,
|
||||||
showAddVarModal,
|
showAddVarModal,
|
||||||
@ -50,16 +51,17 @@ const Panel: FC<NodePanelProps<StartNodeType>> = ({
|
|||||||
</Field>
|
</Field>
|
||||||
</div>
|
</div>
|
||||||
<Split />
|
<Split />
|
||||||
|
{isChatMode && (
|
||||||
<div className='px-4 pt-4 pb-2'>
|
<div className='px-4 pt-4 pb-2'>
|
||||||
<OutputVars title={t(`${i18nPrefix}.builtInVar`)!}>
|
<OutputVars title={t(`${i18nPrefix}.builtInVar`)!}>
|
||||||
<>
|
<>
|
||||||
<VarItem
|
<VarItem
|
||||||
name='sys.query'
|
name='sys.query'
|
||||||
type='string'
|
type='string'
|
||||||
description={t(`${i18nPrefix}.outputVars.query`)}
|
description={t(`${i18nPrefix}.outputVars.query`)}
|
||||||
/>
|
/>
|
||||||
<VarItem
|
{/* Now not support sys.memories */}
|
||||||
|
{/* <VarItem
|
||||||
name='sys.memories'
|
name='sys.memories'
|
||||||
type='array[Object]'
|
type='array[Object]'
|
||||||
description={t(`${i18nPrefix}.outputVars.memories.des`)}
|
description={t(`${i18nPrefix}.outputVars.memories.des`)}
|
||||||
@ -75,15 +77,17 @@ const Panel: FC<NodePanelProps<StartNodeType>> = ({
|
|||||||
description: t(`${i18nPrefix}.outputVars.memories.content`),
|
description: t(`${i18nPrefix}.outputVars.memories.content`),
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
/>
|
/> */}
|
||||||
<VarItem
|
<VarItem
|
||||||
name='sys.files'
|
name='sys.files'
|
||||||
type='string'
|
type='string'
|
||||||
description={t(`${i18nPrefix}.outputVars.files`)}
|
description={t(`${i18nPrefix}.outputVars.files`)}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
</OutputVars>
|
</OutputVars>
|
||||||
</div>
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
{isShowAddVarModal && (
|
{isShowAddVarModal && (
|
||||||
<ConfigVarModal
|
<ConfigVarModal
|
||||||
isCreate
|
isCreate
|
||||||
|
|||||||
@ -4,8 +4,13 @@ import { useBoolean } from 'ahooks'
|
|||||||
import type { StartNodeType } from './types'
|
import type { StartNodeType } from './types'
|
||||||
import type { InputVar } from '@/app/components/workflow/types'
|
import type { InputVar } from '@/app/components/workflow/types'
|
||||||
import useNodeCrud from '@/app/components/workflow/nodes/_base/hooks/use-node-crud'
|
import useNodeCrud from '@/app/components/workflow/nodes/_base/hooks/use-node-crud'
|
||||||
|
import {
|
||||||
|
useIsChatMode,
|
||||||
|
} from '@/app/components/workflow/hooks'
|
||||||
|
|
||||||
const useConfig = (id: string, payload: StartNodeType) => {
|
const useConfig = (id: string, payload: StartNodeType) => {
|
||||||
|
const isChatMode = useIsChatMode()
|
||||||
|
|
||||||
const { inputs, setInputs } = useNodeCrud<StartNodeType>(id, payload)
|
const { inputs, setInputs } = useNodeCrud<StartNodeType>(id, payload)
|
||||||
|
|
||||||
const [isShowAddVarModal, {
|
const [isShowAddVarModal, {
|
||||||
@ -27,6 +32,7 @@ const useConfig = (id: string, payload: StartNodeType) => {
|
|||||||
setInputs(newInputs)
|
setInputs(newInputs)
|
||||||
}, [inputs, setInputs])
|
}, [inputs, setInputs])
|
||||||
return {
|
return {
|
||||||
|
isChatMode,
|
||||||
inputs,
|
inputs,
|
||||||
isShowAddVarModal,
|
isShowAddVarModal,
|
||||||
showAddVarModal,
|
showAddVarModal,
|
||||||
|
|||||||
Reference in New Issue
Block a user