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

Commit 7b69d6d

Browse files
committed
Fixing create kb output to return json file and fixing sme comments
1 parent 8fbed97 commit 7b69d6d

File tree

4 files changed

+24
-8
lines changed

4 files changed

+24
-8
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export default class QnamakerCreateKb extends Command {
7474
userConfig.qnamaker = input.config
7575
await fs.writeJson(path.join(this.config.configDir, 'config.json'), userConfig, {spaces: 2})
7676
} else {
77-
this.log('Knowledge Base id: ' + kbId)
77+
this.log(JSON.stringify({kbId}, null, 2))
7878
}
7979
}
8080

packages/qnamaker/src/commands/qnamaker/query.ts

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@ export default class QnamakerQuery extends Command {
77
static description = 'Generate Answer for fetching the answer from Kb for a query'
88

99
static flags: flags.Input<any> = {
10-
question: flags.string({description: 'Query to get a prediction for.', required: true}),
10+
question: flags.string({description: 'Query to get a prediction for', required: true}),
1111
top: flags.integer({description: 'Specifies the number of matching results'}),
12-
test: flags.boolean({description: 'Query against the test index.', default: false}),
12+
test: flags.boolean({description: 'Query against the test index', default: false}),
1313
scorethreshold: flags.integer({description: 'Specifies the confidence score threshold for the returned answer.'}),
14-
strictfilters: flags.string({description: 'Path to json file {"strictfilters": MetadataDTO[]}'}),
15-
hostname: flags.string({description: 'Specifies the url for your private QnA service. Overrides the value present in config.'}),
16-
endpointKey: flags.string({description: 'Specifies the endpoint key for your private QnA service (From qnamaker.ai portal user settings page). Overrides the value present in config.'}),
14+
strictfilters: flags.string({description: 'Path to json file with MetadataDTO[] e.g {"strictfilters": MetadataDTO[]}'}),
15+
qnaId: flags.integer({description: 'Exact qnaId to fetch from the knowledgebase, this field takes priority over question'}),
16+
context: flags.string({description: 'Path to Context object json file with previous QnA'}),
17+
hostname: flags.string({description: 'Specifies the url for your private QnA service. Overrides the value present in config'}),
18+
endpointKey: flags.string({description: 'Specifies the endpoint key for your private QnA service (From qnamaker.ai portal user settings page). Overrides the value present in config'}),
1719
kbId: flags.string({description: 'Specifies the active qnamaker knowledgebase id. Overrides the value present in the config'}),
1820
help: flags.help({char: 'h', description: 'qnamaker:query command help'}),
1921
}
@@ -30,6 +32,10 @@ export default class QnamakerQuery extends Command {
3032
input.requestBody.top = flags.top
3133
}
3234

35+
if (flags.qnaId) {
36+
input.requestBody.qnaId = flags.qnaId
37+
}
38+
3339
if (flags.scorethreshold) {
3440
input.requestBody.scoreThreshold = flags.scorethreshold
3541
}
@@ -43,6 +49,15 @@ export default class QnamakerQuery extends Command {
4349
}
4450
}
4551

52+
if (flags.context) {
53+
try {
54+
let ctx = await getFileInput(flags.context)
55+
input.requestBody.context = ctx
56+
} catch (error) {
57+
throw new CLIError(error.message)
58+
}
59+
}
60+
4661
const result = await qnamaker(input.config, input.serviceManifest, flags, input.requestBody)
4762
if (result.error) {
4863
throw new CLIError(JSON.stringify(result.error, null, 4))

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ describe('qnamaker:create:kb', () => {
4343
.stdout()
4444
.command(['qnamaker:create:kb','--in', `${path.join(__dirname, '../../../fixtures/kb.json')}`])
4545
.it('Creates kb qnamaker:create:kb --in', ctx => {
46-
expect(ctx.stdout).to.contain('Knowledge Base id: 8600c573-2acf-4466-97e8-999ad4cecbc2')
46+
let response = JSON.parse(ctx.stdout)
47+
expect(response.kbId).to.be.equal('8600c573-2acf-4466-97e8-999ad4cecbc2')
4748
})
4849
})
4950

packages/qnamaker/test/mocha.opts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
--watch-extensions ts
33
--recursive
44
--reporter spec
5-
--timeout 10000
5+
--timeout 15000

0 commit comments

Comments
 (0)