Skip to content

Commit 80352a4

Browse files
authored
Merge pull request #203924 from aahill/sumamrization-qs
Summarization SDK quickstarts
2 parents e2417d9 + f51ab70 commit 80352a4

File tree

5 files changed

+188
-9
lines changed

5 files changed

+188
-9
lines changed

articles/cognitive-services/language-service/summarization/includes/quickstarts/csharp-sdk.md

Lines changed: 166 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,20 @@ manager: nitinme
44
ms.service: cognitive-services
55
ms.subservice: language-service
66
ms.topic: include
7-
ms.date: 06/14/2022
7+
ms.date: 07/06/2022
88
ms.author: aahi
99
ms.custom: ignite-fall-2021
1010
---
1111

12+
# [Document summarization](#tab/document-summarization)
13+
1214
[Reference documentation](/dotnet/api/azure.ai.textanalytics?preserve-view=true&view=azure-dotnet-preview) | [Library source code](https://github.com/Azure/azure-sdk-for-net/tree/master/sdk/textanalytics/Azure.AI.TextAnalytics) | [Package (NuGet)](https://www.nuget.org/packages/Azure.AI.TextAnalytics/5.2.0-beta.1) | [Additional samples](https://github.com/Azure/azure-sdk-for-net/tree/master/sdk/textanalytics/Azure.AI.TextAnalytics/samples)
1315

16+
# [Conversation summarization](#tab/conversation-summarization)
17+
18+
[Reference documentation](/dotnet/api/overview/azure/ai.language.conversations-readme-pre?view=azure-dotnet-preview&preserve-view=true) | [Library source code](https://github.com/Azure/azure-sdk-for-net/tree/Azure.AI.Language.Conversations_1.1.0-beta.1/sdk/cognitivelanguage/Azure.AI.Language.Conversations/src/) | [Package (NuGet)](https://www.nuget.org/packages/Azure.AI.Language.Conversations/1.1.0-beta.1) | [Additional samples](https://github.com/Azure/azure-sdk-for-net/tree/Azure.AI.Language.Conversations_1.1.0-beta.1/sdk/cognitivelanguage/Azure.AI.Language.Conversations/samples)
19+
20+
---
1421

1522
## Prerequisites
1623

@@ -33,8 +40,16 @@ ms.custom: ignite-fall-2021
3340

3441
Using the Visual Studio IDE, create a new .NET Core console app. This will create a "Hello World" project with a single C# source file: *program.cs*.
3542

43+
# [Document summarization](#tab/document-summarization)
44+
3645
Install the client library by right-clicking on the solution in the **Solution Explorer** and selecting **Manage NuGet Packages**. In the package manager that opens select **Browse** and search for `Azure.AI.TextAnalytics`. Make sure **Include prerelease** is checked. Select version `5.2.0-beta.1`, and then **Install**. You can also use the [Package Manager Console](/nuget/consume-packages/install-use-packages-powershell#find-and-install-a-package).
3746

47+
# [Conversation summarization](#tab/conversation-summarization)
48+
49+
Install the client library by right-clicking on the solution in the **Solution Explorer** and selecting **Manage NuGet Packages**. In the package manager that opens select **Browse** and search for `Azure.AI.Language.Conversations`. Make sure **Include prerelease** is checked. Select version `1.1.0-beta.1`, and then **Install**. You can also use the [Package Manager Console](/nuget/consume-packages/install-use-packages-powershell#find-and-install-a-package).
50+
51+
---
52+
3853
> [!div class="nextstepaction"]
3954
> <a href="https://microsoft.qualtrics.com/jfe/form/SV_0Cl5zkG3CnDjq6O?PLanguage=CSHARP&Pillar=Language&Product=Summarization&Page=quickstart&Section=Set-up-the-environment" target="_target">I ran into an issue</a>
4055
@@ -44,14 +59,16 @@ Copy the following code into your *program.cs* file. Remember to replace the `ke
4459

4560
[!INCLUDE [find the key and endpoint for a resource](../../../includes/find-azure-resource-info.md)]
4661

62+
# [Document summarization](#tab/document-summarization)
63+
4764
```csharp
4865
using Azure;
4966
using System;
5067
using Azure.AI.TextAnalytics;
5168
using System.Threading.Tasks;
5269
using System.Collections.Generic;
5370

54-
namespace LanguageDetectionExample
71+
namespace Example
5572
{
5673
class Program
5774
{
@@ -141,9 +158,6 @@ namespace LanguageDetectionExample
141158

142159
```
143160

144-
> [!div class="nextstepaction"]
145-
> <a href="https://microsoft.qualtrics.com/jfe/form/SV_0Cl5zkG3CnDjq6O?PLanguage=CSHARP&Pillar=Language&Product=Summarization&Page=quickstart&Section=Code-example" target="_target">I ran into an issue</a>
146-
147161
### Output
148162

149163
```console
@@ -162,3 +176,150 @@ Sentence: This feature is provided as an API for developers.
162176

163177
Sentence: They can use it to build intelligent solutions based on the relevant information extracted to support various use cases.
164178
```
179+
180+
# [Conversation summarization](#tab/conversation-summarization)
181+
182+
```csharp
183+
using System;
184+
using Azure;
185+
using Azure.Core;
186+
using Azure.AI.Language.Conversations;
187+
using System.Text.Json;
188+
189+
namespace Example
190+
{
191+
class Program
192+
{
193+
private static readonly AzureKeyCredential credentials = new AzureKeyCredential("replace-with-your-key-here");
194+
private static readonly Uri endpoint = new Uri("replace-with-your-endpoint-here");
195+
196+
static void Main(string[] args)
197+
{
198+
199+
ConversationAnalysisClient client = new ConversationAnalysisClient(endpoint, credentials);
200+
summarization(client);
201+
}
202+
public static void summarization(ConversationAnalysisClient client)
203+
{
204+
var data = new
205+
{
206+
analysisInput = new
207+
{
208+
conversations = new[]
209+
{
210+
new
211+
{
212+
conversationItems = new[]
213+
{
214+
new
215+
{
216+
text = "Hello, you’re chatting with Rene. How may I help you?",
217+
id = "1",
218+
participantId = "Agent",
219+
},
220+
new
221+
{
222+
text = "Hi, I tried to set up wifi connection for Smart Brew 300 coffee machine, but it didn’t work.",
223+
id = "2",
224+
participantId = "Customer",
225+
},
226+
new
227+
{
228+
text = "I’m sorry to hear that. Let’s see what we can do to fix this issue. Could you please try the following steps for me? First, could you push the wifi connection button, hold for 3 seconds, then let me know if the power light is slowly blinking on and off every second?",
229+
id = "3",
230+
participantId = "Agent",
231+
},
232+
new
233+
{
234+
text = "Yes, I pushed the wifi connection button, and now the power light is slowly blinking?",
235+
id = "4",
236+
participantId = "Customer",
237+
},
238+
new
239+
{
240+
text = "Great. Thank you! Now, please check in your Contoso Coffee app. Does it prompt to ask you to connect with the machine?",
241+
id = "5",
242+
participantId = "Agent",
243+
},
244+
new
245+
{
246+
text = "No. Nothing happened.",
247+
id = "6",
248+
participantId = "Customer",
249+
},
250+
new
251+
{
252+
text = "I’m very sorry to hear that. Let me see if there’s another way to fix the issue. Please hold on for a minute.",
253+
id = "7",
254+
participantId = "Agent",
255+
}
256+
},
257+
id = "1",
258+
language = "en",
259+
modality = "text",
260+
},
261+
}
262+
},
263+
tasks = new[]
264+
{
265+
new
266+
{
267+
parameters = new
268+
{
269+
summaryAspects = new[]
270+
{
271+
"issue",
272+
"resolution",
273+
}
274+
},
275+
kind = "ConversationalSummarizationTask",
276+
taskName = "1",
277+
},
278+
},
279+
};
280+
281+
Operation<BinaryData> analyzeConversationOperation = client.AnalyzeConversation(WaitUntil.Started, RequestContent.Create(data));
282+
analyzeConversationOperation.WaitForCompletion();
283+
284+
using JsonDocument result = JsonDocument.Parse(analyzeConversationOperation.Value.ToStream());
285+
JsonElement jobResults = result.RootElement;
286+
foreach (JsonElement task in jobResults.GetProperty("tasks").GetProperty("items").EnumerateArray())
287+
{
288+
JsonElement results = task.GetProperty("results");
289+
290+
Console.WriteLine("Conversations:");
291+
foreach (JsonElement conversation in results.GetProperty("conversations").EnumerateArray())
292+
{
293+
Console.WriteLine($"Conversation: #{conversation.GetProperty("id").GetString()}");
294+
Console.WriteLine("Summaries:");
295+
foreach (JsonElement summary in conversation.GetProperty("summaries").EnumerateArray())
296+
{
297+
Console.WriteLine($"Text: {summary.GetProperty("text").GetString()}");
298+
Console.WriteLine($"Aspect: {summary.GetProperty("aspect").GetString()}");
299+
}
300+
Console.WriteLine();
301+
}
302+
}
303+
}
304+
}
305+
}
306+
307+
```
308+
309+
### Output
310+
311+
```console
312+
Conversations:
313+
Conversation: #1
314+
Summaries:
315+
Text: Customer tried to set up wifi connection for Smart Brew 300 coffee machine, but it didn't work
316+
Aspect: issue
317+
Text: Asked customer to try the following steps | Asked customer for the power light | Helped customer to connect to the machine
318+
Aspect: resolution
319+
```
320+
321+
---
322+
323+
> [!div class="nextstepaction"]
324+
> <a href="https://microsoft.qualtrics.com/jfe/form/SV_0Cl5zkG3CnDjq6O?PLanguage=CSHARP&Pillar=Language&Product=Summarization&Page=quickstart&Section=Code-example" target="_target">I ran into an issue</a>
325+

articles/cognitive-services/language-service/summarization/includes/quickstarts/python-sdk.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,20 @@ author: aahill
33
ms.service: cognitive-services
44
ms.subservice: language-service
55
ms.topic: include
6-
ms.date: 06/14/2022
6+
ms.date: 07/06/2022
77
ms.author: aahi
88
ms.custom: ignite-fall-2021
99
---
1010

11+
# [Document summarization](#tab/document-summarization)
12+
1113
[Reference documentation](/python/api/azure-ai-textanalytics/azure.ai.textanalytics?preserve-view=true&view=azure-python-preview) | [Library source code](https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/textanalytics/azure-ai-textanalytics) | [Package (PiPy)](https://pypi.org/project/azure-ai-textanalytics/5.2.0b1/) | [Samples](https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/textanalytics/azure-ai-textanalytics/samples)
1214

15+
# [Conversation summarization](#tab/conversation-summarization)
16+
17+
[Reference documentation](/python/api/overview/azure/ai-language-conversations-readme?preserve-view=true&view=azure-python-preview) | [Library source code](https://github.com/Azure/azure-sdk-for-python/tree/azure-ai-language-conversations_1.1.0b2/sdk/cognitivelanguage/azure-ai-language-conversations) | [Package (PiPy)](https://pypi.org/project/azure-ai-language-conversations/1.1.0b2/) | [Samples](https://github.com/Azure/azure-sdk-for-python/blob/azure-ai-language-conversations_1.1.0b2/sdk/cognitivelanguage/azure-ai-language-conversations/samples/README.md)
18+
19+
---
1320

1421
## Prerequisites
1522

@@ -40,7 +47,7 @@ pip install azure-ai-textanalytics==5.2.0b4
4047
# [Conversation summarization](#tab/conversation-summarization)
4148

4249
```console
43-
pip install azure-ai-language-conversations==1.1.0b1
50+
pip install azure-ai-language-conversations==1.1.0b2
4451
```
4552

4653
---
@@ -233,7 +240,11 @@ with client:
233240
### Output
234241

235242
```console
243+
... view task status ...
244+
status: succeeded
245+
... view task result ...
236246
issue: Customer tried to set up wifi connection for Smart Brew 300 coffee machine, but it didn't work
237247
resolution: Asked customer to try the following steps | Asked customer for the power light | Helped customer to connect to the machine
238248
```
249+
239250
---

articles/cognitive-services/language-service/summarization/includes/regional-availability.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,5 @@ ms.custom: references_regions
1818
> * UK South
1919
> * Conversation summarization is only available using:
2020
> * REST API
21-
> * Python
21+
> * Python
22+
> * C#

articles/cognitive-services/language-service/summarization/quickstart.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ manager: nitinme
88
ms.service: cognitive-services
99
ms.subservice: language-service
1010
ms.topic: quickstart
11-
ms.date: 06/14/2022
11+
ms.date: 07/06/2022
1212
ms.author: aahi
1313
ms.devlang: csharp, java, javascript, python
1414
ms.custom: language-service-summarization, ignite-fall-2021, mode-api

articles/cognitive-services/language-service/toc.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1094,6 +1094,12 @@ items:
10941094
href: /java/api/overview/azure/ai-textanalytics-readme?view=azure-java-preview&preserve-view=true
10951095
- name: Node.js
10961096
href: /javascript/api/overview/azure/ai-text-analytics-readme?view=azure-node-preview&preserve-view=true
1097+
- name: Conversation summarization
1098+
items:
1099+
- name: .NET
1100+
href: /dotnet/api/overview/azure/ai.language.conversations-readme-pre?preserve-view=true&view=azure-dotnet-preview
1101+
- name: Python
1102+
href: /python/api/overview/azure/ai-language-conversations-readme?preserve-view=true&view=azure-python-preview
10971103
- name: Concepts
10981104
items:
10991105
- name: Data limits

0 commit comments

Comments
 (0)