@@ -134,6 +134,87 @@ describe('builder: importUrlOrFileReference function return lu content from file
134134 } )
135135} )
136136
137+ describe ( 'builder: importUrlOrFileReference function return lu content from file sucessfully with multiturn extraction enabled' , ( ) => {
138+ before ( function ( ) {
139+ nock ( 'https://westus.api.cognitive.microsoft.com' )
140+ . get ( uri => uri . includes ( 'qnamaker' ) )
141+ . reply ( 200 , {
142+ knowledgebases :
143+ [ {
144+ name : 'test.en-us.qna' ,
145+ id : 'f8c64e2a-1111-3a09-8f78-39d7adc76ec5' ,
146+ hostName : 'https://myqnamakerbot.azurewebsites.net'
147+ } ]
148+ } )
149+
150+ nock ( 'https://westus.api.cognitive.microsoft.com' )
151+ . post ( uri => uri . includes ( 'createasync' ) )
152+ . reply ( 202 , {
153+ operationId : 'f8c64e2a-aaaa-3a09-8f78-39d7adc76ec5'
154+ } )
155+
156+ nock ( 'https://westus.api.cognitive.microsoft.com' )
157+ . get ( uri => uri . includes ( 'operations' ) )
158+ . reply ( 200 , {
159+ operationState : 'Succeeded' ,
160+ resourceLocation : 'a/b/f8c64e2a-2222-3a09-8f78-39d7adc76ec5'
161+ } )
162+
163+ nock ( 'https://westus.api.cognitive.microsoft.com' )
164+ . get ( uri => uri . includes ( 'knowledgebases' ) )
165+ . reply ( 200 , {
166+ qnaDocuments : [ {
167+ id : 1 ,
168+ source : 'SurfaceManual.pdf' ,
169+ questions : [ 'User Guide' ] ,
170+ answer : 'More Answers' ,
171+ metadata : [ ] ,
172+ prompts : [ {
173+ displayOrder : 0 ,
174+ displayText : 'With Windows 10' ,
175+ qnaId : 2
176+ } ]
177+ } ,
178+ {
179+ id : 2 ,
180+ source : 'SurfaceManual.pdf' ,
181+ questions : [ 'With Windows 10' ] ,
182+ answer : '**With Windows 10**' ,
183+ metadata : [ ] ,
184+ prompts : [ ]
185+ } ]
186+ } )
187+ } )
188+
189+ nock ( 'https://westus.api.cognitive.microsoft.com' )
190+ . delete ( uri => uri . includes ( 'knowledgebases' ) )
191+ . reply ( 200 )
192+
193+ it ( 'should return lu content from file successfully' , async ( ) => {
194+ const builder = new Builder ( )
195+ const luContent = await builder . importFileReference (
196+ 'SurfaceManual.pdf' ,
197+ 'https://download.microsoft.com/download/2/9/B/29B20383-302C-4517-A006-B0186F04BE28/surface-pro-4-user-guide-EN.pdf' ,
198+ uuidv1 ( ) ,
199+ 'https://westus.api.cognitive.microsoft.com/qnamaker/v4.0' ,
200+ 'mytest.en-us.qna' ,
201+ true )
202+
203+ assert . equal ( luContent ,
204+ `> # QnA pairs${ NEWLINE } ${ NEWLINE } ` +
205+ `> !# @qna.pair.source = SurfaceManual.pdf${ NEWLINE } ${ NEWLINE } ` +
206+ `<a id = "1"></a>${ NEWLINE } ${ NEWLINE } ` +
207+ `# ? User Guide${ NEWLINE } ${ NEWLINE } ` +
208+ `\`\`\`markdown${ NEWLINE } ` +
209+ `More Answers${ NEWLINE } \`\`\`${ NEWLINE } ${ NEWLINE } ` +
210+ `> !# @qna.pair.source = SurfaceManual.pdf${ NEWLINE } ${ NEWLINE } ` +
211+ `<a id = "2"></a>${ NEWLINE } ${ NEWLINE } ` +
212+ `# ? With Windows 10${ NEWLINE } ${ NEWLINE } ` +
213+ `\`\`\`markdown${ NEWLINE } ` +
214+ `**With Windows 10**${ NEWLINE } \`\`\`${ NEWLINE } ${ NEWLINE } ` )
215+ } )
216+ } )
217+
137218describe ( 'builder: importUrlOrFileReference function return lu content from url sucessfully' , ( ) => {
138219 before ( function ( ) {
139220 nock ( 'https://westus.api.cognitive.microsoft.com' )
@@ -193,6 +274,86 @@ describe('builder: importUrlOrFileReference function return lu content from url
193274 } )
194275} )
195276
277+ describe ( 'builder: importUrlOrFileReference function return lu content from url sucessfully with multiturn extraction enabled' , ( ) => {
278+ before ( function ( ) {
279+ nock ( 'https://westus.api.cognitive.microsoft.com' )
280+ . get ( uri => uri . includes ( 'qnamaker' ) )
281+ . reply ( 200 , {
282+ knowledgebases :
283+ [ {
284+ name : 'test.en-us.qna' ,
285+ id : 'f8c64e2a-1111-3a09-8f78-39d7adc76ec5' ,
286+ hostName : 'https://myqnamakerbot.azurewebsites.net'
287+ } ]
288+ } )
289+
290+ nock ( 'https://westus.api.cognitive.microsoft.com' )
291+ . post ( uri => uri . includes ( 'createasync' ) )
292+ . reply ( 202 , {
293+ operationId : 'f8c64e2a-aaaa-3a09-8f78-39d7adc76ec5'
294+ } )
295+
296+ nock ( 'https://westus.api.cognitive.microsoft.com' )
297+ . get ( uri => uri . includes ( 'operations' ) )
298+ . reply ( 200 , {
299+ operationState : 'Succeeded' ,
300+ resourceLocation : 'a/b/f8c64e2a-2222-3a09-8f78-39d7adc76ec5'
301+ } )
302+
303+ nock ( 'https://westus.api.cognitive.microsoft.com' )
304+ . get ( uri => uri . includes ( 'knowledgebases' ) )
305+ . reply ( 200 , {
306+ qnaDocuments : [ {
307+ id : 1 ,
308+ source : 'SurfaceManual.pdf' ,
309+ questions : [ 'User Guide' ] ,
310+ answer : 'More Answers' ,
311+ metadata : [ ] ,
312+ prompts : [ {
313+ displayOrder : 0 ,
314+ displayText : 'With Windows 10' ,
315+ qnaId : 2
316+ } ]
317+ } ,
318+ {
319+ id : 2 ,
320+ source : 'SurfaceManual.pdf' ,
321+ questions : [ 'With Windows 10' ] ,
322+ answer : '**With Windows 10**' ,
323+ metadata : [ ] ,
324+ prompts : [ ]
325+ } ]
326+ } )
327+
328+ nock ( 'https://westus.api.cognitive.microsoft.com' )
329+ . delete ( uri => uri . includes ( 'knowledgebases' ) )
330+ . reply ( 200 )
331+ } )
332+
333+ it ( 'should return lu content from url successfully' , async ( ) => {
334+ const builder = new Builder ( )
335+ const luContent = await builder . importUrlReference (
336+ 'https://docs.microsoft.com/en-in/azure/cognitive-services/qnamaker/faqs' ,
337+ uuidv1 ( ) ,
338+ 'https://westus.api.cognitive.microsoft.com/qnamaker/v4.0' ,
339+ 'mytest.en-us.qna' ,
340+ true )
341+
342+ assert . equal ( luContent ,
343+ `> # QnA pairs${ NEWLINE } ${ NEWLINE } ` +
344+ `> !# @qna.pair.source = SurfaceManual.pdf${ NEWLINE } ${ NEWLINE } ` +
345+ `<a id = "1"></a>${ NEWLINE } ${ NEWLINE } ` +
346+ `# ? User Guide${ NEWLINE } ${ NEWLINE } ` +
347+ `\`\`\`markdown${ NEWLINE } ` +
348+ `More Answers${ NEWLINE } \`\`\`${ NEWLINE } ${ NEWLINE } ` +
349+ `> !# @qna.pair.source = SurfaceManual.pdf${ NEWLINE } ${ NEWLINE } ` +
350+ `<a id = "2"></a>${ NEWLINE } ${ NEWLINE } ` +
351+ `# ? With Windows 10${ NEWLINE } ${ NEWLINE } ` +
352+ `\`\`\`markdown${ NEWLINE } ` +
353+ `**With Windows 10**${ NEWLINE } \`\`\`${ NEWLINE } ${ NEWLINE } ` )
354+ } )
355+ } )
356+
196357describe ( 'builder: importUrlOrFileReference function return lu content from url sucessfully when updating kb' , ( ) => {
197358 before ( function ( ) {
198359 nock ( 'https://westus.api.cognitive.microsoft.com' )
0 commit comments