mirror of
https://github.com/langgenius/dify.git
synced 2026-04-14 07:56:31 +08:00
feat: tool output vars
This commit is contained in:
parent
cb2a814296
commit
801160c430
@ -312,3 +312,14 @@ export const HTTP_REQUEST_OUTPUT_STRUCT: Var[] = [
|
||||
type: VarType.string,
|
||||
},
|
||||
]
|
||||
|
||||
export const TOOL_OUTPUT_STRUCT: Var[] = [
|
||||
{
|
||||
variable: 'text',
|
||||
type: VarType.string,
|
||||
},
|
||||
{
|
||||
variable: 'files',
|
||||
type: VarType.arrayFile,
|
||||
},
|
||||
]
|
||||
|
||||
@ -11,6 +11,7 @@ import {
|
||||
LLM_OUTPUT_STRUCT,
|
||||
SUPPORT_OUTPUT_VARS_NODE,
|
||||
TEMPLATE_TRANSFORM_OUTPUT_STRUCT,
|
||||
TOOL_OUTPUT_STRUCT,
|
||||
} from '@/app/components/workflow/constants'
|
||||
|
||||
const inputVarTypeToVarType = (type: InputVarType): VarType => {
|
||||
@ -89,6 +90,12 @@ const formatItem = (item: any, isChatMode: boolean): NodeOutPutVar => {
|
||||
type: output_type,
|
||||
},
|
||||
]
|
||||
break
|
||||
}
|
||||
|
||||
case BlockEnum.Tool: {
|
||||
res.vars = TOOL_OUTPUT_STRUCT
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -12,6 +12,7 @@ import Form from '@/app/components/header/account-setting/model-provider-page/mo
|
||||
import ConfigCredential from '@/app/components/tools/setting/build-in/config-credentials'
|
||||
import Loading from '@/app/components/base/loading'
|
||||
import BeforeRunForm from '@/app/components/workflow/nodes/_base/components/before-run-form'
|
||||
import OutputVars, { VarItem } from '@/app/components/workflow/nodes/_base/components/output-vars'
|
||||
|
||||
const i18nPrefix = 'workflow.nodes.tool'
|
||||
|
||||
@ -110,6 +111,45 @@ const Panel: FC<NodePanelProps<ToolNodeType>> = ({
|
||||
/>
|
||||
)}
|
||||
|
||||
<div className='px-4 pt-4 pb-2'>
|
||||
<OutputVars>
|
||||
<>
|
||||
<VarItem
|
||||
name='text'
|
||||
type='Array[Object]'
|
||||
description={t(`${i18nPrefix}.outputVars.text`)}
|
||||
/>
|
||||
<VarItem
|
||||
name='files'
|
||||
type='Array[File]'
|
||||
description={t(`${i18nPrefix}.outputVars.files.title`)}
|
||||
subItems={[
|
||||
{
|
||||
name: 'type',
|
||||
type: 'string',
|
||||
description: t(`${i18nPrefix}.outputVars.files.type`),
|
||||
},
|
||||
{
|
||||
name: 'transfer_method',
|
||||
type: 'string',
|
||||
description: t(`${i18nPrefix}.outputVars.files.transfer_method`),
|
||||
},
|
||||
{
|
||||
name: 'url',
|
||||
type: 'string',
|
||||
description: t(`${i18nPrefix}.outputVars.files.url`),
|
||||
},
|
||||
{
|
||||
name: 'upload_file_id',
|
||||
type: 'string',
|
||||
description: t(`${i18nPrefix}.outputVars.files.upload_file_id`),
|
||||
},
|
||||
]}
|
||||
/>
|
||||
</>
|
||||
</OutputVars>
|
||||
</div>
|
||||
|
||||
{isShowSingleRun && (
|
||||
<BeforeRunForm
|
||||
nodeName={inputs.title}
|
||||
|
||||
@ -128,6 +128,7 @@ export enum VarType {
|
||||
arrayString = 'array[string]',
|
||||
arrayNumber = 'array[number]',
|
||||
arrayObject = 'array[object]',
|
||||
arrayFile = 'array[file]',
|
||||
}
|
||||
|
||||
export type Var = {
|
||||
|
||||
@ -245,6 +245,16 @@ const translation = {
|
||||
tool: {
|
||||
toAuthorize: 'To authorize',
|
||||
inputVars: 'Input Variables',
|
||||
outputVars: {
|
||||
text: 'tool generated content',
|
||||
files: {
|
||||
title: 'tool generated files',
|
||||
type: 'Support type. Now only support image',
|
||||
transfer_method: 'Transfer method.Value is remote_url or local_file',
|
||||
url: 'Image url',
|
||||
upload_file_id: 'Upload file id',
|
||||
},
|
||||
},
|
||||
},
|
||||
questionClassifiers: {
|
||||
model: 'model',
|
||||
|
||||
@ -245,6 +245,16 @@ const translation = {
|
||||
tool: {
|
||||
toAuthorize: '授权',
|
||||
inputVars: '输入变量',
|
||||
outputVars: {
|
||||
text: '工具生成的内容',
|
||||
files: {
|
||||
title: '工具生成的文件',
|
||||
type: '支持类型。现在只支持图片',
|
||||
transfer_method: '传输方式。值为 remote_url 或 local_file',
|
||||
url: '图片链接',
|
||||
upload_file_id: '上传文件ID',
|
||||
},
|
||||
},
|
||||
},
|
||||
questionClassifiers: {
|
||||
model: '模型',
|
||||
|
||||
Loading…
Reference in New Issue
Block a user