Knowledgebase - Create

建立新知識庫的非同步作業。

POST {Endpoint}/qnamaker/v5.0-preview.2/knowledgebases/create

URI 參數

名稱 位於 必要 類型 Description
Endpoint
path True

string

支持的認知服務端點 (例如,https://< qnamaker-resource-name >.api.cognitiveservices.azure.com) 。

要求標頭

名稱 必要 類型 Description
Ocp-Apim-Subscription-Key True

string

要求本文

名稱 必要 類型 Description
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 標識碼是由服務指派,因此應該省略。

urls

string[]

要用於擷取 Q-A 的 URL 清單。

回應

名稱 類型 Description
202 Accepted

Operation

異步操作的詳細數據。

Other Status Codes

ErrorResponse

錯誤回應。

安全性

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"
}

定義

名稱 Description
Context

與要更新之 Qna 相關聯的內容。

CreateKbDTO

CreateKb 作業的後文架構。

Error

error 物件。 根據 Microsoft One API 指導方針 - https://github.com/Microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses

ErrorCodeType

其中一組伺服器定義的錯誤碼。

ErrorResponse

錯誤回應。 根據 Microsoft One API 指導方針 - https://github.com/Microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses

FileDTO

DTO 可保存已上傳檔案的詳細數據。

InnerErrorModel

物件,包含錯誤的詳細資訊。 根據 Microsoft One API 指導方針 - https://github.com/Microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses

MetadataDTO

名稱 -元數據的值組。

Operation

記錄以追蹤長時間執行的作業。

OperationStateType

作業狀態。

PromptDTO

提示輸入答案。

Qna

QnADTO - QnaId 或 QnADTO 必須存在於 PromptDTO 物件中

QnADTO

Q-A 物件。

Context

與要更新之 Qna 相關聯的內容。

名稱 類型 Description
isContextOnly

boolean

若要標示提示是否只與先前的問題相關。 true - 請勿將此 QnA 作為沒有內容 false 的查詢搜尋結果 - 忽略內容並在搜尋結果中包含此 QnA

promptsToAdd

PromptDTO[]

要新增至 qna 的提示清單。

promptsToDelete

integer[]

要刪除之 qna 相關聯的提示清單

CreateKbDTO

CreateKb 作業的後文架構。

名稱 類型 Description
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 標識碼是由服務指派,因此應該省略。

urls

string[]

要用於擷取 Q-A 的 URL 清單。

Error

error 物件。 根據 Microsoft One API 指導方針 - https://github.com/Microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses

名稱 類型 Description
code

ErrorCodeType

其中一組伺服器定義的錯誤碼。

details

Error[]

導致此錯誤之特定錯誤的詳細數據陣列。

innerError

InnerErrorModel

物件,包含比目前對象有關錯誤更具體的資訊。

message

string

人類可讀取的錯誤表示法。

target

string

錯誤的目標。

ErrorCodeType

其中一組伺服器定義的錯誤碼。

名稱 類型 Description
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

名稱 類型 Description
error

Error

error 物件。

FileDTO

DTO 可保存已上傳檔案的詳細數據。

名稱 類型 Description
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

名稱 類型 Description
code

string

比包含的錯誤所提供更明確的錯誤碼。

innerError

InnerErrorModel

物件,包含比目前對象有關錯誤更具體的資訊。

MetadataDTO

名稱 -元數據的值組。

名稱 類型 Description
name

string

中繼資料名稱。

value

string

中繼資料值。

Operation

記錄以追蹤長時間執行的作業。

名稱 類型 Description
createdTimestamp

string

建立作業時的時間戳。

errorResponse

ErrorResponse

發生失敗時的錯誤詳細數據。

lastActionTimestamp

string

輸入目前狀態時的時間戳。

operationId

string

作業識別碼。

operationState

OperationStateType

作業狀態。

resourceLocation

string

已完成資源的目標資源位置相對 URI。

userId

string

使用者識別碼

OperationStateType

作業狀態。

名稱 類型 Description
Failed

string

NotStarted

string

Running

string

Succeeded

string

PromptDTO

提示輸入答案。

名稱 類型 Description
displayOrder

integer

提示的索引 - 用於排序提示

displayText

string

顯示代表後續問題提示的文字

qna

Qna

QnADTO - QnaId 或 QnADTO 必須存在於 PromptDTO 物件中

qnaId

integer

對應至提示的 Qna 識別碼 - 如果 QnaId 存在,則會忽略 QnADTO 物件。

Qna

QnADTO - QnaId 或 QnADTO 必須存在於 PromptDTO 物件中

名稱 類型 Description
answer

string

回應簡訊

context

Context

QnA 的內容

id

integer

Q-A 的唯一標識碼。

lastUpdatedTimestamp

string

上次更新 QnA 時的時間戳。

metadata

MetadataDTO[]

與答案相關聯的元數據清單。

questions

string[]

與答案相關聯的問題清單。

source

string

Q-A 編製索引的來源。例如 https://docs.microsoft.com/en-us/azure/cognitive-services/QnAMaker/FAQs

QnADTO

Q-A 物件。

名稱 類型 Description
answer

string

回應簡訊

context

Context

QnA 的內容

id

integer

Q-A 的唯一標識碼。

lastUpdatedTimestamp

string

上次更新 QnA 時的時間戳。

metadata

MetadataDTO[]

與答案相關聯的元數據清單。

questions

string[]

與答案相關聯的問題清單。

source

string

Q-A 編製索引的來源。例如 https://docs.microsoft.com/en-us/azure/cognitive-services/QnAMaker/FAQs