Skip to main content

Use script nodes

This topic describes how to use script nodes.

The flow orchestration feature has been upgraded to workflow applications and agent orchestration applications to support more diverse orchestration needs. The flow orchestration feature will be gradually phased out. This change does not affect existing users. You can continue to use flow orchestration or switch to workflow applications or agent orchestration applications for a better experience. For more information, see Workflow applications and Agent orchestration applications.

Node interface

Go to Application Center > Flow Orchestration > New Flow and click Script Node.
image

Node description

A script node provides simple code development capabilities for developers. The code runs on a free Function Compute instance in your account. It currently supports JavaScript and Python. The code within a script node is encapsulated in a function. A return statement is used to output the function's result, which can be used in subsequent steps.

Configuration page

image

Configuration description

Script Type

Supported types: JavaScript and Python.

Return variable name

You can specify the name of the variable returned by the function body. If you do not specify a name, the default name is fcResult. For example,
{
    "svcVars":{
        "Script_szLxMn":{ // The ID of the script node.
            "response":{ // A fixed response field.
                "temp":[ // The name of the declared return variable. The default value is scriptResult.
                    "a",
                    " ",
                    "c"
                ]
            }
        }
    }
}

Sample scripts

You can enter a code snippet in a script node. The code is encapsulated and executed in a function. Therefore, the script must return the results as variables at the end, and the variables can be used in the subsequent process.

Sample JavaScript code

const a = 1;
const b = a+2;
return a;

Sample Python code

import json
import logging
json_string = svcVars['LLM_ae4fzv']['response']['text']
data = json.loads(json_string)
prefix_str = 'Tmall Genie will play for you'
media_name = data['mediaName']
singer_name = data['singerName']
return f"{prefix_str} {media_name} by {singer_name}. To listen to the full version, download the Tmall Genie app."
Token Plan
Model Playground
Fine-tuning
Model Compression
Statistics and Monitoring
Support