Skip to content

Commit 6c69ec6

Browse files
authored
Merge pull request #80799 from diberry/0627-qna-api
[Cogsvcs] QnA Maker - REST API ref generateAnswer
2 parents fddce32 + d465f26 commit 6c69ec6

File tree

2 files changed

+20
-38
lines changed

2 files changed

+20
-38
lines changed

articles/cognitive-services/QnAMaker/How-To/metadata-generateanswer-usage.md

Lines changed: 13 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ manager: nitinme
88
ms.service: cognitive-services
99
ms.subservice: qna-maker
1010
ms.topic: article
11-
ms.date: 06/17/2019
11+
ms.date: 06/27/2019
1212
ms.author: diberry
1313
---
1414

@@ -32,13 +32,13 @@ Each QnA entity has a unique and persistent ID. You can use the ID to make updat
3232

3333
## Get answer predictions with the GenerateAnswer API
3434

35-
You use the GenerateAnswer API in your bot or application to query your knowledge base with a user question, to get the best match from the question and answer sets.
35+
You use the [GenerateAnswer API](https://docs.microsoft.com/rest/api/cognitiveservices/qnamakerruntime/runtime/generateanswer) in your bot or application to query your knowledge base with a user question, to get the best match from the question and answer sets.
3636

3737
<a name="generateanswer-endpoint"></a>
3838

3939
## Publish to get GenerateAnswer endpoint
4040

41-
After you publish your knowledge base, either from the [QnA Maker portal](https://www.qnamaker.ai), or by using the [API](https://go.microsoft.com/fwlink/?linkid=2092179), you can get the details of your GenerateAnswer endpoint.
41+
After you publish your knowledge base, either from the [QnA Maker portal](https://www.qnamaker.ai), or by using the [API](https://docs.microsoft.com/rest/api/cognitiveservices/qnamaker/knowledgebase/publish), you can get the details of your GenerateAnswer endpoint.
4242

4343
To get your endpoint details:
4444
1. Sign in to [https://www.qnamaker.ai](https://www.qnamaker.ai).
@@ -54,34 +54,21 @@ You can also get your endpoint details from the **Settings** tab of your knowled
5454

5555
## GenerateAnswer request configuration
5656

57-
You call GenerateAnswer with an HTTP POST request. For sample code that shows how to call GenerateAnswer, see the [quickstarts](../quickstarts/csharp.md).
57+
You call GenerateAnswer with an HTTP POST request. For sample code that shows how to call GenerateAnswer, see the [quickstarts](../quickstarts/csharp.md).
5858

59-
The **request URL** has the following format:
59+
The POST request uses:
60+
61+
* Required [URI parameters](https://docs.microsoft.com/rest/api/cognitiveservices/qnamakerruntime/runtime/train#uri-parameters)
62+
* Required [header property](https://docs.microsoft.com/azure/cognitive-services/qnamaker/quickstarts/get-answer-from-knowledge-base-nodejs#add-a-post-request-to-send-question-and-get-an-answer), `Authorization`, for security
63+
* Required [body properties](https://docs.microsoft.com/rest/api/cognitiveservices/qnamakerruntime/runtime/train#feedbackrecorddto).
64+
65+
The GenerateAnswer URL has the following format:
6066

6167
```
6268
https://{QnA-Maker-endpoint}/knowledgebases/{knowledge-base-ID}/generateAnswer
6369
```
6470

65-
|HTTP request property|Name|Type|Purpose|
66-
|--|--|--|--|
67-
|URL route parameter|Knowledge base ID|string|The GUID for your knowledge base.|
68-
|URL route parameter|QnAMaker endpoint host|string|The hostname of the endpoint deployed in your Azure subscription. This is available on the **Settings** page after you publish the knowledge base. |
69-
|Header|Content-Type|string|The media type of the body sent to the API. Default value is: ``|
70-
|Header|Authorization|string|Your endpoint key (EndpointKey xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).|
71-
|Post Body|JSON object|JSON|The question with settings.|
72-
73-
74-
The JSON body has several settings:
75-
76-
|JSON body property|Required|Type|Purpose|
77-
|--|--|--|--|
78-
|`question`|required|string|A user question to be sent to your knowledge base.|
79-
|`top`|optional|integer|The number of ranked results to include in the output. The default value is 1.|
80-
|`userId`|optional|string|A unique ID to identify the user. This ID will be recorded in the chat logs.|
81-
|`scoreThreshold`|optional|integer|Only answers with confidence score above this threshold will be returned. The default value is 0.|
82-
|`isTest`|optional|Boolean|If set to true, returns results from `testkb` Search index instead of published index.|
83-
|`strictFilters`|optional|string|If specified, tells QnA Maker to return only answers that have the specified metadata. Use `none` to indicate response should have no metadata filters. |
84-
|`RankerType`|optional|string|If specified as `QuestionOnly`, tells QnA Maker to search questions only. If not specified, QnA Maker searches questions and answers.
71+
Remember to set the HTTP header property of `Authorization` with a value of the string `EndpointKey ` with a trailing space then the endpoint key found on the **Settings** page.
8572

8673
An example JSON body looks like:
8774

@@ -104,19 +91,7 @@ An example JSON body looks like:
10491

10592
## GenerateAnswer response properties
10693

107-
A successful response returns a status of 200 and a JSON response.
108-
109-
|Answers property (sorted by score)|Purpose|
110-
|--|--|
111-
|score|A ranking score between 0 and 100.|
112-
|Id|A unique ID assigned to the answer.|
113-
|questions|The questions provided by the user.|
114-
|answer|The answer to the question.|
115-
|source|The name of the source from which the answer was extracted or saved in the knowledge base.|
116-
|metadata|The metadata associated with the answer.|
117-
|metadata.name|Metadata name. (string, max Length: 100, required)|
118-
|metadata.value|Metadata value. (string, max Length: 100, required)|
119-
94+
The [response](https://docs.microsoft.com/rest/api/cognitiveservices/qnamakerruntime/runtime/generateanswer#successful_query) is a JSON object including all the information you need to display the answer and the next turn in the conversation, if available.
12095

12196
```json
12297
{

articles/cognitive-services/QnAMaker/toc.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,13 @@
145145
- name: Reference
146146
items:
147147
- name: REST API Reference
148+
items:
149+
- name: Authoring APIs
150+
href: https://docs.microsoft.com/rest/api/cognitiveservices/qnamaker/knowledgebase
151+
- name: GenerateAnswer API
152+
href: https://docs.microsoft.com/rest/api/cognitiveservices/qnamakerruntime/runtime/generateanswer
153+
- name: Train API
154+
href: https://docs.microsoft.com/rest/api/cognitiveservices/qnamakerruntime/runtime/train
148155
href: https://go.microsoft.com/fwlink/?linkid=2092179
149156
- name: FAQ
150157
href: faqs.md

0 commit comments

Comments
 (0)