API plugin use cases in large models
This topic describes how to use an API plugin for Alibaba Cloud Outbound Bot in a large model scenario.
Prerequisites
The Function Compute service is activated for your main account.
In your Alibaba Cloud Outbound Bot instance, go to System Management > Service Authorization Configuration. Use your main account to grant permissions to the Function Compute service by using RAM access control.

Configure an API plugin
Access the feature
In the left-side navigation pane of the console, choose Large Model Scenario Management > Global Configuration. On the Global Configuration page, click the API plugin tab.
Create an API plugin
Click New API plugin. A configuration pane appears on the right.

Enter a custom API service name, description, and invocation prompt. Note: To improve model recognition, provide details that accurately describe the plugin's actual purpose.
Service Name: Can contain only letters, digits, and underscores (_), and cannot start with a digit.
Service Description: A brief description of the purpose of the API service.
Invocation Prompt: The message to play if the API call is delayed.
This example configures a plugin to query phone number locations.

Function selection
Click Function Management to go to the Function Compute service console.


In the Function Compute console, click Create Function and select Event-triggered function.

In this example, create an event-triggered function named
Get_phoneLocation. For the runtime, select Built-in Runtimes/Python/Python 3.10 and use the sample code for handling HTTP requests. Then, click Create.
In the built-in editor, configure a sample request to get the location of a phone number:

After adding your code, click Deploy Code.

Test the function to verify that the code runs correctly.
Click the arrow next to the Test Function button and select a test method based on your needs. In this example, select Configure Test Parameters.

Edit the test parameters.

After configuring the parameters, click Test Function to view the execution status and results. If the code runs successfully and returns the expected result, the function is configured correctly.

After configuring the function in Function Compute, return to the Create API plugin page and configure the Function Selection section.
Region: Select the region where you created the Function Compute service. This example uses China (Shanghai).

Function Name: Must match the function name in the Function Compute service. In this example, the name is
Get_phoneLocation.Standby Region: (Optional) Select a standby region. This field is empty by default.
HTTP service: Configure the API call. You can specify a request URL, a GET or POST method, and header parameters.

Input parameters:

The input parameters must match those required by your code in Function Compute. For each parameter, configure its value source, description, and specify if it is required. The value source can be a variable or model recognition. In this example, the parameter is
phone, its type isString, and the value source is set to model recognition.If you need multiple parameters, click Add Parameter and configure them as described above.
Output parameters are system-defined and cannot be modified.
You can also configure the invocation timeout. If the API response time exceeds this limit, the call is terminated. This example uses the default of 5 seconds.
After you finish the configuration, click Confirm.

Test the plugin
Click the Test button. Enter a debug value to check the query result and verify the call to the Function Compute service.

Edit an API plugin
Click the Edit button to open the API plugin editing pane on the right.
Test environment
You can edit the API plugin in its draft version. To revert your changes, click Reset to Published Version.
Production environment
In the production environment, you cannot edit the plugin's content. You can only configure mock values for debugging.
Publish an API plugin
After you create or edit an API plugin, it is in the draft or Published (Edited) state. Your changes do not take effect in the large model scenario until they are published. To apply them, click Publish.
Using API plugins in large models
Access the feature
In the console, choose Large Model Scenario Management > Scenario Management. In the Large Model Scenario List, select a scenario. In this example, select Large Model Interface Test.
Bind an API plugin
After entering a large model scenario, click Select API plugin and choose the plugin you want to add.

After the plugin is added, you can view it in the list of bound API plugins.
Once bound, you can insert the API plugin into a specific location in the prompt.

After inserting the plugin, click Save to complete the bot configuration.
Test results












