Commit 801160c4 authored by Joel's avatar Joel

feat: tool output vars

parent cb2a8142
...@@ -312,3 +312,14 @@ export const HTTP_REQUEST_OUTPUT_STRUCT: Var[] = [ ...@@ -312,3 +312,14 @@ export const HTTP_REQUEST_OUTPUT_STRUCT: Var[] = [
type: VarType.string, type: VarType.string,
}, },
] ]
export const TOOL_OUTPUT_STRUCT: Var[] = [
{
variable: 'text',
type: VarType.string,
},
{
variable: 'files',
type: VarType.arrayFile,
},
]
...@@ -11,6 +11,7 @@ import { ...@@ -11,6 +11,7 @@ import {
LLM_OUTPUT_STRUCT, LLM_OUTPUT_STRUCT,
SUPPORT_OUTPUT_VARS_NODE, SUPPORT_OUTPUT_VARS_NODE,
TEMPLATE_TRANSFORM_OUTPUT_STRUCT, TEMPLATE_TRANSFORM_OUTPUT_STRUCT,
TOOL_OUTPUT_STRUCT,
} from '@/app/components/workflow/constants' } from '@/app/components/workflow/constants'
const inputVarTypeToVarType = (type: InputVarType): VarType => { const inputVarTypeToVarType = (type: InputVarType): VarType => {
...@@ -89,6 +90,12 @@ const formatItem = (item: any, isChatMode: boolean): NodeOutPutVar => { ...@@ -89,6 +90,12 @@ const formatItem = (item: any, isChatMode: boolean): NodeOutPutVar => {
type: output_type, 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 ...@@ -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 ConfigCredential from '@/app/components/tools/setting/build-in/config-credentials'
import Loading from '@/app/components/base/loading' import Loading from '@/app/components/base/loading'
import BeforeRunForm from '@/app/components/workflow/nodes/_base/components/before-run-form' 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' const i18nPrefix = 'workflow.nodes.tool'
...@@ -110,6 +111,45 @@ const Panel: FC<NodePanelProps<ToolNodeType>> = ({ ...@@ -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 && ( {isShowSingleRun && (
<BeforeRunForm <BeforeRunForm
nodeName={inputs.title} nodeName={inputs.title}
......
...@@ -128,6 +128,7 @@ export enum VarType { ...@@ -128,6 +128,7 @@ export enum VarType {
arrayString = 'array[string]', arrayString = 'array[string]',
arrayNumber = 'array[number]', arrayNumber = 'array[number]',
arrayObject = 'array[object]', arrayObject = 'array[object]',
arrayFile = 'array[file]',
} }
export type Var = { export type Var = {
......
...@@ -245,6 +245,16 @@ const translation = { ...@@ -245,6 +245,16 @@ const translation = {
tool: { tool: {
toAuthorize: 'To authorize', toAuthorize: 'To authorize',
inputVars: 'Input Variables', 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: { questionClassifiers: {
model: 'model', model: 'model',
......
...@@ -245,6 +245,16 @@ const translation = { ...@@ -245,6 +245,16 @@ const translation = {
tool: { tool: {
toAuthorize: '授权', toAuthorize: '授权',
inputVars: '输入变量', inputVars: '输入变量',
outputVars: {
text: '工具生成的内容',
files: {
title: '工具生成的文件',
type: '支持类型。现在只支持图片',
transfer_method: '传输方式。值为 remote_url 或 local_file',
url: '图片链接',
upload_file_id: '上传文件ID',
},
},
}, },
questionClassifiers: { questionClassifiers: {
model: '模型', model: '模型',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment