mirror of https://github.com/langgenius/dify.git
feat: handle system var
This commit is contained in:
parent
cbe7de58ab
commit
2edef89a8d
|
|
@ -39,6 +39,17 @@ const formatItem = (item: any, isChatMode: boolean): NodeOutPutVar => {
|
|||
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
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ const Panel: FC<NodePanelProps<StartNodeType>> = ({
|
|||
const { t } = useTranslation()
|
||||
const readOnly = false
|
||||
const {
|
||||
isChatMode,
|
||||
inputs,
|
||||
isShowAddVarModal,
|
||||
showAddVarModal,
|
||||
|
|
@ -50,16 +51,17 @@ const Panel: FC<NodePanelProps<StartNodeType>> = ({
|
|||
</Field>
|
||||
</div>
|
||||
<Split />
|
||||
|
||||
<div className='px-4 pt-4 pb-2'>
|
||||
<OutputVars title={t(`${i18nPrefix}.builtInVar`)!}>
|
||||
<>
|
||||
<VarItem
|
||||
name='sys.query'
|
||||
type='string'
|
||||
description={t(`${i18nPrefix}.outputVars.query`)}
|
||||
/>
|
||||
<VarItem
|
||||
{isChatMode && (
|
||||
<div className='px-4 pt-4 pb-2'>
|
||||
<OutputVars title={t(`${i18nPrefix}.builtInVar`)!}>
|
||||
<>
|
||||
<VarItem
|
||||
name='sys.query'
|
||||
type='string'
|
||||
description={t(`${i18nPrefix}.outputVars.query`)}
|
||||
/>
|
||||
{/* Now not support sys.memories */}
|
||||
{/* <VarItem
|
||||
name='sys.memories'
|
||||
type='array[Object]'
|
||||
description={t(`${i18nPrefix}.outputVars.memories.des`)}
|
||||
|
|
@ -75,15 +77,17 @@ const Panel: FC<NodePanelProps<StartNodeType>> = ({
|
|||
description: t(`${i18nPrefix}.outputVars.memories.content`),
|
||||
},
|
||||
]}
|
||||
/>
|
||||
<VarItem
|
||||
name='sys.files'
|
||||
type='string'
|
||||
description={t(`${i18nPrefix}.outputVars.files`)}
|
||||
/>
|
||||
</>
|
||||
</OutputVars>
|
||||
</div>
|
||||
/> */}
|
||||
<VarItem
|
||||
name='sys.files'
|
||||
type='string'
|
||||
description={t(`${i18nPrefix}.outputVars.files`)}
|
||||
/>
|
||||
</>
|
||||
</OutputVars>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{isShowAddVarModal && (
|
||||
<ConfigVarModal
|
||||
isCreate
|
||||
|
|
|
|||
|
|
@ -4,8 +4,13 @@ import { useBoolean } from 'ahooks'
|
|||
import type { StartNodeType } from './types'
|
||||
import type { InputVar } from '@/app/components/workflow/types'
|
||||
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 isChatMode = useIsChatMode()
|
||||
|
||||
const { inputs, setInputs } = useNodeCrud<StartNodeType>(id, payload)
|
||||
|
||||
const [isShowAddVarModal, {
|
||||
|
|
@ -27,6 +32,7 @@ const useConfig = (id: string, payload: StartNodeType) => {
|
|||
setInputs(newInputs)
|
||||
}, [inputs, setInputs])
|
||||
return {
|
||||
isChatMode,
|
||||
inputs,
|
||||
isShowAddVarModal,
|
||||
showAddVarModal,
|
||||
|
|
|
|||
Loading…
Reference in New Issue