Skip to content

Commit 8e51f66

Browse files
Update conversation summarization C# code example to use Azure.AI.Language.Conversations: 1.1.0
Addresses #121867
1 parent 109f192 commit 8e51f66

File tree

1 file changed

+80
-73
lines changed
  • articles/ai-services/language-service/summarization/includes/quickstarts

1 file changed

+80
-73
lines changed

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

Lines changed: 80 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ using Azure;
190190
using Azure.Core;
191191
using Azure.AI.Language.Conversations;
192192
using System.Text.Json;
193+
using System.Threading.Tasks;
193194

194195
namespace Example
195196
{
@@ -198,92 +199,99 @@ namespace Example
198199
private static readonly AzureKeyCredential credentials = new AzureKeyCredential("replace-with-your-key-here");
199200
private static readonly Uri endpoint = new Uri("replace-with-your-endpoint-here");
200201

201-
static void Main(string[] args)
202+
static async Task Main(string[] args)
202203
{
203-
204204
ConversationAnalysisClient client = new ConversationAnalysisClient(endpoint, credentials);
205-
summarization(client);
205+
await Summarization(client);
206206
}
207-
public static void summarization(ConversationAnalysisClient client)
207+
208+
static async Task Summarization(ConversationAnalysisClient client)
208209
{
209210
var data = new
210211
{
211212
analysisInput = new
212213
{
213214
conversations = new[]
214-
{
215-
new
216-
{
217-
conversationItems = new[]
218-
{
219-
new
220-
{
221-
text = "Hello, you’re chatting with Rene. How may I help you?",
222-
id = "1",
223-
participantId = "Agent",
224-
},
225-
new
226-
{
227-
text = "Hi, I tried to set up wifi connection for Smart Brew 300 coffee machine, but it didn’t work.",
228-
id = "2",
229-
participantId = "Customer",
230-
},
231-
new
232-
{
233-
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?",
234-
id = "3",
235-
participantId = "Agent",
236-
},
237-
new
238-
{
239-
text = "Yes, I pushed the wifi connection button, and now the power light is slowly blinking?",
240-
id = "4",
241-
participantId = "Customer",
242-
},
243-
new
244215
{
245-
text = "Great. Thank you! Now, please check in your Contoso Coffee app. Does it prompt to ask you to connect with the machine?",
246-
id = "5",
247-
participantId = "Agent",
248-
},
249-
new
250-
{
251-
text = "No. Nothing happened.",
252-
id = "6",
253-
participantId = "Customer",
254-
},
255-
new
256-
{
257-
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.",
258-
id = "7",
259-
participantId = "Agent",
216+
new
217+
{
218+
conversationItems = new[]
219+
{
220+
new
221+
{
222+
text = "Hello, you’re chatting with Rene. How may I help you?",
223+
id = "1",
224+
role = "Agent",
225+
participantId = "Agent",
226+
},
227+
new
228+
{
229+
text = "Hi, I tried to set up wifi connection for Smart Brew 300 coffee machine, but it didn’t work.",
230+
id = "2",
231+
role = "Customer",
232+
participantId = "Customer",
233+
},
234+
new
235+
{
236+
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?",
237+
id = "3",
238+
role = "Agent",
239+
participantId = "Agent",
240+
},
241+
new
242+
{
243+
text = "Yes, I pushed the wifi connection button, and now the power light is slowly blinking?",
244+
id = "4",
245+
role = "Customer",
246+
participantId = "Customer",
247+
},
248+
new
249+
{
250+
text = "Great. Thank you! Now, please check in your Contoso Coffee app. Does it prompt to ask you to connect with the machine?",
251+
id = "5",
252+
role = "Agent",
253+
participantId = "Agent",
254+
},
255+
new
256+
{
257+
text = "No. Nothing happened.",
258+
id = "6",
259+
role = "Customer",
260+
participantId = "Customer",
261+
},
262+
new
263+
{
264+
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.",
265+
id = "7",
266+
role = "Agent",
267+
participantId = "Agent",
268+
}
269+
},
270+
id = "1",
271+
language = "en",
272+
modality = "text",
273+
},
260274
}
261275
},
262-
id = "1",
263-
language = "en",
264-
modality = "text",
265-
},
266-
}
267-
},
268276
tasks = new[]
269-
{
270-
new
271-
{
272-
parameters = new
273-
{
274-
summaryAspects = new[]
275277
{
276-
"issue",
277-
"resolution",
278-
}
279-
},
280-
kind = "ConversationalSummarizationTask",
281-
taskName = "1",
282-
},
283-
},
278+
new
279+
{
280+
parameters = new
281+
{
282+
summaryAspects = new[]
283+
{
284+
"issue",
285+
"resolution",
286+
}
287+
},
288+
kind = "ConversationalSummarizationTask",
289+
taskName = "1",
290+
},
291+
},
284292
};
285293

286-
Operation<BinaryData> analyzeConversationOperation = client.AnalyzeConversation(WaitUntil.Started, RequestContent.Create(data));
294+
Operation<BinaryData> analyzeConversationOperation = await client.AnalyzeConversationsAsync(WaitUntil.Started, RequestContent.Create(data));
287295
analyzeConversationOperation.WaitForCompletion();
288296

289297
using JsonDocument result = JsonDocument.Parse(analyzeConversationOperation.Value.ToStream());
@@ -308,7 +316,6 @@ namespace Example
308316
}
309317
}
310318
}
311-
312319
```
313320

314321
### Output
@@ -317,9 +324,9 @@ namespace Example
317324
Conversations:
318325
Conversation: #1
319326
Summaries:
320-
Text: Customer tried to set up wifi connection for Smart Brew 300 coffee machine, but it didn't work
327+
Text: Customer is unable to set up wifi connection for Smart Brew 300 coffee machine.
321328
Aspect: issue
322-
Text: Asked customer to try the following steps | Asked customer for the power light | Helped customer to connect to the machine
329+
Text: The agent instructed the customer to press the wifi connection button, hold for 3 seconds, and check if the power light blinks. The agent also asked the customer to check if the Contoso Coffee app prompts to connect with the machine, but the issue persisted. The agent is looking for another way to fix the issue.
323330
Aspect: resolution
324331
```
325332

0 commit comments

Comments
 (0)