你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
Knowledgebase - Update
用于修改知识库的异步操作。
PATCH {Endpoint}/qnamaker/v5.0-preview.2/knowledgebases/{kbId}
URI 参数
名称 | 在 | 必需 | 类型 | 说明 |
---|---|---|---|---|
Endpoint
|
path | True |
string |
支持的认知服务终结点 (例如,https://< qnamaker-resource-name >.api.cognitiveservices.azure.com) 。 |
kb
|
path | True |
string |
知识库 ID。 |
请求头
名称 | 必需 | 类型 | 说明 |
---|---|---|---|
Ocp-Apim-Subscription-Key | True |
string |
请求正文
名称 | 类型 | 说明 |
---|---|---|
add |
用于添加操作的 CreateKbInputDTO 实例 |
|
defaultAnswerUsedForExtraction |
string |
在任何 Q-A 中用作答案的文本字符串,该 Q-A 没有从文档中提取的答案,但具有层次结构。 当 EnableHierarchicalExtraction 字段设置为 True 时是必需的。 |
delete |
用于删除操作的 DeleteKbContentsDTO 实例 |
|
enableHierarchicalExtraction |
boolean |
从文件和 URL 启用 Q-A 的分层提取。 如果此字段不存在,将使用 KB 创建期间设置的值。 |
update |
Update 操作的 UpdateKbContentsDTO 实例 |
响应
名称 | 类型 | 说明 |
---|---|---|
202 Accepted |
异步操作的详细信息。 Headers Location: string |
|
Other Status Codes |
错误响应。 |
安全性
Ocp-Apim-Subscription-Key
Type:
apiKey
In:
header
示例
Successful query
Sample Request
PATCH {Endpoint}/qnamaker/v5.0-preview.2/knowledgebases/9d091697-fb8c-4ed5-9ac0-35bf8273bfff
{
"add": {
"qnaList": [
{
"id": 0,
"answer": "You can change the default message if you use the QnAMakerDialog. See this for details: https://docs.botframework.com/en-us/azure-bot-service/templates/qnamaker/#navtitle",
"source": "Custom Editorial",
"questions": [
"How can I change the default message from QnA Maker?"
],
"metadata": []
}
],
"urls": [
"https://docs.microsoft.com/en-us/azure/cognitive-services/Emotion/FAQ"
],
"files": [
{
"fileName": "SurfaceManual.pdf",
"fileUri": "https://download.microsoft.com/download/2/9/B/29B20383-302C-4517-A006-B0186F04BE28/surface-pro-4-user-guide-EN.pdf"
}
]
},
"delete": {
"ids": [
13,
35
]
},
"update": {
"name": "QnA Maker FAQ Prompts Bot",
"qnaList": [
{
"id": 2,
"answer": "You can use our REST apis to create a KB. See here for details: https://docs.microsoft.com/en-us/rest/api/cognitiveservices/qnamaker/knowledgebase/create",
"source": "Custom Editorial",
"questions": {
"add": [],
"delete": []
},
"metadata": {
"add": [],
"delete": []
},
"context": {
"isContextOnly": false,
"promptsToAdd": [
{
"displayText": "Add Prompts",
"displayOrder": 0,
"qna": {
"id": 0,
"answer": "Click here to know more https://docs.microsoft.com/en-us/azure/cognitive-services/qnamaker/how-to/multiturn-conversation",
"source": "Editorial",
"questions": [
"How can I add prompts?"
],
"metadata": [],
"context": {
"isContextOnly": false,
"prompts": []
}
},
"qnaId": 0
},
{
"displayText": "Delete Prompts",
"displayOrder": 0,
"qna": {
"id": 0,
"answer": "Click here to know more https://docs.microsoft.com/en-us/azure/cognitive-services/qnamaker/how-to/multiturn-conversation",
"source": "Editorial",
"questions": [
"How can I delete delete prompts?"
],
"metadata": [],
"context": {
"isContextOnly": false,
"prompts": []
}
},
"qnaId": 0
},
{
"displayText": "Update Knowledgebase",
"displayOrder": 0,
"qna": null,
"qnaId": 3
}
],
"promptsToDelete": [
3
]
}
},
{
"id": 3,
"answer": "You can use our REST apis to update your KB. See here for details: https://docs.microsoft.com/en-us/rest/api/cognitiveservices/qnamaker/knowledgebase/update",
"source": "Custom Editorial",
"questions": {
"add": [],
"delete": []
},
"metadata": {
"delete": [
{
"name": "category",
"value": "api"
}
],
"add": [
{
"name": "category",
"value": "programmatic"
}
]
},
"context": {
"isContextOnly": false,
"promptsToAdd": [
{
"displayText": "Regenerate Endpoint keys",
"displayOrder": 1,
"qna": null,
"qnaId": 4
}
],
"promptsToDelete": [
4
]
}
}
]
}
}
Sample Response
{
"operationState": "NotStarted",
"createdTimestamp": "2018-03-19T07:38:46Z",
"lastActionTimestamp": "2018-03-19T07:39:29Z",
"userId": "86bb8390-56c0-42c2-9f81-3de161981191",
"operationId": "03a4f4ce-30a6-4ec6-b436-02bcdf6153e1"
}
定义
名称 | 说明 |
---|---|
Add |
用于添加操作的 CreateKbInputDTO 实例 |
Context |
与要更新的 Qna 关联的上下文。 |
Delete |
用于删除操作的 DeleteKbContentsDTO 实例 |
Error |
错误对象。 根据 Microsoft One API 指南 - https://github.com/Microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses。 |
Error |
服务器定义的一组错误代码中的一个。 |
Error |
错误响应。 根据 Microsoft One API 指南 - https://github.com/Microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses。 |
FileDTO |
用于保存已上传文件的详细信息的 DTO。 |
Inner |
包含有关错误的更具体信息的对象。 根据 Microsoft One API 指南 - https://github.com/Microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses。 |
Metadata |
与要更新的答案关联的元数据列表 |
MetadataDTO |
名称 - 元数据的值对。 |
Operation |
记录以跟踪长时间运行的操作。 |
Operation |
操作状态。 |
PromptDTO |
提示输入答案。 |
Qna |
QnADTO - QnaId 或 QnADTO 需要存在于 PromptDTO 对象中 |
QnADTO |
Q-A 对象。 |
Questions |
与答案关联的问题列表。 |
Update |
Update 操作的 UpdateKbContentsDTO 实例 |
Update |
包含要更新的 QnA 列表 |
Update |
更新 Qna 列表的 PATCH 正文架构 |
Add
用于添加操作的 CreateKbInputDTO 实例
名称 | 类型 | 说明 |
---|---|---|
files |
FileDTO[] |
要添加到知识库的文件列表。 |
qnaList |
QnADTO[] |
要添加到索引的 QNA 列表。 ID 由服务生成,应省略。 |
urls |
string[] |
要添加到知识库的 URL 列表。 |
Context
与要更新的 Qna 关联的上下文。
名称 | 类型 | 说明 |
---|---|---|
isContextOnly |
boolean |
标记提示是否仅与上一个问题相关。 true - 对于没有上下文 false 的查询,不要将此 QnA 作为搜索结果包括在内 - 忽略上下文并在搜索结果中包括此 QnA |
promptsToAdd |
要添加到 qna 的提示列表。 |
|
promptsToDelete |
integer[] |
与要删除的 qna 关联的提示列表 |
Delete
用于删除操作的 DeleteKbContentsDTO 实例
名称 | 类型 | 说明 |
---|---|---|
ids |
integer[] |
要删除的 Qna ID 列表 |
sources |
string[] |
要从知识库中删除的源列表。 |
Error
错误对象。 根据 Microsoft One 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 |
string |
|
EndpointKeysError |
string |
|
ExtractionFailure |
string |
|
Forbidden |
string |
|
KbNotFound |
string |
|
NotFound |
string |
|
OperationNotFound |
string |
|
QnaRuntimeError |
string |
|
QuotaExceeded |
string |
|
SKULimitExceeded |
string |
|
ServiceError |
string |
|
Unauthorized |
string |
|
Unspecified |
string |
|
ValidationFailure |
string |
ErrorResponse
错误响应。 根据 Microsoft One API 指南 - https://github.com/Microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses。
名称 | 类型 | 说明 |
---|---|---|
error |
错误对象。 |
FileDTO
用于保存已上传文件的详细信息的 DTO。
名称 | 类型 | 说明 |
---|---|---|
fileName |
string |
文件名。 支持的文件类型为“.tsv”、“.pdf”、“.txt”、“.docx”、“.xlsx”。 |
fileUri |
string |
文件的公共 URI。 |
isUnstructured |
boolean |
可选 标志,用于指定给定文件是否为非结构化文件。 |
InnerErrorModel
包含有关错误的更具体信息的对象。 根据 Microsoft One API 指南 - https://github.com/Microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses。
名称 | 类型 | 说明 |
---|---|---|
code |
string |
比包含的错误提供的错误代码更具体的代码。 |
innerError |
一个 对象,该对象包含比当前对象更具体的错误信息。 |
Metadata
与要更新的答案关联的元数据列表
名称 | 类型 | 说明 |
---|---|---|
add |
与要添加的答案关联的元数据列表 |
|
delete |
与要删除的答案关联的元数据列表 |
MetadataDTO
名称 - 元数据的值对。
名称 | 类型 | 说明 |
---|---|---|
name |
string |
元数据名称。 |
value |
string |
元数据值。 |
Operation
记录以跟踪长时间运行的操作。
名称 | 类型 | 说明 |
---|---|---|
createdTimestamp |
string |
创建操作时的时间戳。 |
errorResponse |
失败时的错误详细信息。 |
|
lastActionTimestamp |
string |
输入当前状态时的时间戳。 |
operationId |
string |
操作 ID。 |
operationState |
操作状态。 |
|
resourceLocation |
string |
已完成资源的目标资源位置的相对 URI。 |
userId |
string |
用户 ID |
OperationStateType
操作状态。
名称 | 类型 | 说明 |
---|---|---|
Failed |
string |
|
NotStarted |
string |
|
Running |
string |
|
Succeeded |
string |
PromptDTO
提示输入答案。
名称 | 类型 | 说明 |
---|---|---|
displayOrder |
integer |
提示索引 - 用于对提示进行排序 |
displayText |
string |
显示用于表示跟进问题提示的文本 |
qna |
QnADTO - QnaId 或 QnADTO 需要存在于 PromptDTO 对象中 |
|
qnaId |
integer |
对应于提示的 Qna ID - 如果存在 QnaId,则忽略 QnADTO 对象。 |
Qna
QnADTO - QnaId 或 QnADTO 需要存在于 PromptDTO 对象中
名称 | 类型 | 说明 |
---|---|---|
answer |
string |
回复短信 |
context |
QnA 的上下文 |
|
id |
integer |
Q-A 的唯一 ID。 |
lastUpdatedTimestamp |
string |
上次更新 QnA 时的时间戳。 |
metadata |
与答案关联的元数据列表。 |
|
questions |
string[] |
与答案关联的问题列表。 |
source |
string |
从中为 Q-A 编制索引的源。例如 https://docs.microsoft.com/en-us/azure/cognitive-services/QnAMaker/FAQs |
QnADTO
Q-A 对象。
名称 | 类型 | 说明 |
---|---|---|
answer |
string |
回复短信 |
context |
QnA 的上下文 |
|
id |
integer |
Q-A 的唯一 ID。 |
lastUpdatedTimestamp |
string |
上次更新 QnA 时的时间戳。 |
metadata |
与答案关联的元数据列表。 |
|
questions |
string[] |
与答案关联的问题列表。 |
source |
string |
从中为 Q-A 编制索引的源。例如 https://docs.microsoft.com/en-us/azure/cognitive-services/QnAMaker/FAQs |
Questions
与答案关联的问题列表。
名称 | 类型 | 说明 |
---|---|---|
add |
string[] |
要添加的问题列表 |
delete |
string[] |
要删除的问题列表。 |
Update
Update 操作的 UpdateKbContentsDTO 实例
名称 | 类型 | 说明 |
---|---|---|
defaultAnswer |
string |
如果在知识库中找不到合适的匹配项,则向用户发送默认答案。 |
name |
string |
知识库的友好名称。 |
qnaList |
要添加到知识库的 Q-A (UpdateQnaDTO) 列表。 |
|
urls |
string[] |
要刷新的现有 URL 的列表。 将再次提取内容并重新编制索引。 |
UpdateKbOperationDTO
包含要更新的 QnA 列表
名称 | 类型 | 说明 |
---|---|---|
add |
用于添加操作的 CreateKbInputDTO 实例 |
|
defaultAnswerUsedForExtraction |
string |
在任何 Q-A 中用作答案的文本字符串,该 Q-A 没有从文档中提取的答案,但具有层次结构。 当 EnableHierarchicalExtraction 字段设置为 True 时是必需的。 |
delete |
用于删除操作的 DeleteKbContentsDTO 实例 |
|
enableHierarchicalExtraction |
boolean |
从文件和 URL 启用 Q-A 的分层提取。 如果此字段不存在,将使用 KB 创建期间设置的值。 |
update |
Update 操作的 UpdateKbContentsDTO 实例 |
UpdateQnaDTO
更新 Qna 列表的 PATCH 正文架构
名称 | 类型 | 说明 |
---|---|---|
answer |
string |
回复短信 |
context |
与要更新的 Qna 关联的上下文。 |
|
id |
integer |
Q-A 的唯一 ID |
metadata |
与要更新的答案关联的元数据列表 |
|
questions |
与答案关联的问题列表。 |
|
source |
string |
从中为 Q-A 编制索引的源。例如 https://docs.microsoft.com/en-us/azure/cognitive-services/QnAMaker/FAQs |