你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
Runtime - Generate Answer
用于查询知识库的 GenerateAnswer 调用。
POST {RuntimeEndpoint}/qnamaker/knowledgebases/{kbId}/generateAnswer
URI 参数
名称 | 在 | 必需 | 类型 | 说明 |
---|---|---|---|---|
kb
|
path | True |
string |
知识库 ID。 |
Runtime
|
path | True |
string |
QnA Maker 应用服务终结点(例如:https://{qnaservice-hostname}.azurewebsites.net)。 |
请求头
名称 | 必需 | 类型 | 说明 |
---|---|---|---|
Authorization | True |
string |
请求正文
名称 | 类型 | 说明 |
---|---|---|
context |
包含先前 QnA 信息的上下文对象。 |
|
isTest |
boolean |
针对测试索引进行查询。 |
qnaId |
string |
要从知识库中提取的确切 qnaId,此字段优先于问题。 |
question |
string |
要查询知识库的用户问题。 |
rankerType |
string |
可选字段。 设置为“QuestionOnly”以仅使用问题排名器。 |
scoreThreshold |
number |
根据分数返回的答案的阈值。 |
strictFilters |
仅查找包含这些元数据的答案。 |
|
strictFiltersCompoundOperationType |
可选字段。 设置为 OR 以将 OR 用作严格筛选器的作。 |
|
top |
integer (int32) |
要为问题返回的最大答案数。 |
userId |
string |
用户的唯一标识符。 遥测的可选参数。 有关详细信息,请参阅 分析和遥测。 |
响应
名称 | 类型 | 说明 |
---|---|---|
200 OK |
GenerateAnswer 调用响应。 |
|
Other Status Codes |
错误响应。 |
安全性
Authorization
类型:
apiKey
在:
header
示例
Successful query
示例请求
POST {RuntimeEndpoint}/qnamaker/knowledgebases/9d091697-fb8c-4ed5-9ac0-35bf8273bfff/generateAnswer
{
"question": "qna maker and luis",
"top": 6,
"isTest": true,
"scoreThreshold": 20,
"strictFilters": [
{
"name": "category",
"value": "api"
}
],
"userId": "sd53lsY="
}
示例响应
{
"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"
}
]
}
]
}
定义
名称 | 说明 |
---|---|
Context |
QnA 的上下文 |
Error |
错误对象。 根据Microsoft一个 API 指南 - https://github.com/Microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses。 |
Error |
服务器定义的错误代码集之一。 |
Error |
错误响应。 根据Microsoft一个 API 指南 - https://github.com/Microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses。 |
Inner |
包含有关错误的更具体信息的对象。 根据Microsoft一个 API 指南 - https://github.com/Microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses。 |
MetadataDTO |
名称 - 元数据值对。 |
PromptDTO |
提示输入答案。 |
Qna |
QnADTO - QnaId 或 QnADTO 需要存在于 PromptDTO 对象中 |
Qn |
表示搜索结果。 |
Qn |
表示问题解答列表。 |
QueryDTO |
用于查询知识库的 POST 正文架构。 |
Strict |
可选字段。 设置为 OR 以将 OR 用作严格筛选器的作。 |
Context
QnA 的上下文
名称 | 类型 | 说明 |
---|---|---|
isContextOnly |
boolean |
如果提示仅与前面的问题相关,则进行标记。 true - 请勿将此 QnA 作为没有上下文 false 的查询的搜索结果包含 - 忽略上下文并在搜索结果中包含此 QnA |
prompts |
与答案关联的提示列表。 |
Error
错误对象。 根据Microsoft一个 API 指南 - https://github.com/Microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses。
名称 | 类型 | 说明 |
---|---|---|
code |
服务器定义的错误代码集之一。 |
|
details |
Error[] |
导致此报告错误的特定错误的详细信息数组。 |
innerError |
包含与当前对象有关错误的更具体信息的对象。 |
|
message |
string |
错误的人工可读表示形式。 |
target |
string |
错误的目标。 |
ErrorCodeType
服务器定义的错误代码集之一。
值 | 说明 |
---|---|
BadArgument | |
EndpointKeysError | |
ExtractionFailure | |
Forbidden | |
KbNotFound | |
NotFound | |
OperationNotFound | |
QnaRuntimeError | |
QuotaExceeded | |
SKULimitExceeded | |
ServiceError | |
Unauthorized | |
Unspecified | |
ValidationFailure |
ErrorResponse
错误响应。 根据Microsoft一个 API 指南 - https://github.com/Microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses。
名称 | 类型 | 说明 |
---|---|---|
error |
错误对象。 |
InnerErrorModel
包含有关错误的更具体信息的对象。 根据Microsoft一个 API 指南 - https://github.com/Microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses。
名称 | 类型 | 说明 |
---|---|---|
code |
string |
比包含的错误提供的错误代码更具体。 |
innerError |
包含与当前对象有关错误的更具体信息的对象。 |
MetadataDTO
名称 - 元数据值对。
名称 | 类型 | 说明 |
---|---|---|
name |
string minLength: 1maxLength: 100 |
元数据名称。 |
value |
string minLength: 1maxLength: 500 |
元数据值。 |
PromptDTO
提示输入答案。
名称 | 类型 | 说明 |
---|---|---|
displayOrder |
integer (int32) |
提示的索引 - 用于提示排序 |
displayText |
string maxLength: 200 |
显示以表示后续问题提示的文本 |
qna |
QnADTO - QnaId 或 QnADTO 需要存在于 PromptDTO 对象中 |
|
qnaId |
integer (int32) |
与提示对应的 Qna ID - 如果 QnaId 存在,则忽略 QnADTO 对象。 |
Qna
QnADTO - QnaId 或 QnADTO 需要存在于 PromptDTO 对象中
名称 | 类型 | 说明 |
---|---|---|
answer |
string minLength: 1maxLength: 25000 |
应答文本 |
context |
QnA 的上下文 |
|
id |
integer (int32) |
Q-A 的唯一 ID。 |
metadata |
与答案关联的元数据列表。 |
|
questions |
string[] |
与答案关联的问题列表。 |
source |
string maxLength: 300 |
从中为 Q-A 编制索引的源。例如https://docs.microsoft.com/en-us/azure/cognitive-services/QnAMaker/FAQs |
QnASearchResult
表示搜索结果。
名称 | 类型 | 说明 |
---|---|---|
answer |
string |
答。 |
context |
QnA 的上下文对象 |
|
id |
integer (int32) |
QnA 结果的 ID。 |
metadata |
元数据列表。 |
|
questions |
string[] |
问题列表。 |
score |
number |
搜索结果分数。 |
source |
string |
QnA 结果的来源。 |
QnASearchResultList
表示问题解答列表。
名称 | 类型 | 说明 |
---|---|---|
answers |
表示搜索结果列表。 |
QueryDTO
用于查询知识库的 POST 正文架构。
名称 | 类型 | 说明 |
---|---|---|
context |
包含先前 QnA 信息的上下文对象。 |
|
isTest |
boolean |
针对测试索引进行查询。 |
qnaId |
string |
要从知识库中提取的确切 qnaId,此字段优先于问题。 |
question |
string |
要查询知识库的用户问题。 |
rankerType |
string |
可选字段。 设置为“QuestionOnly”以仅使用问题排名器。 |
scoreThreshold |
number |
根据分数返回的答案的阈值。 |
strictFilters |
仅查找包含这些元数据的答案。 |
|
strictFiltersCompoundOperationType |
可选字段。 设置为 OR 以将 OR 用作严格筛选器的作。 |
|
top |
integer (int32) |
要为问题返回的最大答案数。 |
userId |
string |
用户的唯一标识符。 遥测的可选参数。 有关详细信息,请参阅 分析和遥测。 |
StrictFiltersCompoundOperationType
可选字段。 设置为 OR 以将 OR 用作严格筛选器的作。
值 | 说明 |
---|---|
AND | |
OR |