Skip to content

Commit 1609693

Browse files
Merge pull request #103011 from diberry/diberry/0131-fresh-1
[Cogsvcs] LUIS - quickstarts - fresh - 1
2 parents df37d4b + 8414e10 commit 1609693

12 files changed

+386
-362
lines changed

articles/cognitive-services/LUIS/includes/get-key-quickstart.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@ services: cognitive-services
55
author: diberry
66
manager: nitinme
77
ms.service: cognitive-services
8-
ms.topic: include
8+
ms.topic: include
99
ms.date: 11/20/2019
1010
ms.author: diberry
1111
---
1212

13-
Keys and endpoints are provided in the LUIS portal in the **Manage Section** on the **Azure Resources** page.
14-
15-
1. Sign in to the [LUIS portal](https://preview.luis.ai/).
13+
Keys and endpoints are provided in the LUIS portal in the **Manage Section** on the **Azure Resources** page.
14+
15+
1. Sign in to the [LUIS portal](https://preview.luis.ai/).
1616
1. Create a new app, or select an existing app from the apps list.
17-
1. Select **Manage** then select **Azure Resources**.
18-
1. Copy the values for the key and endpoint for the Starter resource. You'll need these to run the sample below.
17+
1. Select **Manage** then select **Azure Resources**.
18+
1. Copy the values for the key and endpoint for the authoring resource. You'll need these to run the sample below.
1919
> [!NOTE]
20-
> The **Starter** key allows free requests to the authoring API and up to 1000 queries to the prediction endpoint API per month for all your LUIS apps.
20+
> The **Starter** key allows free requests to the authoring API and up to 1000 queries to the prediction endpoint API per month for all your LUIS apps.

articles/cognitive-services/LUIS/includes/get-started-get-intent-rest-csharp.md

Lines changed: 43 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ services: cognitive-services
55
author: diberry
66
manager: nitinme
77
ms.service: cognitive-services
8-
ms.topic: include
9-
ms.date: 11/20/2019
8+
ms.topic: include
9+
ms.date: 01/31/2020
1010
ms.author: diberry
1111
---
1212

@@ -16,79 +16,92 @@ ms.author: diberry
1616
* [Visual Studio Code](https://code.visualstudio.com/)
1717
* Public app ID: `df67dcdb-c37d-46af-88e1-8b97951ca1c2`
1818

19-
## Get LUIS key
19+
## Create LUIS runtime key for predictions
2020

21-
[!INCLUDE [Use authoring key for endpoint](../includes/get-key-quickstart.md)]
21+
1. Sign into the [Azure portal](https://portal.azure.com)
22+
1. Click [Create **Language Understanding**](https://ms.portal.azure.com/#create/Microsoft.CognitiveServicesLUISAllInOne)
23+
1. Enter all required settings for Runtime key:
24+
25+
|Setting|Value|
26+
|--|--|
27+
|Name|Desired name (2-64 characters)|
28+
|Subscription|Select appropriate subscription|
29+
|Location|Select any nearby and available location|
30+
|Pricing Tier|`F0` - the minimal pricing tier|
31+
|Resource Group|Select an available resource group|
32+
33+
1. Click **Create** and wait for the resource to be created. After it is created, navigate to the resource page.
34+
1. Collect configured `endpoint` and a `key`.
2235

2336
## Get intent programmatically
2437

2538
Use C# (.NET Core) to query the [prediction endpoint](https://aka.ms/luis-apim-v3-prediction) and get a prediction result.
2639

27-
1. Create a new console application targeting the C# language, with a project and folder name of `predict-with-rest`.
40+
1. Create a new console application targeting the C# language, with a project and folder name of `predict-with-rest`.
2841

2942
```console
3043
dotnet new console -lang C# -n predict-with-rest
3144
```
3245

33-
1. Change to the `predict-with-rest` directory you just created, and install required dependencies with these commands:
46+
1. Change to the `predict-with-rest` directory you just created, and install required dependencies with these commands:
3447

3548
```console
3649
cd predict-with-rest
3750
dotnet add package System.Net.Http
3851
```
3952

4053
1. Open `Program.cs` in your favorite IDE or editor. Then overwrite `Program.cs` with the following code:
41-
54+
4255
```csharp
4356
using System;
4457
using System.Net.Http;
4558
using System.Web;
46-
59+
4760
namespace predict_with_rest
4861
{
4962
class Program
5063
{
5164
static void Main(string[] args)
5265
{
53-
// YOUR-KEY: for example, the starter key
66+
// YOUR-KEY: 32 character key
5467
var key = "YOUR-KEY";
55-
56-
// YOUR-ENDPOINT: example is westus2.api.cognitive.microsoft.com
68+
69+
// YOUR-ENDPOINT: example is your-resource-name.api.cognitive.microsoft.com
5770
var endpoint = "YOUR-ENDPOINT";
5871

5972
// //public sample app
60-
var appId = "df67dcdb-c37d-46af-88e1-8b97951ca1c2";
61-
73+
var appId = "df67dcdb-c37d-46af-88e1-8b97951ca1c2";
74+
6275
var utterance = "turn on all lights";
63-
76+
6477
MakeRequest(key, endpoint, appId, utterance);
65-
78+
6679
Console.WriteLine("Hit ENTER to exit...");
6780
Console.ReadLine();
6881
}
6982
static async void MakeRequest(string key, string endpoint, string appId, string utterance)
7083
{
7184
var client = new HttpClient();
7285
var queryString = HttpUtility.ParseQueryString(string.Empty);
73-
86+
7487
// The request header contains your subscription key
7588
client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", key);
76-
89+
7790
// The "q" parameter contains the utterance to send to LUIS
7891
queryString["query"] = utterance;
79-
92+
8093
// These optional request parameters are set to their default values
8194
queryString["verbose"] = "true";
8295
queryString["show-all-intents"] = "true";
8396
queryString["staging"] = "false";
8497
queryString["timezoneOffset"] = "0";
85-
98+
8699
var endpointUri = String.Format("https://{0}/luis/prediction/v3.0/apps/{1}/slots/production/predict?query={2}", endpoint, appId, queryString);
87-
100+
88101
var response = await client.GetAsync(endpointUri);
89-
102+
90103
var strResponseContent = await response.Content.ReadAsStringAsync();
91-
104+
92105
// Display the JSON result from LUIS
93106
Console.WriteLine(strResponseContent.ToString());
94107
}
@@ -97,12 +110,14 @@ Use C# (.NET Core) to query the [prediction endpoint](https://aka.ms/luis-apim-v
97110

98111
```
99112

100-
1. Replace the following values:
113+
1. Replace the `YOUR-KEY` and `YOUR-ENDPOINT` values with your own prediction key and endpoint.
101114

102-
* `YOUR-KEY` with your starter key.
103-
* `YOUR-ENDPOINT` with your endpoint. For example, `westus2.api.cognitive.microsoft.com`.
115+
|Information|Purpose|
116+
|--|--|
117+
|`YOUR-KEY`|Your 32 character prediction key.|
118+
|`YOUR-ENDPOINT`| Your prediction URL endpoint. For example, `replace-with-your-resource-name.api.cognitive.microsoft.com`.|
104119

105-
1. Build the console application with this command:
120+
1. Build the console application with this command:
106121

107122
```console
108123
dotnet build
@@ -121,7 +136,7 @@ Use C# (.NET Core) to query the [prediction endpoint](https://aka.ms/luis-apim-v
121136
{'query': 'turn on all lights', 'prediction': {'topIntent': 'HomeAutomation.TurnOn', 'intents': {'HomeAutomation.TurnOn': {'score': 0.5375382}, 'None': {'score': 0.08687421}, 'HomeAutomation.TurnOff': {'score': 0.0207554}}, 'entities': {'HomeAutomation.Operation': ['on'], '$instance': {'HomeAutomation.Operation': [{'type': 'HomeAutomation.Operation', 'text': 'on', 'startIndex': 5, 'length': 2, 'score': 0.724984169, 'modelTypeId': -1, 'modelType': 'Unknown', 'recognitionSources': ['model']}]}}}}
122137
```
123138

124-
The JSON response formatted for readability:
139+
The JSON response formatted for readability:
125140

126141
```JSON
127142
{
@@ -164,13 +179,9 @@ Use C# (.NET Core) to query the [prediction endpoint](https://aka.ms/luis-apim-v
164179
}
165180
```
166181

167-
## LUIS keys
168-
169-
[!INCLUDE [Use authoring key for endpoint](../includes/starter-key-explanation.md)]
170-
171182
## Clean up resources
172183

173-
When you are finished with this quickstart, delete the file from the file system.
184+
When you are finished with this quickstart, delete the file from the file system.
174185

175186
## Next steps
176187

articles/cognitive-services/LUIS/includes/get-started-get-intent-rest-go.md

Lines changed: 44 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,43 @@ services: cognitive-services
55
author: diberry
66
manager: nitinme
77
ms.service: cognitive-services
8-
ms.topic: include
9-
ms.date: 11/20/2019
8+
ms.topic: include
9+
ms.date: 01/31/2020
1010
ms.author: diberry
1111
---
1212

1313
## Prerequisites
1414

15-
* [Go](https://golang.org/) programming language
15+
* [Go](https://golang.org/) programming language
1616
* [Visual Studio Code](https://code.visualstudio.com/)
1717
* Public app ID: `df67dcdb-c37d-46af-88e1-8b97951ca1c2`
1818

19-
## Get LUIS key
19+
## Create LUIS runtime key for predictions
2020

21-
[!INCLUDE [Use authoring key for endpoint](../includes/get-key-quickstart.md)]
21+
1. Sign into the [Azure portal](https://portal.azure.com)
22+
1. Click [Create **Language Understanding**](https://ms.portal.azure.com/#create/Microsoft.CognitiveServicesLUISAllInOne)
23+
1. Enter all required settings for Runtime key:
24+
25+
|Setting|Value|
26+
|--|--|
27+
|Name|Desired name (2-64 characters)|
28+
|Subscription|Select appropriate subscription|
29+
|Location|Select any nearby and available location|
30+
|Pricing Tier|`F0` - the minimal pricing tier|
31+
|Resource Group|Select an available resource group|
32+
33+
1. Click **Create** and wait for the resource to be created. After it is created, navigate to the resource page.
34+
1. Collect configured `endpoint` and a `key`.
2235

2336
## Get intent programmatically
2437

2538
Use Go to query the [prediction endpoint](https://aka.ms/luis-apim-v3-prediction) and get a prediction result.
2639

2740
1. Create a new file named `predict.go`. Add the following code:
28-
41+
2942
```go
3043
package main
31-
44+
3245
/* Do dependencies */
3346
import (
3447
"fmt"
@@ -38,65 +51,67 @@ Use Go to query the [prediction endpoint](https://aka.ms/luis-apim-v3-prediction
3851
"log"
3952
)
4053
func main() {
41-
54+
4255
// public app
4356
var appID = "df67dcdb-c37d-46af-88e1-8b97951ca1c2"
44-
57+
4558
// utterance for public app
4659
var utterance = "turn on all lights"
47-
48-
// YOUR-KEY - your starter or prediction key
60+
61+
// YOUR-KEY - your key
4962
var endpointKey = "YOUR-KEY"
50-
51-
// YOUR-ENDPOINT - example is westus2.api.cognitive.microsoft.com
63+
64+
// YOUR-ENDPOINT - example is your-resource-name.api.cognitive.microsoft.com
5265
var endpoint = "YOUR-ENDPOINT"
53-
66+
5467
endpointPrediction(appID, endpointKey, endpoint, utterance)
5568
}
5669
func endpointPrediction(appID string, endpointKey string, endpoint string, utterance string) {
57-
70+
5871
var endpointUrl = fmt.Sprintf("https://%s/luis/prediction/v3.0/apps/%s/slots/production/predict?subscription-key=%s&verbose=true&show-all-intents=true&query=%s", endpoint, appID, endpointKey, url.QueryEscape(utterance))
59-
72+
6073
response, err := http.Get(endpointUrl)
61-
74+
6275
if err!=nil {
6376
// handle error
6477
fmt.Println("error from Get")
6578
log.Fatal(err)
6679
}
67-
80+
6881
response2, err2 := ioutil.ReadAll(response.Body)
69-
82+
7083
if err2!=nil {
7184
// handle error
7285
fmt.Println("error from ReadAll")
7386
log.Fatal(err2)
7487
}
75-
88+
7689
fmt.Println("response")
7790
fmt.Println(string(response2))
7891
}
7992
```
8093

81-
1. Replace the following values:
94+
1. Replace the `YOUR-KEY` and `YOUR-ENDPOINT` values with your own prediction key and endpoint.
8295

83-
* `YOUR-KEY` with your starter key.
84-
* `YOUR-ENDPOINT` with your endpoint. For example, `westus2.api.cognitive.microsoft.com`.
96+
|Information|Purpose|
97+
|--|--|
98+
|`YOUR-KEY`|Your 32 character prediction key.|
99+
|`YOUR-ENDPOINT`| Your prediction URL endpoint. For example, `replace-with-your-resource-name.api.cognitive.microsoft.com`.|
85100

86101
1. With a command prompt in the same directory as where you created the file, enter the following command to compile the Go file:
87102

88103
```console
89104
go build predict.go
90-
```
105+
```
91106

92-
1. Run the Go application from the command line by entering the following text in the command prompt:
107+
1. Run the Go application from the command line by entering the following text in the command prompt:
93108

94109
```console
95110
go run predict.go
96111
```
97-
98-
The command prompt response is:
99-
112+
113+
The command prompt response is:
114+
100115
```console
101116
appID has value df67dcdb-c37d-46af-88e1-8b97951ca1c2
102117
endpointKey has value a7b206911f714e71a1ddae36928a61cc
@@ -150,13 +165,9 @@ Use Go to query the [prediction endpoint](https://aka.ms/luis-apim-v3-prediction
150165
```
151166

152167

153-
## LUIS keys
154-
155-
[!INCLUDE [Use authoring key for endpoint](../includes/starter-key-explanation.md)]
156-
157168
## Clean up resources
158169

159-
When you are finished with this quickstart, delete the file from the file system.
170+
When you are finished with this quickstart, delete the file from the file system.
160171

161172
## Next steps
162173

0 commit comments

Comments
 (0)