mirror of https://github.com/langgenius/dify.git
feat: start build in vars show
This commit is contained in:
parent
ea76f46223
commit
5817a035f9
|
|
@ -6,11 +6,13 @@ import cn from 'classnames'
|
|||
|
||||
type Props = {
|
||||
className?: string
|
||||
title?: string
|
||||
children: JSX.Element
|
||||
}
|
||||
|
||||
const OutputVars: FC<Props> = ({
|
||||
className,
|
||||
title,
|
||||
children,
|
||||
}) => {
|
||||
const { t } = useTranslation()
|
||||
|
|
@ -18,7 +20,7 @@ const OutputVars: FC<Props> = ({
|
|||
return (
|
||||
<div>
|
||||
<div className={cn(className, 'leading-[18px] text-[13px] font-semibold text-gray-700 uppercase')}>
|
||||
{t('workflow.nodes.common.outputVars')}
|
||||
{title || t('workflow.nodes.common.outputVars')}
|
||||
</div>
|
||||
<div className='mt-2 space-y-1'>
|
||||
{children}
|
||||
|
|
@ -30,12 +32,18 @@ type VarItemProps = {
|
|||
name: string
|
||||
type: string
|
||||
description: string
|
||||
subItems?: {
|
||||
name: string
|
||||
type: string
|
||||
description: string
|
||||
}[]
|
||||
}
|
||||
|
||||
export const VarItem: FC<VarItemProps> = ({
|
||||
name,
|
||||
type,
|
||||
description,
|
||||
subItems,
|
||||
}) => {
|
||||
return (
|
||||
<div className='py-1'>
|
||||
|
|
@ -43,7 +51,21 @@ export const VarItem: FC<VarItemProps> = ({
|
|||
<div className='text-[13px] font-medium text-gray-900'>{name}</div>
|
||||
<div className='ml-2 text-xs font-normal text-gray-500 capitalize'>{type}</div>
|
||||
</div>
|
||||
<div className='mt-0.5 leading-[18px] text-xs font-normal text-gray-600'>{description}</div>
|
||||
<div className='mt-0.5 leading-[18px] text-xs font-normal text-gray-600'>
|
||||
{description}
|
||||
{subItems && (
|
||||
<div className='ml-2 border-l border-gray-200 pl-2'>
|
||||
{subItems.map((item, index) => (
|
||||
<VarItem
|
||||
key={index}
|
||||
name={item.name}
|
||||
type={item.type}
|
||||
description={item.description}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,59 @@
|
|||
import type { FC } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import Split from '@/app/components/workflow/nodes/_base/components/split'
|
||||
import Field from '@/app/components/workflow/nodes/_base/components/field'
|
||||
import OutputVars, { VarItem } from '@/app/components/workflow/nodes/_base/components/output-vars'
|
||||
|
||||
const i18nPrefix = 'workflow.nodes.start'
|
||||
|
||||
const Panel: FC = () => {
|
||||
const { t } = useTranslation()
|
||||
|
||||
return (
|
||||
<div>start panel inputs</div>
|
||||
<div className='mt-2'>
|
||||
<div className='px-4 pb-4 space-y-4'>
|
||||
<Field
|
||||
title={t(`${i18nPrefix}.model`)}
|
||||
>
|
||||
ss
|
||||
</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
|
||||
name='sys.memories'
|
||||
type='array[Object]'
|
||||
description={t(`${i18nPrefix}.outputVars.memories.des`)}
|
||||
subItems={[
|
||||
{
|
||||
name: 'type',
|
||||
type: 'string',
|
||||
description: t(`${i18nPrefix}.outputVars.memories.type`),
|
||||
},
|
||||
{
|
||||
name: 'content',
|
||||
type: 'string',
|
||||
description: t(`${i18nPrefix}.outputVars.memories.content`),
|
||||
},
|
||||
]}
|
||||
/>
|
||||
<VarItem
|
||||
name='sys.files'
|
||||
type='string'
|
||||
description={t(`${i18nPrefix}.outputVars.files`)}
|
||||
/>
|
||||
</>
|
||||
</OutputVars>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,12 @@
|
|||
import { useState } from 'react'
|
||||
import type { StartNodeType } from './types'
|
||||
|
||||
const useConfig = (initInputs: StartNodeType) => {
|
||||
const [inputs, setInputs] = useState<StartNodeType>(initInputs)
|
||||
|
||||
return {
|
||||
inputs,
|
||||
}
|
||||
}
|
||||
|
||||
export default useConfig
|
||||
|
|
@ -6,6 +6,16 @@ const translation = {
|
|||
},
|
||||
start: {
|
||||
required: 'required',
|
||||
builtInVar: 'Built-in Variables',
|
||||
outputVars: {
|
||||
query: 'User input',
|
||||
memories: {
|
||||
des: 'Conversation history',
|
||||
type: 'message type',
|
||||
content: 'message content',
|
||||
},
|
||||
files: 'File list',
|
||||
},
|
||||
},
|
||||
end: {
|
||||
outputs: 'Outputs',
|
||||
|
|
|
|||
|
|
@ -6,6 +6,16 @@ const translation = {
|
|||
},
|
||||
start: {
|
||||
required: '必填',
|
||||
builtInVar: '内置变量',
|
||||
outputVars: {
|
||||
query: '用户输入',
|
||||
memories: {
|
||||
des: '会话历史',
|
||||
type: '消息类型',
|
||||
content: '消息内容',
|
||||
},
|
||||
files: '文件列表',
|
||||
},
|
||||
},
|
||||
end: {
|
||||
outputs: '输出',
|
||||
|
|
|
|||
Loading…
Reference in New Issue