共用方式為


Runtime - Generate Answer

GenerateAnswer 呼叫以查詢知識庫。

POST {RuntimeEndpoint}/qnamaker/knowledgebases/{kbId}/generateAnswer

URI 參數

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

string

知識庫標識碼。

RuntimeEndpoint
path True

string

QnA Maker App Service 端點(例如:https://{qnaservice-hostname}.azurewebsites.net)。

要求標頭

名稱 必要 類型 Description
Authorization True

string

要求本文

名稱 類型 Description
context

Context

具有先前 QnA 資訊的內容物件。

isTest

boolean

針對測試索引進行查詢。

qnaId

string

要從知識庫擷取的確切 qnaId,此字段優先於問題。

question

string

要查詢知識庫的用戶問題。

rankerType

string

選擇性欄位。 設定為 『QuestionOnly』,以便只使用問題排名器。

scoreThreshold

number

根據分數傳回的答案閾值。

strictFilters

MetadataDTO[]

只尋找包含這些元數據的解答。

strictFiltersCompoundOperationType

StrictFiltersCompoundOperationType

選擇性欄位。 設定為 OR 以使用 OR 做為嚴格篩選的作業。

top

integer (int32)

要針對問題傳回的答案數目上限。

userId

string

使用者的唯一標識碼。 遙測的選擇性參數。 如需詳細資訊,請參閱 Analytics 和 Telemetry

回應

名稱 類型 Description
200 OK

QnASearchResultList

GenerateAnswer 呼叫回應。

Other Status Codes

ErrorResponse

錯誤回應。

安全性

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

定義

名稱 Description
Context

QnA 的內容

Error

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

ErrorCodeType

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

ErrorResponse

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

InnerErrorModel

物件,包含有關錯誤的更特定資訊。 根據Microsoft一個 API 指導方針 - https://github.com/Microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses

MetadataDTO

名稱 -元數據的值組。

PromptDTO

提示輸入答案。

Qna

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

QnASearchResult

代表搜尋結果。

QnASearchResultList

代表問題解答清單。

QueryDTO

POST 本文架構以查詢知識庫。

StrictFiltersCompoundOperationType

選擇性欄位。 設定為 OR 以使用 OR 做為嚴格篩選的作業。

Context

QnA 的內容

名稱 類型 Description
isContextOnly

boolean

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

prompts

PromptDTO[]

與答案相關聯的提示清單。

Error

error 物件。 根據Microsoft一個 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
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

名稱 類型 Description
error

Error

error 物件。

InnerErrorModel

物件,包含有關錯誤的更特定資訊。 根據Microsoft一個 API 指導方針 - https://github.com/Microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses

名稱 類型 Description
code

string

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

innerError

InnerErrorModel

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

MetadataDTO

名稱 -元數據的值組。

名稱 類型 Description
name

string

minLength: 1
maxLength: 100

元數據名稱。

value

string

minLength: 1
maxLength: 500

元數據值。

PromptDTO

提示輸入答案。

名稱 類型 Description
displayOrder

integer (int32)

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

displayText

string

maxLength: 200

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

qna

Qna

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

qnaId

integer (int32)

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

Qna

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

名稱 類型 Description
answer

string

minLength: 1
maxLength: 25000

回應文字

context

Context

QnA 的內容

id

integer (int32)

Q-A 的唯一標識碼。

metadata

MetadataDTO[]

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

questions

string[]

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

source

string

maxLength: 300

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

QnASearchResult

代表搜尋結果。

名稱 類型 Description
answer

string

答:

context

Context

QnA 的內容物件

id

integer (int32)

QnA 結果的標識碼。

metadata

MetadataDTO[]

元數據清單。

questions

string[]

問題清單。

score

number

搜尋結果分數。

source

string

QnA 結果的來源。

QnASearchResultList

代表問題解答清單。

名稱 類型 Description
answers

QnASearchResult[]

代表搜尋結果清單。

QueryDTO

POST 本文架構以查詢知識庫。

名稱 類型 Description
context

Context

具有先前 QnA 資訊的內容物件。

isTest

boolean

針對測試索引進行查詢。

qnaId

string

要從知識庫擷取的確切 qnaId,此字段優先於問題。

question

string

要查詢知識庫的用戶問題。

rankerType

string

選擇性欄位。 設定為 『QuestionOnly』,以便只使用問題排名器。

scoreThreshold

number

根據分數傳回的答案閾值。

strictFilters

MetadataDTO[]

只尋找包含這些元數據的解答。

strictFiltersCompoundOperationType

StrictFiltersCompoundOperationType

選擇性欄位。 設定為 OR 以使用 OR 做為嚴格篩選的作業。

top

integer (int32)

要針對問題傳回的答案數目上限。

userId

string

使用者的唯一標識碼。 遙測的選擇性參數。 如需詳細資訊,請參閱 Analytics 和 Telemetry

StrictFiltersCompoundOperationType

選擇性欄位。 設定為 OR 以使用 OR 做為嚴格篩選的作業。

Description
AND
OR