Runtime - Generate Answer
GenerateAnswer call to query the knowledgebase.
POST {RuntimeEndpoint}/qnamaker/knowledgebases/{kbId}/generateAnswer
URI Parameters
| Name | In | Required | Type | Description |
|---|---|---|---|---|
|
kb
|
path | True |
|
Knowledgebase id. |
|
Runtime
|
path | True |
|
QnA Maker App Service endpoint (for example: https://{qnaservice-hostname}.azurewebsites.net). |
Request Header
| Name | Required | Type | Description |
|---|---|---|---|
| Authorization | True |
|
Request Body
| Name | Type | Description |
|---|---|---|
| context |
Context object with previous QnA's information. |
|
| isTest |
|
Query against the test index. |
| qnaId |
|
Exact qnaId to fetch from the knowledgebase, this field takes priority over question. |
| question |
|
User question to query against the knowledge base. |
| rankerType |
|
Optional field. Set to 'QuestionOnly' for using a question only Ranker. |
| scoreThreshold |
|
Threshold for answers returned based on score. |
| strictFilters |
Find only answers that contain these metadata. |
|
| strictFiltersCompoundOperationType |
Optional field. Set to OR for using OR as Operation for Strict Filters. |
|
| top |
|
Max number of answers to be returned for the question. |
| userId |
|
Unique identifier for the user. Optional parameter for telemetry. For more information, refer Analytics and Telemetry. |
Responses
| Name | Type | Description |
|---|---|---|
| 200 OK |
GenerateAnswer call response. |
|
| Other Status Codes |
Error response. |
Security
Authorization
Type:
apiKey
In:
header
Examples
Successful query
Sample Request
POST {RuntimeEndpoint}/qnamaker/knowledgebases/9d091697-fb8c-4ed5-9ac0-35bf8273bfff/generateAnswer
Authorization: EndpointKey {Primary/Secondary EndpointKey}
{
"question": "qna maker and luis",
"top": 6,
"isTest": true,
"scoreThreshold": 20,
"strictFilters": [
{
"name": "category",
"value": "api"
}
],
"userId": "sd53lsY="
}
Sample Response
{
"answers": [
{
"score": 28.54820341616869,
"id": 20,
"answer": "There is no direct integration of LUIS with QnA Maker. But, in your bot code, you can use LUIS and QnA Maker together.",
"source": "Custom Editorial",
"questions": [
"How can I integrate LUIS with QnA Maker?"
],
"metadata": [
{
"name": "category",
"value": "api"
}
]
}
]
}
Definitions
| Context |
Context of a QnA |
| Error |
The error object. As per Microsoft One API guidelines - https://github.com/Microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses. |
|
Error |
One of a server-defined set of error codes. |
|
Error |
Error response. As per Microsoft One API guidelines - https://github.com/Microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses. |
|
Inner |
An object containing more specific information about the error. As per Microsoft One API guidelines - https://github.com/Microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses. |
| MetadataDTO |
Name - value pair of metadata. |
| PromptDTO |
Prompt for an answer. |
| Qna |
QnADTO - Either QnaId or QnADTO needs to be present in a PromptDTO object |
|
Qn |
Represents Search Result. |
|
Qn |
Represents List of Question Answers. |
| QueryDTO |
POST body schema to query the knowledgebase. |
|
Strict |
Optional field. Set to OR for using OR as Operation for Strict Filters. |
Context
Context of a QnA
| Name | Type | Description |
|---|---|---|
| isContextOnly |
|
To mark if a prompt is relevant only with a previous question or not. true - Do not include this QnA as search result for queries without context false - ignores context and includes this QnA in search result |
| prompts |
List of prompts associated with the answer. |
Error
The error object. As per Microsoft One API guidelines - https://github.com/Microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses.
| Name | Type | Description |
|---|---|---|
| code |
One of a server-defined set of error codes. |
|
| details |
|
An array of details about specific errors that led to this reported error. |
| innerError |
An object containing more specific information than the current object about the error. |
|
| message |
|
A human-readable representation of the error. |
| target |
|
The target of the error. |
ErrorCodeType
One of a server-defined set of error codes.
| Name | Type | Description |
|---|---|---|
| BadArgument |
|
|
| EndpointKeysError |
|
|
| ExtractionFailure |
|
|
| Forbidden |
|
|
| KbNotFound |
|
|
| NotFound |
|
|
| OperationNotFound |
|
|
| QnaRuntimeError |
|
|
| QuotaExceeded |
|
|
| SKULimitExceeded |
|
|
| ServiceError |
|
|
| Unauthorized |
|
|
| Unspecified |
|
|
| ValidationFailure |
|
ErrorResponse
Error response. As per Microsoft One API guidelines - https://github.com/Microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses.
| Name | Type | Description |
|---|---|---|
| error |
The error object. |
InnerErrorModel
An object containing more specific information about the error. As per Microsoft One API guidelines - https://github.com/Microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses.
| Name | Type | Description |
|---|---|---|
| code |
|
A more specific error code than was provided by the containing error. |
| innerError |
An object containing more specific information than the current object about the error. |
MetadataDTO
Name - value pair of metadata.
| Name | Type | Description |
|---|---|---|
| name |
|
Metadata name. |
| value |
|
Metadata value. |
PromptDTO
Prompt for an answer.
| Name | Type | Description |
|---|---|---|
| displayOrder |
|
Index of the prompt - used in ordering of the prompts |
| displayText |
|
Text displayed to represent a follow up question prompt |
| qna |
QnADTO - Either QnaId or QnADTO needs to be present in a PromptDTO object |
|
| qnaId |
|
Qna id corresponding to the prompt - if QnaId is present, QnADTO object is ignored. |
Qna
QnADTO - Either QnaId or QnADTO needs to be present in a PromptDTO object
| Name | Type | Description |
|---|---|---|
| answer |
|
Answer text |
| context |
Context of a QnA |
|
| id |
|
Unique id for the Q-A. |
| metadata |
List of metadata associated with the answer. |
|
| questions |
|
List of questions associated with the answer. |
| source |
|
Source from which Q-A was indexed. eg. https://docs.microsoft.com/en-us/azure/cognitive-services/QnAMaker/FAQs |
QnASearchResult
Represents Search Result.
| Name | Type | Description |
|---|---|---|
| answer |
|
Answer. |
| context |
Context object of the QnA |
|
| id |
|
Id of the QnA result. |
| metadata |
List of metadata. |
|
| questions |
|
List of questions. |
| score |
|
Search result score. |
| source |
|
Source of QnA result. |
QnASearchResultList
Represents List of Question Answers.
| Name | Type | Description |
|---|---|---|
| answers |
Represents Search Result list. |
QueryDTO
POST body schema to query the knowledgebase.
| Name | Type | Description |
|---|---|---|
| context |
Context object with previous QnA's information. |
|
| isTest |
|
Query against the test index. |
| qnaId |
|
Exact qnaId to fetch from the knowledgebase, this field takes priority over question. |
| question |
|
User question to query against the knowledge base. |
| rankerType |
|
Optional field. Set to 'QuestionOnly' for using a question only Ranker. |
| scoreThreshold |
|
Threshold for answers returned based on score. |
| strictFilters |
Find only answers that contain these metadata. |
|
| strictFiltersCompoundOperationType |
Optional field. Set to OR for using OR as Operation for Strict Filters. |
|
| top |
|
Max number of answers to be returned for the question. |
| userId |
|
Unique identifier for the user. Optional parameter for telemetry. For more information, refer Analytics and Telemetry. |
StrictFiltersCompoundOperationType
Optional field. Set to OR for using OR as Operation for Strict Filters.
| Name | Type | Description |
|---|---|---|
| AND |
|
|
| OR |
|