Skip to main content

Use the Function Compute node

This document describes how to use the Function Compute node.

To better support diverse orchestration needs, the flow orchestration feature has been upgraded to workflow applications and agent orchestration applications. The flow orchestration feature will be gradually discontinued. This change does not affect existing users of the flow orchestration feature. You can continue to use the flow orchestration feature or switch to workflow applications or agent orchestration applications for an improved experience. For more information, see workflow applications and agent orchestration applications.

Node interface

image

Node description

Alibaba Cloud Model Studio provides a Function Compute node that uses Alibaba Cloud Function Compute (FC) to provide developers with advanced code development capabilities. After you grant authorization, the node uses a service-linked role to retrieve your function list and call specified functions. This lets you run custom code within your flow.

Authorization

If Function Compute is not authorized, the Function Compute node is grayed out and you cannot drag it. You must grant authorization first.
image
Click Authorize. The authorization description appears.
image
After you grant authorization, you can drag the Function Compute node.
image
For more information about service-linked roles and how to delete them, see Service-linked Role.

Configuration page

Function node configuration
image

As shown in the preceding figure, region is the region where your Function Compute service is located. Currently, only the Hangzhou and Beijing regions are supported. When you switch the region, the Function Name list displays all function names in the new region. Select the function that you want to call. Input Parameter Settings is used to pass parameters for a function invocation. For example, as shown in the figure, Function Compute requires two parameters: cityParam and dateParam. To pass the city and date request parameters to the corresponding function parameters, configure them as shown in the figure. Output Parameter Settings is used to define the key for the Function Compute result in the result set. This allows subsequent nodes to easily retrieve the result. For more information about how to retrieve input and output parameter values, see Description and retrieval of flow variables.

Create and use a Function Compute function

Create an event function in Function Compute. This function type is integrated with the Function Compute node to simplify parameter passing.
image
Take the hello world sample code as an example. The following figure shows the code, which prints the event parameter.
image
Make a call from the Alibaba Cloud Model Studio flow debugger. Pass two parameters: cityParam set to Hangzhou and dateParam set to 2024-01-26. After the call, the result hello world is returned.
image
View the Function Compute logs. The current event is output. The cityParam and dateParam parameters are passed to Function Compute as a dictionary (dict). This allows Function Compute to use intermediate results from the large model flow.
image

Function Compute response parameters

The output of Function Compute calls is converted to a string. This can make it difficult to retrieve values from complex objects in subsequent nodes. To resolve this issue, Alibaba Cloud Model Studio transforms the results from Function Compute. If the result is a dict, map, or list, it is converted to an object in the global variables. For example, if Function Compute returns {"a":"1","b":"2"}, Model Studio converts this JSON string to an object: {"a":"1","b":"2"}. To retrieve the value of a, you can use the expression svcVars.{function_compute_id}.{result_key}.a. For more information about the specific logic for retrieving values, see Description and retrieval of flow variables.
Token Plan
Model Playground
Fine-tuning
Model Compression
Statistics and Monitoring
Support