你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
Knowledgebase - Create
用于创建新知识库的异步操作。
POST {Endpoint}/qnamaker/v5.0-preview.2/knowledgebases/create
URI 参数
名称 | 在 | 必需 | 类型 | 说明 |
---|---|---|---|---|
Endpoint
|
path | True |
string |
支持的认知服务终结点 (例如,https://< qnamaker-resource-name >.api.cognitiveservices.azure.com) 。 |
请求头
名称 | 必需 | 类型 | 说明 |
---|---|---|---|
Ocp-Apim-Subscription-Key | True |
string |
请求正文
名称 | 必需 | 类型 | 说明 |
---|---|---|---|
name | True |
string |
知识库的友好名称。 |
defaultAnswer |
string |
如果在 KB 中找不到匹配项,则发送给用户的默认答案。 |
|
defaultAnswerUsedForExtraction |
string |
在任何 Q-A 中用作答案的文本字符串,该 Q-A 没有从文档中提取的答案,但具有层次结构。 当 EnableHierarchicalExtraction 字段设置为 True 时是必需的。 |
|
enableHierarchicalExtraction |
boolean |
启用从文件和 URL 中分层提取 Q-A。 如果此字段不存在,将被视为 False 的值。 |
|
enableMultipleLanguages |
boolean |
设置为 true 以允许为同一资源使用不同语言创建 KB。 |
|
files |
FileDTO[] |
要从中提取 Q-A 的文件列表。 |
|
language |
string |
知识库的语言。 请 在此处找到支持的语言列表。 |
|
qnaList |
QnADTO[] |
要添加到知识库的 Q-A (QnADTO) 的列表。 Q-A ID 由服务分配,应省略。 |
|
urls |
string[] |
要用于提取 Q-A 的 URL 列表。 |
响应
名称 | 类型 | 说明 |
---|---|---|
202 Accepted |
异步操作的详细信息。 |
|
Other Status Codes |
错误响应。 |
安全性
Ocp-Apim-Subscription-Key
Type:
apiKey
In:
header
示例
Successful query
Sample Request
POST {Endpoint}/qnamaker/v5.0-preview.2/knowledgebases/create
{
"name": "QnA Maker FAQ",
"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": []
},
{
"id": 0,
"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": [
"How do I programmatically create a KB?"
],
"metadata": [
{
"name": "category",
"value": "api"
}
],
"context": {
"isContextOnly": false,
"prompts": [
{
"displayOrder": 1,
"displayText": "Update KB",
"qna": {
"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",
"questions": [
"How do I programmatically update my KB?"
],
"metadata": [
{
"name": "category",
"value": "api"
}
],
"context": {
"isContextOnly": false,
"prompts": [
{
"displayOrder": 1,
"displayText": "Refresh Endpoint Keys",
"qna": {
"answer": "You can use our REST apis to refresh endpoint keys. See here for details: https://docs.microsoft.com/en-us/rest/api/cognitiveservices/qnamaker/endpointkeys/refreshkeys",
"questions": [
"How do I programmatically refresh endpoint keys?"
]
}
}
]
}
}
}
]
}
}
],
"urls": [
"https://docs.microsoft.com/en-in/azure/cognitive-services/qnamaker/faqs",
"https://docs.microsoft.com/en-us/bot-framework/resources-bot-framework-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"
}
]
}
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"
}
定义
名称 | 说明 |
---|---|
Context |
与要更新的 Qna 关联的上下文。 |
Create |
CreateKb 操作的后正文架构。 |
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。 |
MetadataDTO |
名称 - 元数据的值对。 |
Operation |
用于跟踪长时间运行的操作的记录。 |
Operation |
操作状态。 |
PromptDTO |
提示输入答案。 |
Qna |
QnADTO - QnaId 或 QnADTO 需要存在于 PromptDTO 对象中 |
QnADTO |
Q-A 对象。 |
Context
与要更新的 Qna 关联的上下文。
名称 | 类型 | 说明 |
---|---|---|
isContextOnly |
boolean |
标记提示是否仅与上一个问题相关。 true - 不要将此 QnA 作为没有上下文 false 的查询的搜索结果包括在内 - 忽略上下文并在搜索结果中包含此 QnA |
promptsToAdd |
要添加到 qna 的提示列表。 |
|
promptsToDelete |
integer[] |
与要删除的 qna 关联的提示列表 |
CreateKbDTO
CreateKb 操作的后正文架构。
名称 | 类型 | 说明 |
---|---|---|
defaultAnswer |
string |
如果在 KB 中找不到匹配项,则发送给用户的默认答案。 |
defaultAnswerUsedForExtraction |
string |
在任何 Q-A 中用作答案的文本字符串,该 Q-A 没有从文档中提取的答案,但具有层次结构。 当 EnableHierarchicalExtraction 字段设置为 True 时是必需的。 |
enableHierarchicalExtraction |
boolean |
启用从文件和 URL 中分层提取 Q-A。 如果此字段不存在,将被视为 False 的值。 |
enableMultipleLanguages |
boolean |
设置为 true 以允许为同一资源使用不同语言创建 KB。 |
files |
FileDTO[] |
要从中提取 Q-A 的文件列表。 |
language |
string |
知识库的语言。 请 在此处找到支持的语言列表。 |
name |
string |
知识库的友好名称。 |
qnaList |
QnADTO[] |
要添加到知识库的 Q-A (QnADTO) 的列表。 Q-A ID 由服务分配,应省略。 |
urls |
string[] |
要用于提取 Q-A 的 URL 列表。 |
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 |
一个 对象,该对象包含比当前对象更具体的错误信息。 |
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 |