1 | # QnAMaker
|
2 |
|
3 | [![npm version](https://badge.fury.io/js/qnamaker.svg)](https://badge.fury.io/js/qnamaker)
|
4 |
|
5 | QnAMaker is command line tool and library for interacting with QnAMaker service using the QnAMaker REST API
|
6 |
|
7 | ## Pre-requisite
|
8 |
|
9 | - [Node.js](https://nodejs.org/) version 8.5 or higher
|
10 |
|
11 | ## Installation
|
12 |
|
13 | ### As a cli
|
14 | Make sure you have node >=8.5 and npm installed on your machine. then use:
|
15 |
|
16 | `npm i -g qnamaker`
|
17 |
|
18 | ### As a library
|
19 | The QnAMaker apis can be installed and used as a library in any Node or UI JavaScript projects for the browser.
|
20 |
|
21 | `npm i -s qnamaker`
|
22 |
|
23 | You can then import and use service classes specific to the endpoint and operation you wish to call.
|
24 |
|
25 | ## Command line usage
|
26 |
|
27 | QnA Maker cli for interacting with the QnA Maker api - © 2018 Microsoft Corporation
|
28 |
|
29 | |Commands| |
|
30 | |----|----|
|
31 | | qnamaker create --in createKnowledgeBase.json |Creates a new knowledge base.|
|
32 | | qnamaker publish |Publish all unpublished in the knowledgebase to the prod endpoint|
|
33 | | qnamaker update --in updateKnowledgeBase.json |Add or delete QnA Pairs and / or URLs to an existing knowledge base.|
|
34 | | qnamaker get |Downloads all the data associated with the specified knowledge base.|
|
35 | | qnamaker delete |Deletes the specified knowledge base and all data associated with it.|
|
36 | | qnamaker query --question "how do I turn it on" --top 5 |Returns the list of answers for the given question sorted in descending order of ranking score.|
|
37 | | qnamaker train --in trainKnowledgeBase.json |train the model |
|
38 | | qnamaker get alterations |Downloads all word alterations (synonyms) that have been automatically mined or added by the user.|
|
39 | | qnamaker update alterations --in updateAlterations.json |Replaces word alterations (synonyms) for the KB with the give records.|
|
40 |
|
41 |
|
42 | |Configuration and Overrides|description|
|
43 | |---|---|
|
44 | | --kbId <kbId> |Specifies the public qnamaker knowledgebase id. Overrides the .qnamakerrc value and the QNAMAKER_KBID environment variable.|
|
45 | | --subscriptionKey <key> |Specifies the qnamaker subscription key (from qnamaker.ai portal user settings page). Overrides the .qnamakerrc value and the QNAMAKER_SUBSCRIPTION_KEY environment variable.|
|
46 | | --endpoint <path> |Specifies the base URI for all requests. Overrides the .qnamakerrc value and the QNAMAKER_ENDPOINT environment variable.|
|
47 |
|
48 | |Global Arguments | description |
|
49 | | ---- | --- |
|
50 | | --help, -h | this help file.|
|
51 | | --version, -v | the version of this cli tool|
|
52 |
|
53 | ## Configuration
|
54 | A configuration object is required to provide the endpoint base path, app ID, version ID and the
|
55 | authoring key to each outbound call. There are 3 ways to provide this information to the cli
|
56 |
|
57 | 1. As a `.qnamakerrc` file in the cwd.
|
58 | The json format for the `.qnamakerrc` file is:
|
59 | ```json
|
60 | {
|
61 | "knowledgeBaseID": "xxxxxxx-xxxxx-xxxx-xxxx-xxxxxxxx",
|
62 | "subscriptionKey": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
|
63 | "endpoint": "https://westus.api.cognitive.microsoft.com/qnamaker/v2.0"
|
64 | }
|
65 | ```
|
66 |
|
67 | > NOTE: Simply run `qnamaker --init` to answer simple questions to create your .qnamakerrc file
|
68 |
|
69 | 2. As arguments to the cli. `--kbId <string> --subscriptionKey <string> --endpoint <string>`
|
70 |
|
71 | 3. As environment variables. `QNAMAKER_KBID, QNAMAKER_SUBSCRIPTION_KEY, QNAMAKER_ENDPOINT`
|
72 |
|
73 | The cli will first look for these named configuration variables in the arguments list, then inside the `.qnamakerrc` file, then fallback to environment variables.
|
74 |
|
75 | ### Securing Your Access Key
|
76 | To better secure your access key, it's recommended to omit the key from the `.qnamakerrc`
|
77 | file and instead pass it in to the `--subscriptionKey` argument or store it as the `QNAMAKER_SUBSCRIPTION_KEY`
|
78 | environment variable. If security is not a concern for your particular case, all configuration items
|
79 | can be stored in the `.qnamaker` for convenience.
|
80 |
|
81 | ### Overriding Configurations
|
82 | Since configuration items can be passed as arguments to the cli, using arguments to specify
|
83 | the configuration will override the `.qnamakerrc` and any environment variables that may have been specified.
|
84 |
|