The charm of Huawei Cloud API conversation robot CBS - If there were AI, I would be "Li Bai" - Develop a poetry-composing robot in 5 minutes

Cloud services, APIs, SDKs, debugging, viewing, I can do it all

By reading the short article, you can learn: artificial intelligence, emotional analysis of self-talk language, text segmentation, and text translation.

1 Introduction to the API plug-in of IntelliJ IDEA

The API plug-in supports VS Code IDE, IntelliJ IDEA and other platforms, as well as Huawei Cloud's self-developed CodeArts IDE. Based on the capabilities provided by Huawei Cloud services, it helps developers build applications more efficiently and conveniently. The API plug-in is associated with API Explorer, DevStar, CodeLabs, SDK Center, and CLI Center products under Huawei Cloud Services, and is committed to providing developers with a more stable, faster, and safer programming experience.

In this plug-in, we provide but are not limited to the following functions:

Connected to the Huawei Cloud API open platform, it supports users to retrieve APIs, view API documents, debug APIs, and provide SDK sample codes for users to learn how to use APIs.

Provides Huawei Cloud SDK code snippet completion function, and SDK dependency packages are automatically introduced to accelerate users' integration of Huawei Cloud APIs.

Connected to Huawei Cloud Development Experience Center Codelabs, it provides 500+ cloud service code examples and guided tutorials to help users learn quickly.

illustrate:

On a series of platforms such as IntelliJ IDEA and VS Code IDE, the name of the Huawei Cloud API plug-in is Huawei Cloud API. In CodeArts IDE, the API plug-in is natively built into the IDE, and its name is Huawei Cloud API Development Kit.

The use of API plug-ins on series platforms such as IntelliJ IDEA and VS Code IDE depends on the base plug-in. Please install the base plug-in in advance.

2 API plug-in installation--IntelliJ IDEA

2.1 IntelliJ IDEA and other platforms

Installation preparation: Download and install JDK1.8 or higher. Download and install IntelliJ IDEA 2020.2 or higher.

Note: The IntellIj platform also supports IDEs including Goland, Pycharm, etc. If you develop on other related IDEs, please download and configure the compiler or interpreter of the corresponding language. Here we take IDEA as an example to introduce the installation process of the IntelliJ platform plug-in. For other IntelliJ series IDEs, please refer to IDEA.

start installation:

You can download and install the offline package directly from the IDE plug-in market or directly from the JetBrains plug-in market.

https://developer.huaweicloud.com/develop/toolkit.html

IDE installation

  1. Select File > Settings in the top menu bar of IntelliJ IDEA, and click Plugins in the left navigation bar of the Settings dialog box.
  2. Click Marketplace in the Plugins area and enter Huawei Cloud API in the search bar.
  3. Huawei Cloud API will appear in the Search Results area, click Install, and restart the IDE after completion.

Offline package installation:

  1. Enter the plug-in market and search for Huawei Cloud API, enter the plug-in details page, select the desired version of the API plug-in under the Versions tab, and click Download to download the offline plug-in compressed package and save it locally. .
  2. Select File > Settings in the top menu bar of IntelliJ IDEA, and click Plugins in the left navigation bar of the Settings dialog box.
  3. Click in the Plugins area, and then click Install Plugin from Disk....
  4. Select the offline installation package (no need to decompress it) in the Choose Plugin File dialog box, and follow the prompts on the IntelliJ IDEA installation page to complete the subsequent installation steps.

Note: If the IntelliJ IDE you want to install the plug-in for is already open on the desktop, enter the plug-in market and search for Huawei Cloud API. Enter the plug-in details page. In the upper right corner, the locally opened IDE will be identified. Click the corresponding button. In the pop-up Click OK in the IDE window, and the IDE background will start to install the corresponding version of the API plug-in.

Installation verification: After successfully installing the plug-in on the IntelliJ series platform, you can see the Huawei Cloud Toolkit icon in the left navigation bar. Click on the back panel and the words Huawei Cloud API will appear, indicating that the installation is successful.

3 Use dialogue processes to build complex logic AI dialogue scenarios

3.1 Huawei Cloud API

Toolkit-Huawei Cloud

The API list is displayed on the left, and all APIs can be queried. Currently, there are 206 cloud services and APIs 9213.

3.2 If there was AI, I would be "Li Bai" - Develop a poetry writing robot in 5 minutes

Create a Huawei Cloud account and perform real-name authentication. Click the Browse Code button on the right to download the entire compressed data package to your local computer. After decompression, you can see the following three folders:

.

├── acrostic_dict.txt

├── poetry_demo.py

└── poetry_type_dict.txt

Create a trial version of the intelligent question and answer robot. Since skill management is a function of the professional version of the intelligent question and answer robot, first we need to purchase a trial version of the professional version of the question and answer robot. Click this link to enter the dialogue robot service intelligent question and answer robot page. Click Purchase Question and Answer Robot in the upper right corner to enter the question and answer robot purchase page.

Enter the name of the Q&A robot respectively, select the trial billing mode, and click Buy Now to complete the payment. This completes the creation of the trial professional version robot.

After the Q&A robot is successfully created, return to the main page of the conversation robot service. After waiting for the robot to be successfully created, click "Robot Name" to enter the robot. There will be a skill management in the tab bar on the left.

 

After the Q&A robot is successfully created, return to the main page of the conversation robot service. After waiting for the robot to be successfully created, click "Robot Name" to enter the robot. There will be a skill management in the tab bar on the left.

Create entity:

To add a poetry type entity, create an entity, click this link to enter the conversation robot service, click to enter the corresponding robot, click "Entity Management", then click the "Create Entity" button, and follow the guidance below to add a poetry type entity: https: // console.huaweicloud.com/cbs/?region=cn-north-4#/home/qa-robot

Dictionary annotation: POETRY_TYPE

Dictionary Name: Poetry Types

Click the "Confirm" button to create the dictionary and enter the "Edit" page.

Add term

Click the "Import Entries" button on the page, then click the "Add File" button, upload the poetry_type_dict.txt file in the local folder, select "Append" for the import mode, and finally click the "OK" button to complete the poetry type dictionary Entry import. As shown below:

After the import is successful, click "Build Dictionary" and you will see the following entries:

Add acrostic dictionary: Create dictionary

Click to enter this page, refer to the above method of creating a poetry type dictionary, and create an acrostic poetry dictionary. Click the "Create Dictionary" button and enter the "Edit" page. Fill in the content as follows: https://console.huaweicloud.com/cbs/?region=cn-north-4#/home/qa-robot

Dictionary logo: ACROSTIC

Dictionary name: Judgment of acrostic poems

Click the "Confirm" button.

Add term

After entering the "Edit" interface, click the "Import Term" button, click the "Add File" button, select the acrostic_dict.txt file in the local folder, select "Append" for the import mode, and finally click the "OK" button to complete the acronym. The poetry judgment dictionary entries are imported, as shown in the figure below:

After the import is complete, click "Build Dictionary". As shown below:

At this point, the two dictionaries have been created successfully. Return to the dictionary management page and click "Publish Dictionary", as shown in the following figure:

Skill configuration

In this section, we will add corpus and annotation, and configure the skills of the poetry-composing robot.

Click this link to enter the "Skill Management" of the dialogue robot service, create a new poetry writing skill and configure the skill.

Create skills

Click the "Add Skill" button, select "Multiple Rounds of Dialogue Skills", click Next, enter the skill name: Poetry Writing Skill, as shown in the figure below:

Create intent

After the skill is created, click to enter the poetry writing skill, click the "Create" button in the intention list, and fill in the instructions as shown below:

Intent flag: poem

Intent name: write poetry

Then click the "Confirm and continue setup" button to continue configuring the intent.

Add user question materials

Enter the "User Questioning Method" of the "poem" intention, click the blue font "Batch Add User Questioning Material" below the "User Questioning Material" input box, copy the corpus below to the pop-up dialog box, and click "Confirm" to complete the user Question method is expected to be imported.

Write a poem with the title of Autumn Thoughts

compose a poem

Write a five-character quatrain

write a poem

write a poem

Write a seven-character quatrain

Come up with a seven-character rhymed poem

Come up with a poem

Write a poem with white clouds

Write a five-character poem using Qiu Si

write me a poem

After adding the corpus, slide the page to the bottom and click "Save". The following results can be obtained:

Add slot

Scroll down the page, find the "Slot Management" page, and create three slots: poetryType (poetry type), poetryName (poem name), and acrostic (acrostic poem). The slot is the key piece of information that triggers the intent.

Then click the "Add Slot" button and follow the instructions below to add the poemType slot:

Associated slot: Not associated

Slot ID: poetryType

Slot name: poetryType

Is it necessary: ​​Yes

Number of questioning rounds: 1

Input box: What is the type of poetry?

Dictionary selection: POETRY_TYPE

Answer candidates: Check

Then click the "OK" button.

Click the "Add Slot" button again and follow the instructions below to add the poemName slot:

Associated slot: Not associated

Slot ID: poetryName

Slot name: poetryName

Is it necessary: ​​Yes

Number of questioning rounds: 1

Input box: What is the name of the poem?

Dictionary selection: sys.any

Answer candidates: Unchecked

Then click the "OK" button.

Click the "Add Slot" button again and follow the instructions below to add an acrostic slot:

Associated slot: Not associated

Slot ID: cangtou

Slot name: acrostic

Is it necessary: ​​Yes

Number of questioning rounds: 1

Input box: Do you need an acrostic poem?

Dictionary selection: ACROSTIC

Answer candidates: Unchecked

Then click the "OK" button.

After adding the three slots, slide the page to the bottom and click "Save". You can get the following list:

corpus annotation

Swipe up the page, return to "User Questions", and annotate the corpus in the "User Questions Materials" list.

Select the keyword, and then use the slot to mark the keyword. For example: seven character quatrains-poetryType, Qiu Si-poetryName.

After the annotation is completed, it will appear as shown below:

Add user question template

Click the "User Question Template" page in "User Question" to add a template.

Click the "Add Template" button. The template content is as shown in the figure below. Click the slot name below at the corresponding position to insert the corresponding slot. After completing the configuration, users can use the template's questions to talk to the robot.

Add the first template:

Add a second template:

After adding the two question templates, slide the page to the bottom and click "Save". You can see the following list:

Robot reply management

The configuration is called as a function through the poetry interface.

Create function

Scroll down the page to find the "Reply Management" page.

Select "Call Function Reply" and click the "Create New Function" button on the right to enter the function workflow console, as shown in the following figure:

In the function workflow console, click to enter "Function" - "Function List", and click the "Create Function" button in the upper right corner: https://console.huaweicloud.com/functiongraph/?region=cn-north-4# /serverless/functions

Follow the instructions below to fill in the parameters:

Template: use empty template

Function name:poem

Application: default

Delegation name: Do not use task delegation

Runtime language: Python3.6

Function execution entry: index.handler

Code upload method: online editing. Copy and paste the code in the poem_demo.py file in the local folder . Then fill in your real account name, username, and password. Then click "Deploy".

Note: You need to change the account name, user name, and password in the code to your real information (if it is the main account, the user name and account name are the same)

The main functions of the code: obtain slot information, call the poetry writing interface, and return the interface call result.

Finally click the "Create Function" button:

After successful creation, it will automatically jump to the function configuration page.

set function

To configure the timeout of the function, click the "Settings" tab, then change the execution timeout to 10, and click Save, as shown in the figure below:

Configure test cases

Click the "Configure Test Event" button in the "Please select a test event" drop-down box in the upper right corner, as shown in the figure below:

Fill in the test event input box: {"slots":{"poetryType":["Five Character Quatrains"],"poetryName":["Qiu Si"],"acrostic":["true"]}}, as follows As shown in the figure:

After saving the test event, click the "Test" button to view the test results. The test results are as follows:

Select function reply

Return to the poem intention management page, select the call function reply, and select the created function poem in the drop-down box, as shown in the following figure:

Then click the "Save" button at the bottom of the page to save all configuration information of the intent.

Model training release:

On the "Poetry Writing Skills" page, enter the "Publish Test" page, click the "Train Model" button, check "Users' Common Questions", and leave the skill threshold as default. Click "OK" to start model training, which takes about 3 minutes.

After the model training is completed, click the "Online Publish" button to publish the model.

3.3 Skill experience

After the model is released, return to the "Skill Management" page and click the "Conversation Experience" button in the upper right corner (the poetry type slot has been configured with open candidates, so users can automatically reply by clicking on the response type)

The picture below is a sample conversation:

congratulations:

Congratulations, you have completed the configuration of the skill robot using the CBS skills platform! Next, you can configure various skills for the robot based on different needs to achieve multi-round dialogue capabilities in different scenarios.

Next you can

Try other forms of multi-turn conversations with the poetry bot.

Try other features in the conversation bot service.

4 References

https://support.huaweicloud.com/usermanual-cbs/cbs_01_0029.html

https://console.huaweicloud.com/cbs/?region=cn-north-4#/cbs/management/skills

5 Experience the charm of plug-ins

Huawei Cloud devkit is now online: https://developer.huaweicloud.com/develop/toolkit.html

Guess you like

Origin blog.csdn.net/hwxiaozhi/article/details/133273588