API plugin use cases in large models

Updated at:

This topic describes how to use an API plugin for Alibaba Cloud Outbound Bot in a large model scenario.

Prerequisites

  1. The Function Compute service is activated for your main account.

  2. 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.image

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.image

Create an API plugin

  1. Click New API plugin. A configuration pane appears on the right.image

  2. 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.image

  3. Function selection

    • Click Function Management to go to the Function Compute service console.imageimage

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

      • 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.image

      • In the built-in editor, configure a sample request to get the location of a phone number:image

      • After adding your code, click Deploy Code.image

      • 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.image

        • Edit the test parameters.image

        • 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.image

    • 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).image

      • 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.image

  4. Input parameters:image

    • 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 is String, and the value source is set to model recognition.

    • If you need multiple parameters, click Add Parameter and configure them as described above.

  5. Output parameters are system-defined and cannot be modified.

  6. 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.

  7. After you finish the configuration, click Confirm.image

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.imageimage

Edit an API plugin

Click the Edit button to open the API plugin editing pane on the right.image

Test environment

You can edit the API plugin in its draft version. To revert your changes, click Reset to Published Version.image

Production environment

In the production environment, you cannot edit the plugin's content. You can only configure mock values for debugging.image

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.image

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.image

Bind an API plugin

After entering a large model scenario, click Select API plugin and choose the plugin you want to add.

image

After the plugin is added, you can view it in the list of bound API plugins.image

Once bound, you can insert the API plugin into a specific location in the prompt.imageimage

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

Test results

image