Skip to content
This repository was archived by the owner on Jan 15, 2025. It is now read-only.

Commit 2ea32b4

Browse files
authored
Merge pull request #202 from microsoft/emimunoz/qnamaker
Gov support to QnAMaker
2 parents f7e02da + 7240729 commit 2ea32b4

File tree

23 files changed

+196
-52
lines changed

23 files changed

+196
-52
lines changed

packages/cli/README.md

Lines changed: 117 additions & 39 deletions
Large diffs are not rendered by default.

packages/qnamaker/README.md

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,13 @@
3030
* [`bf qnamaker:replace:alterations`](#bf-qnamakerreplacealterations)
3131
* [`bf qnamaker:replace:kb`](#bf-qnamakerreplacekb)
3232
* [`bf qnamaker:train`](#bf-qnamakertrain)
33+
* [`bf qnamaker:update`](#bf-qnamakerupdate)
3334
* [`bf qnamaker:update:endpointsettings`](#bf-qnamakerupdateendpointsettings)
3435
* [`bf qnamaker:update:kb`](#bf-qnamakerupdatekb)
3536

3637
## `bf qnamaker`
3738

38-
QnA Maker CLI (Preview version)
39+
QnA Maker
3940

4041
```
4142
USAGE
@@ -57,6 +58,7 @@ USAGE
5758
5859
OPTIONS
5960
-h, --help qnamaker:create:kb command help
61+
--endpoint=endpoint Overrides public endpoint https://westus.api.cognitive.microsoft.com/qnamaker/v4.0/
6062
--in=in File path to the CreateKbDTO object to send in the body of the request.
6163
6264
--name=name Name of the kb you want to create. This will override the name of KB that might be
@@ -81,6 +83,7 @@ USAGE
8183
8284
OPTIONS
8385
-h, --help qnamaker:delete:kb command help
86+
--endpoint=endpoint Overrides public endpoint https://westus.api.cognitive.microsoft.com/qnamaker/v4.0/
8487
--force Do not prompt for confirmation, force the operation
8588
8689
--kbId=kbId Knowledgebase id to be deleted. Overrides the knowledge base id present in the
@@ -103,6 +106,7 @@ USAGE
103106
104107
OPTIONS
105108
-h, --help qnamaker:export:kb command help
109+
--endpoint=endpoint Overrides public endpoint https://westus.api.cognitive.microsoft.com/qnamaker/v4.0/
106110
--environment=environment (required) Specifies whether environment is Test or Prod.
107111
108112
--kbId=kbId Knowledgebase id to be exported. Overrides the knowledge base id present in the
@@ -139,6 +143,7 @@ USAGE
139143
140144
OPTIONS
141145
-h, --help qnamaker:get:endpointsettings command help
146+
--endpoint=endpoint Overrides public endpoint https://westus.api.cognitive.microsoft.com/qnamaker/v4.0/
142147
--kbId=kbId Knowledgebase id to get metadata.
143148
144149
--subscriptionKey=subscriptionKey Specifies the qnamaker Ocp-Apim-Subscription Key (found in Keys under Resource
@@ -158,6 +163,7 @@ USAGE
158163
159164
OPTIONS
160165
-h, --help qnamaker:get:kb command help
166+
--endpoint=endpoint Overrides public endpoint https://westus.api.cognitive.microsoft.com/qnamaker/v4.0/
161167
162168
--kbId=kbId Knowledgebase id to get metadata. Overrides the knowledge base id present in the
163169
config
@@ -179,6 +185,7 @@ USAGE
179185
180186
OPTIONS
181187
-h, --help qnamaker:get:operationdetails command help
188+
--endpoint=endpoint Overrides public endpoint https://westus.api.cognitive.microsoft.com/qnamaker/v4.0/
182189
--operationId=operationId (required) Operation id.
183190
184191
--subscriptionKey=subscriptionKey Specifies the qnamaker Ocp-Apim-Subscription Key (found in Keys under Resource
@@ -197,7 +204,8 @@ USAGE
197204
$ bf qnamaker:init
198205
199206
OPTIONS
200-
-h, --help qnamaker:init command help
207+
-h, --help qnamaker:init command help
208+
--endpoint=endpoint Overrides public endpoint https://westus.api.cognitive.microsoft.com/qnamaker/v4.0/
201209
```
202210

203211
_See code: [src/commands/qnamaker/init.ts](https://github.com/microsoft/botframework-cli/blob/v1.0.0/src/commands/qnamaker/init.ts)_
@@ -226,6 +234,7 @@ USAGE
226234
227235
OPTIONS
228236
-h, --help qnamaker:list:alterations command help
237+
--endpoint=endpoint Overrides public endpoint https://westus.api.cognitive.microsoft.com/qnamaker/v4.0/
229238
230239
--subscriptionKey=subscriptionKey Specifies the qnamaker Ocp-Apim-Subscription Key (found in Keys under Resource
231240
Management section for your Qna Maker cognitive service). Overrides the
@@ -244,6 +253,7 @@ USAGE
244253
245254
OPTIONS
246255
-h, --help qnamaker:list:endpointkeys command help
256+
--endpoint=endpoint Overrides public endpoint https://westus.api.cognitive.microsoft.com/qnamaker/v4.0/
247257
248258
--subscriptionKey=subscriptionKey Specifies the qnamaker Ocp-Apim-Subscription Key (found in Keys under Resource
249259
Management section for your Qna Maker cognitive service). Overrides the
@@ -262,6 +272,7 @@ USAGE
262272
263273
OPTIONS
264274
-h, --help qnamaker:list:kbs command help
275+
--endpoint=endpoint Overrides public endpoint https://westus.api.cognitive.microsoft.com/qnamaker/v4.0/
265276
266277
--subscriptionKey=subscriptionKey Specifies the qnamaker Ocp-Apim-Subscription Key (found in Keys under Resource
267278
Management section for your Qna Maker cognitive service). Overrides the
@@ -280,6 +291,7 @@ USAGE
280291
281292
OPTIONS
282293
-h, --help qnamaker:publish:kb command help
294+
--endpoint=endpoint Overrides public endpoint https://westus.api.cognitive.microsoft.com/qnamaker/v4.0/
283295
--kbId=kbId Knowledgebase id to pubish. Overrides the knowledge base id present in the config
284296
285297
--subscriptionKey=subscriptionKey Specifies the qnamaker Ocp-Apim-Subscription Key (found in Keys under Resource
@@ -332,6 +344,7 @@ USAGE
332344
333345
OPTIONS
334346
-h, --help qnamaker:refresh:endpoints command help
347+
--endpoint=endpoint Overrides public endpoint https://westus.api.cognitive.microsoft.com/qnamaker/v4.0/
335348
--keyType=keyType (required) Type of Key. (PrimaryKey/SecondaryKey)
336349
337350
--subscriptionKey=subscriptionKey Specifies the qnamaker Ocp-Apim-Subscription Key (found in Keys under Resource
@@ -365,6 +378,7 @@ USAGE
365378
366379
OPTIONS
367380
-h, --help qnamaker:replace:alterations command help
381+
--endpoint=endpoint Overrides public endpoint https://westus.api.cognitive.microsoft.com/qnamaker/v4.0/
368382
--in=in File path to the WordAlterationsDTO object to send in the body of the request
369383
370384
--subscriptionKey=subscriptionKey Specifies the qnamaker Ocp-Apim-Subscription Key (found in Keys under Resource
@@ -384,6 +398,7 @@ USAGE
384398
385399
OPTIONS
386400
-h, --help qnamaker:replace:kb command help
401+
--endpoint=endpoint Overrides public endpoint https://westus.api.cognitive.microsoft.com/qnamaker/v4.0/
387402
--in=in File path to the ReplaceKbDTO object to send in the body of the request
388403
--kbId=kbId Knowledgebase id. Overrides the knowledge base id present in the config
389404
@@ -423,6 +438,20 @@ OPTIONS
423438

424439
_See code: [src/commands/qnamaker/train.ts](https://github.com/microsoft/botframework-cli/blob/v1.0.0/src/commands/qnamaker/train.ts)_
425440

441+
## `bf qnamaker:update`
442+
443+
Updates KB or Endpoint settings
444+
445+
```
446+
USAGE
447+
$ bf qnamaker:update
448+
449+
OPTIONS
450+
-h, --help display qnamaker:update available commands
451+
```
452+
453+
_See code: [src/commands/qnamaker/update/index.ts](https://github.com/microsoft/botframework-cli/blob/v1.0.0/src/commands/qnamaker/update/index.ts)_
454+
426455
## `bf qnamaker:update:endpointsettings`
427456

428457
Updates endpoint settings for an endpoint.
@@ -434,6 +463,7 @@ USAGE
434463
OPTIONS
435464
-h, --help qnamaker:update:endpointsettings command help
436465
--activelearning Enable active learning. Disables if flag not set
466+
--endpoint=endpoint Overrides public endpoint https://westus.api.cognitive.microsoft.com/qnamaker/v4.0/
437467
438468
--subscriptionKey=subscriptionKey Specifies the qnamaker Ocp-Apim-Subscription Key (found in Keys under Resource
439469
Management section for your Qna Maker cognitive service). Overrides the
@@ -452,6 +482,7 @@ USAGE
452482
453483
OPTIONS
454484
-h, --help qnamaker:update:kb command help
485+
--endpoint=endpoint Overrides public endpoint https://westus.api.cognitive.microsoft.com/qnamaker/v4.0/
455486
456487
--in=in The file path to the UpdateKbOperationDTO object to send in the body of the
457488
request.

packages/qnamaker/src/commands/qnamaker/create/kb.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export default class QnamakerCreateKb extends Command {
2020
name: flags.string({description: 'Name of the kb you want to create. This will override the name of KB that might be present in the CreateKb DTO'}),
2121
save: flags.boolean({description: 'Save the kbId in config.'}),
2222
subscriptionKey: flags.string({description: 'Specifies the qnamaker Ocp-Apim-Subscription Key (found in Keys under Resource Management section for your Qna Maker cognitive service). Overrides the subscriptionkey value present in the config'}),
23+
endpoint: flags.string({description: 'Overrides public endpoint https://westus.api.cognitive.microsoft.com/qnamaker/v4.0/'}),
2324
help: flags.help({char: 'h', description: 'qnamaker:create:kb command help'}),
2425
}
2526

@@ -68,6 +69,8 @@ export default class QnamakerCreateKb extends Command {
6869
await fs.mkdirp(this.config.configDir)
6970
}
7071

72+
delete input.config.endpoint
73+
7174
userConfig.qnamaker = input.config
7275
await fs.writeJson(path.join(this.config.configDir, 'config.json'), userConfig, {spaces: 2})
7376
} else {

packages/qnamaker/src/commands/qnamaker/delete/kb.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ export default class QnamakerDeleteKb extends Command {
1313
static flags: flags.Input<any> = {
1414
kbId: flags.string({description: 'Knowledgebase id to be deleted. Overrides the knowledge base id present in the config'}),
1515
subscriptionKey: flags.string({description: 'Specifies the qnamaker Ocp-Apim-Subscription Key (found in Keys under Resource Management section for your Qna Maker cognitive service). Overrides the subscriptionkey value present in the config'}),
16-
force: flags.boolean({description: 'Do not prompt for confirmation, force the operation '}),
16+
force: flags.boolean({description: 'Do not prompt for confirmation, force the operation'}),
17+
endpoint: flags.string({description: 'Overrides public endpoint https://westus.api.cognitive.microsoft.com/qnamaker/v4.0/'}),
1718
help: flags.help({char: 'h', description: 'qnamaker:delete:kb command help'}),
1819
}
1920

packages/qnamaker/src/commands/qnamaker/export/kb.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export default class QnamakerExportKb extends Command {
1010
kbId: flags.string({description: 'Knowledgebase id to be exported. Overrides the knowledge base id present in the config'}),
1111
environment: flags.string({description: 'Specifies whether environment is Test or Prod.', required: true}),
1212
subscriptionKey: flags.string({description: 'Specifies the qnamaker Ocp-Apim-Subscription Key (found in Keys under Resource Management section for your Qna Maker cognitive service). Overrides the subscriptionkey value present in the config'}),
13+
endpoint: flags.string({description: 'Overrides public endpoint https://westus.api.cognitive.microsoft.com/qnamaker/v4.0/'}),
1314
help: flags.help({char: 'h', description: 'qnamaker:export:kb command help'}),
1415
}
1516

packages/qnamaker/src/commands/qnamaker/get/endpointsettings.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export default class QnamakerGetEndpointsettings extends Command {
99
static flags: flags.Input<any> = {
1010
kbId: flags.string({description: 'Knowledgebase id to get metadata.'}),
1111
subscriptionKey: flags.string({description: 'Specifies the qnamaker Ocp-Apim-Subscription Key (found in Keys under Resource Management section for your Qna Maker cognitive service). Overrides the subscriptionkey value present in the config'}),
12+
endpoint: flags.string({description: 'Overrides public endpoint https://westus.api.cognitive.microsoft.com/qnamaker/v4.0/'}),
1213
help: flags.help({char: 'h', description: 'qnamaker:get:endpointsettings command help'}),
1314
}
1415

packages/qnamaker/src/commands/qnamaker/get/kb.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export default class QnamakerGetKb extends Command {
1010
static flags: flags.Input<any> = {
1111
kbId: flags.string({description: 'Knowledgebase id to get metadata. Overrides the knowledge base id present in the config'}),
1212
subscriptionKey: flags.string({description: 'Specifies the qnamaker Ocp-Apim-Subscription Key (found in Keys under Resource Management section for your Qna Maker cognitive service). Overrides the subscriptionkey value present in the config'}),
13+
endpoint: flags.string({description: 'Overrides public endpoint https://westus.api.cognitive.microsoft.com/qnamaker/v4.0/'}),
1314
help: flags.help({char: 'h', description: 'qnamaker:get:kb command help'}),
1415
}
1516

packages/qnamaker/src/commands/qnamaker/get/operationdetails.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export default class QnamakerGetOperationdetails extends Command {
1010
static flags: flags.Input<any> = {
1111
operationId: flags.string({description: 'Operation id.', required: true}),
1212
subscriptionKey: flags.string({description: 'Specifies the qnamaker Ocp-Apim-Subscription Key (found in Keys under Resource Management section for your Qna Maker cognitive service). Overrides the subscriptionkey value present in the config'}),
13+
endpoint: flags.string({description: 'Overrides public endpoint https://westus.api.cognitive.microsoft.com/qnamaker/v4.0/'}),
1314
help: flags.help({char: 'h', description: 'qnamaker:get:operationdetails command help'}),
1415
}
1516

packages/qnamaker/src/commands/qnamaker/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {Command, flags} from '@microsoft/bf-cli-command'
22

33
export default class QnamakerIndex extends Command {
4-
static description = 'QnA Maker CLI (Preview version)'
4+
static description = 'QnA Maker'
55

66
static flags: flags.Input<any> = {
77
help: flags.help({char: 'h', description: 'Display QnA Maker CLI available commnads'}),

packages/qnamaker/src/commands/qnamaker/init.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,19 @@ export default class QnamakerInit extends Command {
1111
static description = 'Initializes the config file with settings.'
1212

1313
static flags: flags.Input<any> = {
14+
endpoint: flags.string({description: 'Overrides public endpoint https://westus.api.cognitive.microsoft.com/qnamaker/v4.0/'}),
1415
help: flags.help({char: 'h', description: 'qnamaker:init command help'}),
1516
}
1617

1718
async run() {
18-
const result = await this.initializeConfig()
19+
const {flags} = this.parse(QnamakerInit)
20+
const result = await this.initializeConfig(flags.endpoint)
1921
if (result) {
2022
this.log(`Successfully wrote ${this.config.configDir}/config.json`)
2123
}
2224
}
2325

24-
async initializeConfig(): Promise<boolean> {
26+
async initializeConfig(endpoint: string | undefined): Promise<boolean> {
2527
this.log(chalk.cyan.bold('\nThis util will walk you through the QnA Maker config settings\n\nPress ^C at any time to quit.\n\n'))
2628
const questions = [
2729
'What is your QnAMaker access/subscription key? (found on the Cognitive Services Azure portal page under "access keys") ',
@@ -38,15 +40,16 @@ export default class QnamakerInit extends Command {
3840

3941
let [subscriptionKey, kbId] = answers
4042
/* tslint:disable: prefer-object-spread */
41-
const config = Object.assign({}, {subscriptionKey, kbId})
43+
const config = Object.assign({}, {subscriptionKey, kbId, endpoint})
4244

4345
if (subscriptionKey && kbId) {
44-
cli.action.start('Updating hostname')
46+
cli.action.start('Updating config file hostname and endpoint key')
4547
await this.updateKbId(config)
4648
cli.action.stop()
4749
}
4850

4951
let confirmation: boolean
52+
delete config.endpoint
5053
try {
5154
confirmation = await cli.confirm(`Does this look ok?\n${JSON.stringify(config, null, 2)}\n[Yes]/No:`)
5255
/* tslint:disable: no-unused */

0 commit comments

Comments
 (0)