# 代码节点
工作流的代码执行节点,用于执行自定义代码。
# 数据结构定义
export interface CodeNodeDef {
id: INodeIDValue;
type: WorkflowNodeTypeEnum.Code;
data: {
title: string;
inputsValues: {
language: IFlowConstantValue, // 脚本类型
script: IFlowConstantValue, // 脚本内容
input_params: Record<string, IFlowValue>; // 输入参数
max_retries: IFlowConstantValue, // 最大重试次数
retry_interval: IFlowConstantValue, // 重试间隔
};
inputs: IJsonSchema; // 节点输入参数类型
outputs: IJsonSchema; // 节点输出参数类型
}
}
# 范例
{
id: {random(6)},
type: 'code',
data: {
title: `代码`,
inputsValues: {
language: { // 脚本类型
type: 'constant',
content: 'python'
},
script: { // 脚本内容
type: 'constant',
content: ''
},
input_params: {
arg1: { // 输入参数1
type: 'constant',
content: ''
},
},
max_retries: { // 最大重试次数
type: 'constant',
content: 3,
},
retry_interval: { // 重试间隔
type: 'constant',
content: 1000,
},
},
inputs: {
type: 'object',
required: [],
properties: {
language: { type: 'string' },
script: { type: 'string' },
input_params: {
type: 'object',
properties: {
arg1: { type: 'string' },
},
},
max_retries: { type: 'number' };
retry_interval: { type: 'number' };
},
},
outputs: {
type: 'object',
properties: {
result: {
type: 'string',
},
},
},
},
}