Calling the Foundation Model Connector to Talk with the AI Assistant
Application Scenarios
When you build a standard page, you can connect to an external foundation model API via the AI assistant widget. First, set up the foundation model connection details in the connector, then choose that connector in the AI assistant widget.
This practice shows you how to configure the connector and use it in the widget for smart chat functionality.
Prerequisites
You have obtained or set up foundation model resources. This practice takes connecting to a self-built foundation model as an example.
Procedure
Figure 1 shows how to set up a foundation model connector and use it with the AI assistant widget to talk with the AI assistant.
Step 1: Create a Foundation Model Connector to Connect to an External Foundation Model
Create a foundation model connector to connect to an external foundation model API.
- Create a low-code application.
- Apply for a free trial or purchase a commercial instance by referring to Authorization of Users for Huawei Cloud Astro Zero Usage and Instance Purchases.
- After you have an instance, click Access Homepage on Homepage. The application development page is displayed.
- In the navigation pane, choose Applications. On the displayed page, click Low-Code or
.
When you create an application for the first time, create a namespace as prompted. Once it is created, you cannot change or delete it, so check the details carefully. Use your company or team's abbreviation for the namespace. Enter up to 15 characters. Use only letters, digits, and underscores (_). Start with a letter and end with a letter or digit. Do not enter consecutive underscores.
- In the displayed dialog box, choose Standard Applications and click the confirm button.
- Enter a label and name of the application, and click the confirm button. The application designer is displayed.
Figure 2 Creating a blank application
- Create a foundation model connector.
- In the application designer, choose Integrations > Connector > Connector Instance.
- Choose Foundation Model > Custom Model and click +. The page for creating a custom foundation model connector is displayed.
Figure 3 Creating a custom foundation model connector
- Enter and save the configuration information of the foundation model connector.
Figure 4 Setting foundation model connector information
- Test the connectivity of the foundation model connector.
- On the custom foundation model details page, click Test. On the displayed dialog box, click Test. The foundation model connector test page is displayed.
- In the Input Content text box, enter the dialog content (for example, "Hello"), and click Test. Check whether the returned message is correct.
If the returned message contains the streaming response packet, the foundation model connector is configured successfully. Otherwise, check whether the foundation model connector information is correct.Figure 5 Foundation model connector test page
Step 2: Create an AI Assistant Page and Add the Foundation Model Connector to the Page
In the AI assistant template application, create a standard page for assembling the dialog page of the AI assistant template.
- In the navigation pane, choose Page.
- Click
next to the page, set the basic information about the standard page, and click Create.
Figure 6 Creating a standard page - Drag the AI Assistant widget from Basic > Smart to the canvas.
Figure 7 Dragging the AI Assistant widget to the page
- Click the AI assistant widget, choose Properties > Advanced Properties, and enable Show Model.
- Click Set Default Model next to Default Model and select the model connector created in Step 1: Create a Foundation Model Connector to Connect to an External Foundation Model.
Figure 8 Advanced settings of the AI assistant widget
- Click
in the upper part of the page to save the standard page.
Step 3: Verify the Chat Function of the AI Assistant
Preview the AI assistant page in the AI assistant template application and verify the chat function of the AI assistant.
- On the saved standard page, click
. The preview page is displayed.
Figure 9 Preview page of the AI assistant - In the AI assistant chat box, type something like "How is the weather today?" and click Send.
If the AI assistant returns the corresponding streaming result, the AI assistant widget is successfully connected to the external foundation model API.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot