44import { AuthMethod , createClient , startRecorder } from "./utils/recordedClient" ;
55import { Context , Suite } from "mocha" ;
66import { assert , matrix } from "@azure/test-utils" ;
7- import { conv1 , conv2 , conv3 , conv4 , conv5 , conv6 } from "./inputs" ;
87import { ConversationAnalysisClient } from "../../src" ;
9- import { Recorder } from "@azure-tools/test-recorder" ;
8+ import { Recorder , assertEnvironmentVariable } from "@azure-tools/test-recorder" ;
109
1110matrix ( [ [ "APIKey" ] ] as const , async ( authMethod : AuthMethod ) => {
1211 describe ( `[${ authMethod } ] ConversationAnalysisClient` , function ( this : Suite ) {
@@ -27,7 +26,24 @@ matrix([["APIKey"]] as const, async (authMethod: AuthMethod) => {
2726
2827 describe ( "#sync" , ( ) => {
2928 it ( "Test Conversation App" , async function ( ) {
30- const message = await client . analyzeConversation ( conv1 ) ;
29+ const message = await client . analyzeConversation ( {
30+ kind : "Conversation" ,
31+ analysisInput : {
32+ conversationItem : {
33+ participantId : "1" ,
34+ id : "1" ,
35+ modality : "text" ,
36+ language : "en" ,
37+ text : "Send an email to Carol about the tomorrow's demo" ,
38+ } ,
39+ } ,
40+ parameters : {
41+ projectName : assertEnvironmentVariable ( "LANGUAGE_CLU_PROJECT_NAME" ) ,
42+ deploymentName : assertEnvironmentVariable ( "LANGUAGE_CLU_DEPLOYMENT_NAME" ) ,
43+ verbose : true ,
44+ isLoggingEnabled : false ,
45+ } ,
46+ } ) ;
3147 // Assert prediction type
3248 assert . equal ( message . kind , "ConversationResult" ) ;
3349 assert . exists ( message . result . query ) ;
@@ -48,7 +64,24 @@ matrix([["APIKey"]] as const, async (authMethod: AuthMethod) => {
4864 } ) ;
4965
5066 it ( "Test Orchestration App Conversational Response" , async function ( ) {
51- const message = await client . analyzeConversation ( conv2 ) ;
67+ const message = await client . analyzeConversation ( {
68+ kind : "Conversation" ,
69+ analysisInput : {
70+ conversationItem : {
71+ participantId : "1" ,
72+ id : "1" ,
73+ modality : "text" ,
74+ language : "en" ,
75+ text : "Send an email to Carol about the tomorrow's demo" ,
76+ } ,
77+ } ,
78+ parameters : {
79+ projectName : assertEnvironmentVariable ( "LANGUAGE_ORCHESTRATION_PROJECT_NAME" ) ,
80+ deploymentName : assertEnvironmentVariable ( "LANGUAGE_ORCHESTRATION_DEPLOYMENT_NAME" ) ,
81+ verbose : true ,
82+ isLoggingEnabled : false ,
83+ } ,
84+ } ) ;
5285 // Assert prediction type
5386 assert . equal ( message . kind , "ConversationResult" ) ;
5487 assert . exists ( message . result . query ) ;
@@ -81,7 +114,24 @@ matrix([["APIKey"]] as const, async (authMethod: AuthMethod) => {
81114 } ) ;
82115
83116 it . skip ( "Test Orchestration App LUIS Response" , async function ( ) {
84- const message = await client . analyzeConversation ( conv3 ) ;
117+ const message = await client . analyzeConversation ( {
118+ kind : "Conversation" ,
119+ analysisInput : {
120+ conversationItem : {
121+ participantId : "1" ,
122+ id : "1" ,
123+ modality : "text" ,
124+ language : "en" ,
125+ text : "Reserve a table for 2 at the Italian restaurant" ,
126+ } ,
127+ } ,
128+ parameters : {
129+ projectName : assertEnvironmentVariable ( "LANGUAGE_ORCHESTRATION_PROJECT_NAME" ) ,
130+ deploymentName : assertEnvironmentVariable ( "LANGUAGE_ORCHESTRATION_DEPLOYMENT_NAME" ) ,
131+ verbose : true ,
132+ isLoggingEnabled : false ,
133+ } ,
134+ } ) ;
85135 // Assert prediction type
86136 assert . equal ( message . kind , "ConversationResult" ) ;
87137 assert . exists ( message . result . query ) ;
@@ -112,7 +162,24 @@ matrix([["APIKey"]] as const, async (authMethod: AuthMethod) => {
112162 } ) ;
113163
114164 it ( "Test Orchestration App QnA Response" , async function ( ) {
115- const message = await client . analyzeConversation ( conv4 ) ;
165+ const message = await client . analyzeConversation ( {
166+ kind : "Conversation" ,
167+ analysisInput : {
168+ conversationItem : {
169+ participantId : "1" ,
170+ id : "1" ,
171+ modality : "text" ,
172+ language : "en" ,
173+ text : "How are you?" ,
174+ } ,
175+ } ,
176+ parameters : {
177+ projectName : assertEnvironmentVariable ( "LANGUAGE_ORCHESTRATION_PROJECT_NAME" ) ,
178+ deploymentName : assertEnvironmentVariable ( "LANGUAGE_ORCHESTRATION_DEPLOYMENT_NAME" ) ,
179+ verbose : true ,
180+ isLoggingEnabled : false ,
181+ } ,
182+ } ) ;
116183 // Assert prediction type
117184 assert . equal ( message . kind , "ConversationResult" ) ;
118185 assert . exists ( message . result . query ) ;
@@ -140,7 +207,56 @@ matrix([["APIKey"]] as const, async (authMethod: AuthMethod) => {
140207
141208 describe ( "#async" , ( ) => {
142209 it ( "Test Conversation App PII transcript" , async function ( ) {
143- const poller = await client . beginConversationAnalysis ( conv5 ) ;
210+ const poller = await client . beginConversationAnalysis ( {
211+ displayName : "Analyze PII in conversation" ,
212+ analysisInput : {
213+ conversations : [
214+ {
215+ conversationItems : [
216+ {
217+ id : "1" ,
218+ participantId : "0" ,
219+ modality : "transcript" ,
220+ text : "It is john doe." ,
221+ lexical : "It is john doe" ,
222+ itn : "It is john doe" ,
223+ maskedItn : "It is john doe" ,
224+ } ,
225+ {
226+ id : "2" ,
227+ participantId : "1" ,
228+ modality : "transcript" ,
229+ text : "Yes, 633-27-8199 is my phone" ,
230+ lexical : "yes six three three two seven eight one nine nine is my phone" ,
231+ itn : "yes 633278199 is my phone" ,
232+ maskedItn : "yes 633278199 is my phone" ,
233+ } ,
234+ {
235+ id : "3" ,
236+ participantId : "1" ,
237+ modality : "transcript" ,
238+ text : "j.doe@yahoo.com is my email" ,
239+ lexical : "j dot doe at yahoo dot com is my email" ,
240+ maskedItn : "j.doe@yahoo.com is my email" ,
241+ itn : "j.doe@yahoo.com is my email" ,
242+ } ,
243+ ] ,
244+ modality : "transcript" ,
245+ id : "1" ,
246+ language : "en" ,
247+ } ,
248+ ] ,
249+ } ,
250+ tasks : [
251+ {
252+ kind : "ConversationalPIITask" ,
253+ parameters : {
254+ redactionSource : "lexical" ,
255+ piiCategories : [ "all" ] ,
256+ } ,
257+ } ,
258+ ] ,
259+ } ) ;
144260 const message = await poller . pollUntilDone ( ) ;
145261 // Assert main object
146262 assert . equal ( message . status , "succeeded" ) ;
@@ -167,7 +283,47 @@ matrix([["APIKey"]] as const, async (authMethod: AuthMethod) => {
167283 } ) ;
168284
169285 it ( "Test Conversation Summarization App" , async function ( ) {
170- const poller = await client . beginConversationAnalysis ( conv6 ) ;
286+ const poller = await client . beginConversationAnalysis ( {
287+ displayName : "Analyze conversations from xxx" ,
288+ analysisInput : {
289+ conversations : [
290+ {
291+ conversationItems : [
292+ {
293+ text : "Hello, how can I help you?" ,
294+ modality : "text" ,
295+ id : "1" ,
296+ participantId : "Agent" ,
297+ } ,
298+ {
299+ text : "How to upgrade Office? I am getting error messages the whole day." ,
300+ modality : "text" ,
301+ id : "2" ,
302+ participantId : "Customer" ,
303+ } ,
304+ {
305+ text : "Press the upgrade button please. Then sign in and follow the instructions." ,
306+ modality : "text" ,
307+ id : "3" ,
308+ participantId : "Agent" ,
309+ } ,
310+ ] ,
311+ modality : "text" ,
312+ id : "conversation1" ,
313+ language : "en" ,
314+ } ,
315+ ] ,
316+ } ,
317+ tasks : [
318+ {
319+ taskName : "analyze 1" ,
320+ kind : "ConversationalSummarizationTask" ,
321+ parameters : {
322+ summaryAspects : [ "Issue, Resolution" ] ,
323+ } ,
324+ } ,
325+ ] ,
326+ } ) ;
171327 const message = await poller . pollUntilDone ( ) ;
172328 // Assert main object
173329 assert . equal ( message . status , "succeeded" ) ;
0 commit comments