Skip to content

Commit 93129b7

Browse files
Merge pull request #116468 from diberry/diberry/0522-fresh-1
[Cogsvcs] LUIS - fresh - May -1
2 parents ff4e4c4 + 9d43aa6 commit 93129b7

File tree

3 files changed

+20
-109
lines changed

3 files changed

+20
-109
lines changed

articles/cognitive-services/LUIS/includes/sdk-csharp-authoring.md

Lines changed: 14 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ author: diberry
66
manager: nitinme
77
ms.service: cognitive-services
88
ms.subservice: language-understanding
9-
ms.date: 02/14/2020
9+
ms.date: 05/26/2020
1010
ms.topic: include
1111
ms.custom: include file
1212
ms.author: diberry
@@ -23,55 +23,13 @@ Use the Language Understanding (LUIS) authoring client library for .NET to:
2323

2424
## Prerequisites
2525

26-
* Language Understanding (LUIS) portal account - [Create one for free](https://www.luis.ai)
26+
* Azure subscription - [Create one for free](https://azure.microsoft.com/free/)
2727
* The current version of [.NET Core](https://dotnet.microsoft.com/download/dotnet-core).
28-
28+
* Once you have your Azure subscription, [create a Language Understanding authoring resource](https://ms.portal.azure.com/#create/Microsoft.CognitiveServicesLUISAllInOne) in the Azure portal to get your key and endpoint. Wait for it to deploy and click the **Go to resource** button.
29+
* You will need the key and endpoint from the resource you [create](../luis-how-to-azure-subscription.md#create-luis-resources-in-azure-portal) to connect your application to Language Understanding authoring. You'll paste your key and endpoint into the code below later in the quickstart. You can use the free pricing tier (`F0`) to try the service.
2930

3031
## Setting up
3132

32-
### Get your Language Understanding (LUIS) starter key
33-
34-
Get your [starter key](../luis-how-to-azure-subscription.md#starter-key) by creating a LUIS authoring resource. Keep your key, and the region of the key for the next step.
35-
36-
### Create an environment variable
37-
38-
Using your key, and the region for the key, create two environment variables for authentication:
39-
40-
* `COGNITIVESERVICE_AUTHORING_KEY` - The resource key for authenticating your requests.
41-
* `COGNITIVESERVICE_REGION` - The region associated with your key. For example `westus`.
42-
43-
Use the instructions for your operating system.
44-
45-
#### [Windows](#tab/windows)
46-
47-
```console
48-
setx COGNITIVESERVICE_AUTHORING_KEY <replace-with-your-authoring-key>
49-
setx COGNITIVESERVICE_REGION <replace-with-your-authoring-region>
50-
```
51-
52-
After you add the environment variable, restart the console window.
53-
54-
#### [Linux](#tab/linux)
55-
56-
```bash
57-
export COGNITIVESERVICE_AUTHORING_KEY=<replace-with-your-authoring-key>
58-
export COGNITIVESERVICE_REGION=<replace-with-your-authoring-region>
59-
```
60-
61-
After you add the environment variable, run `source ~/.bashrc` from your console window to make the changes effective.
62-
63-
#### [macOS](#tab/unix)
64-
65-
Edit your `.bash_profile`, and add the environment variable:
66-
67-
```bash
68-
export COGNITIVESERVICE_AUTHORING_KEY=<replace-with-your-authoring-key>
69-
export COGNITIVESERVICE_REGION=<replace-with-your-authoring-region>
70-
```
71-
72-
After you add the environment variable, run `source .bash_profile` from your console window to make the changes effective.
73-
***
74-
7533
### Create a new C# application
7634

7735
Create a new .NET Core application in your preferred editor or IDE.
@@ -142,23 +100,17 @@ These code snippets show you how to do the following with the Language Understan
142100

143101
From the project directory, open the *Program.cs* file in your preferred editor or IDE. Replace the existing `using` code with the following `using` directives:
144102

145-
[!code-csharp[Using statements](~/cognitive-services-dotnet-sdk-samples/documentation-samples/quickstarts/LUIS/LUIS.cs?name=Dependencies)]
103+
[!code-csharp[Using statements](~/cognitive-services-quickstart-code/dotnet/LanguageUnderstanding/authoring/authoring-with-sdk.cs?name=Dependencies)]
146104

147105
## Authenticate the client
148106

149-
1. Create a variable to manage your authoring key pulled from an environment variable named `COGNITIVESERVICES_AUTHORING_KEY`. If you created the environment variable after the application is launched, the editor, IDE, or shell running it will need to be closed and reloaded to access the variable. The methods will be created later.
150-
151-
1. Create variables to hold your authoring region and endpoint. The region of your authoring key depends on where you are authoring. The [three authoring regions](../luis-reference-regions.md) are:
152-
153-
* Australia - `australiaeast`
154-
* Europe - `westeurope`
155-
* U.S. and other regions - `westus` (Default)
107+
1. Create a variable to hold your authoring key and authoring endpoint.
156108

157-
[!code-csharp[Authorization to resource key](~/cognitive-services-dotnet-sdk-samples/documentation-samples/quickstarts/LUIS/LUIS.cs?name=Variables)]
109+
[!code-csharp[Authorization to resource key](~/cognitive-services-quickstart-code/dotnet/LanguageUnderstanding/authoring/authoring-with-sdk.cs?name=Variables)]
158110

159111
1. Create an [ApiKeyServiceClientCredentials](https://docs.microsoft.com/dotnet/api/microsoft.azure.cognitiveservices.language.luis.authoring.apikeyserviceclientcredentials?view=azure-dotnet) object with your key, and use it with your endpoint to create an [LUISAuthoringClient](https://docs.microsoft.com/dotnet/api/microsoft.azure.cognitiveservices.language.luis.authoring.luisauthoringclient?view=azure-dotnet) object.
160112

161-
[!code-csharp[Create LUIS client object](~/cognitive-services-dotnet-sdk-samples/documentation-samples/quickstarts/LUIS/LUIS.cs?name=AuthoringCreateClient)]
113+
[!code-csharp[Create LUIS client object](~/cognitive-services-quickstart-code/dotnet/LanguageUnderstanding/authoring/authoring-with-sdk.cs?name=AuthoringCreateClient)]
162114

163115
## Create a LUIS app
164116

@@ -168,14 +120,14 @@ From the project directory, open the *Program.cs* file in your preferred editor
168120

169121
1. Call the [Apps.AddAsync](https://docs.microsoft.com/dotnet/api/microsoft.azure.cognitiveservices.language.luis.authoring.appsextensions.addasync?view=azure-dotnet) method. The response is the app ID.
170122

171-
[!code-csharp[Create a LUIS app](~/cognitive-services-dotnet-sdk-samples/documentation-samples/quickstarts/LUIS/LUIS.cs?name=AuthoringCreateApplication)]
123+
[!code-csharp[Create a LUIS app](~/cognitive-services-quickstart-code/dotnet/LanguageUnderstanding/authoring/authoring-with-sdk.cs?name=AuthoringCreateApplication)]
172124

173125
## Create intent for the app
174126
The primary object in a LUIS app's model is the intent. The intent aligns's with a grouping of user utterance _intentions_. A user may ask a question, or make a statement looking for a particular _intended_ response from a bot (or other client application). Examples of intentions are booking a flight, asking about weather in a destination city, and asking about contact information for customer service.
175127

176128
Create a [ModelCreateObject](https://docs.microsoft.com/dotnet/api/microsoft.azure.cognitiveservices.language.luis.authoring.models.modelcreateobject?view=azure-dotnet) with the name of the unique intent then pass the app ID, version ID, and the ModelCreateObject to the [Model.AddIntentAsync](https://docs.microsoft.com/dotnet/api/microsoft.azure.cognitiveservices.language.luis.authoring.modelextensions.addintentasync?view=azure-dotnet) method. The response is the intent ID.
177129

178-
[!code-csharp[Create intent](~/cognitive-services-dotnet-sdk-samples/documentation-samples/quickstarts/LUIS/LUIS.cs?name=AuthoringAddIntents)]
130+
[!code-csharp[Create intent](~/cognitive-services-quickstart-code/dotnet/LanguageUnderstanding/authoring/authoring-with-sdk.cs?name=AuthoringAddIntents)]
179131

180132
## Create entities for the app
181133

@@ -187,7 +139,7 @@ It is important to know that entities are not marked with an intent. They can an
187139

188140
Creation methods for entities are part of the [Model](https://docs.microsoft.com/dotnet/api/microsoft.azure.cognitiveservices.language.luis.authoring.modelextensions?view=azure-dotnet) class. Each entity type has its own data transformation object (DTO) model, usually containing the word `model` in the [Models](https://docs.microsoft.com/dotnet/api/microsoft.azure.cognitiveservices.language.luis.authoring.models?view=azure-dotnet) namespace.
189141

190-
[!code-csharp[Create entities](~/cognitive-services-dotnet-sdk-samples/documentation-samples/quickstarts/LUIS/LUIS.cs?name=AuthoringAddEntities)]
142+
[!code-csharp[Create entities](~/cognitive-services-quickstart-code/dotnet/LanguageUnderstanding/authoring/authoring-with-sdk.cs?name=AuthoringAddEntities)]
191143

192144
## Add example utterance to intent
193145

@@ -197,7 +149,7 @@ Add example utterances by creating a list of [ExampleLabelObject](https://docs.m
197149

198150
Call [Examples.BatchAsync](https://docs.microsoft.com/dotnet/api/microsoft.azure.cognitiveservices.language.luis.authoring.examplesextensions.batchasync?view=azure-dotnet#Microsoft_Azure_CognitiveServices_Language_LUIS_Authoring_ExamplesExtensions_BatchAsync_Microsoft_Azure_CognitiveServices_Language_LUIS_Authoring_IExamples_System_Guid_System_String_System_Collections_Generic_IList_Microsoft_Azure_CognitiveServices_Language_LUIS_Authoring_Models_ExampleLabelObject__System_Threading_CancellationToken_) with the app ID, version ID, and the list of examples. The call responds with a list of results. You need to check each example's result to make sure it was successfully added to the model.
199151

200-
[!code-csharp[Add example utterances to a specific intent](~/cognitive-services-dotnet-sdk-samples/documentation-samples/quickstarts/LUIS/LUIS.cs?name=AuthoringBatchAddUtterancesForIntent)]
152+
[!code-csharp[Add example utterances to a specific intent](~/cognitive-services-quickstart-code/dotnet/LanguageUnderstanding/authoring/authoring-with-sdk.cs?name=AuthoringBatchAddUtterancesForIntent)]
201153

202154
The **CreateUtterance** and **CreateLabel** methods are utility methods to help you create objects.
203155

@@ -209,13 +161,13 @@ The [Train.TrainVersionAsync](https://docs.microsoft.com/dotnet/api/microsoft.az
209161

210162
A very small model, such as this quickstart shows, will train very quickly. For production-level applications, training the app should include a polling call to the [GetStatusAsync](https://docs.microsoft.com/dotnet/api/microsoft.azure.cognitiveservices.language.luis.authoring.trainextensions.getstatusasync?view=azure-dotnet#Microsoft_Azure_CognitiveServices_Language_LUIS_Authoring_TrainExtensions_GetStatusAsync_Microsoft_Azure_CognitiveServices_Language_LUIS_Authoring_ITrain_System_Guid_System_String_System_Threading_CancellationToken_) method to determine when or if the training succeeded. The response is a list of [ModelTrainingInfo](https://docs.microsoft.com/dotnet/api/microsoft.azure.cognitiveservices.language.luis.authoring.models.modeltraininginfo?view=azure-dotnet) objects with a separate status for each object. All objects must be successful for the training to be considered complete.
211163

212-
[!code-csharp[Train the app's version](~/cognitive-services-dotnet-sdk-samples/documentation-samples/quickstarts/LUIS/LUIS.cs?name=AuthoringTrainVersion)]
164+
[!code-csharp[Train the app's version](~/cognitive-services-quickstart-code/dotnet/LanguageUnderstanding/authoring/authoring-with-sdk.cs?name=AuthoringTrainVersion)]
213165

214166
## Publish a Language Understanding app
215167

216168
Publish the LUIS app using the [PublishAsync](https://docs.microsoft.com/dotnet/api/microsoft.azure.cognitiveservices.language.luis.authoring.appsextensions.publishasync?view=azure-dotnet) method. This publishes the current trained version to the specified slot at the endpoint. Your client application uses this endpoint to send user utterances for prediction of intent and entity extraction.
217169

218-
[!code-csharp[Create entities](~/cognitive-services-dotnet-sdk-samples/documentation-samples/quickstarts/LUIS/LUIS.cs?name=AuthoringPublishVersionAndSlot)]
170+
[!code-csharp[Create entities](~/cognitive-services-quickstart-code/dotnet/LanguageUnderstanding/authoring/authoring-with-sdk.cs?name=AuthoringPublishVersionAndSlot)]
219171

220172
## Run the application
221173

articles/cognitive-services/LUIS/includes/sdk-python-authoring.md

Lines changed: 5 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ author: diberry
66
manager: nitinme
77
ms.service: cognitive-services
88
ms.subservice: language-understanding
9-
ms.date: 02/14/2020
9+
ms.date: 05/26/2020
1010
ms.topic: include
1111
ms.custom: include file
1212
ms.author: diberry
@@ -22,54 +22,13 @@ Use the Language Understanding (LUIS) authoring client library for Python to:
2222

2323
## Prerequisites
2424

25-
* Language Understanding (LUIS) portal account: [Create one for free](https://www.luis.ai).
26-
* [Python 3.x](https://www.python.org/)
25+
* Azure subscription - [Create one for free](https://azure.microsoft.com/free/)
26+
* The current version of [Python 3.x](https://www.python.org/).
27+
* Once you have your Azure subscription, [create a Language Understanding authoring resource](https://ms.portal.azure.com/#create/Microsoft.CognitiveServicesLUISAllInOne) in the Azure portal to get your key and endpoint. Wait for it to deploy and click the **Go to resource** button.
28+
* You will need the key and endpoint from the resource you [create](../luis-how-to-azure-subscription.md#create-luis-resources-in-azure-portal) to connect your application to Language Understanding authoring. You'll paste your key and endpoint into the code below later in the quickstart. You can use the free pricing tier (`F0`) to try the service.
2729

2830
## Setting up
2931

30-
### Get your Language Understanding (LUIS) starter key
31-
32-
Get your [starter key](../luis-how-to-azure-subscription.md#starter-key) by creating a LUIS authoring resource. Keep your key, and the region of the key for the next step.
33-
34-
### Create an environment variable
35-
36-
Using your key, and the region for the key, create two environment variables for authentication:
37-
38-
* `LUIS_AUTHORING_KEY` - The resource key for authenticating your requests.
39-
* `LUIS_REGION` - The region associated with your key. For example `westus`.
40-
41-
Use the instructions for your operating system.
42-
43-
#### [Windows](#tab/windows)
44-
45-
```console
46-
setx LUIS_AUTHORING_KEY <replace-with-your-luis-authoring-key
47-
setx LUIS_REGION <replace-with-your-luis-region>
48-
```
49-
50-
After you add the environment variable, restart the console window.
51-
52-
#### [Linux](#tab/linux)
53-
54-
```bash
55-
export LUIS_AUTHORING_KEY=<replace-with-your-luis-authoring-key>
56-
export LUIS_REGION=<replace-with-your-luis-region>
57-
```
58-
59-
After you add the environment variable, run `source ~/.bashrc` from your console window to make the changes effective.
60-
61-
#### [macOS](#tab/unix)
62-
63-
Edit your `.bash_profile`, and add the environment variable:
64-
65-
```bash
66-
export LUIS_AUTHORING_KEY=<replace-with-your-luis-authoring-key>
67-
export LUIS_REGION=<replace-with-your-luis-region>
68-
```
69-
70-
After you add the environment variable, run `source .bash_profile` from your console window to make the changes effective.
71-
***
72-
7332
### Install the Python library for LUIS
7433

7534
Within the application directory, install the Language Understanding (LUIS) authoring client library for python with the following command:

articles/cognitive-services/LUIS/sdk-authoring.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: "Quickstart: Language Understanding (LUIS) authoring client library"
33
description: Get started with the LUIS client library with this quickstart. Follow these steps to install the package and try out the example code for basic tasks.
44
ms.topic: quickstart
5-
ms.date: 01/14/2020
5+
ms.date: 05/22/2020
66
zone_pivot_groups: programming-languages-set-diberry-3core
77
---
88
# Quickstart: Language Understanding (LUIS) authoring client library

0 commit comments

Comments
 (0)